Skip to content

Commit

Permalink
update google map
Browse files Browse the repository at this point in the history
  • Loading branch information
cavencj committed Jul 30, 2023
1 parent ec69a97 commit 063ebe4
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 22 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ viewer.imageryLayers.add(new Cesium.ImageryLayer( new AmapImageryProvider(option

> 百度地图
```js
```js
var options = {
style: 'normal', // style: img、vec、normal、dark
crs: 'WGS84' // 使用84坐标系,默认为:BD09
Expand All @@ -72,11 +72,12 @@ viewer.imageryLayers.add(new Cesium.ImageryLayer( new GeoVisImageryProvider(opti

## GoogleImageryProvider

> 谷歌地图(已被墙)
> 谷歌地图
```js
var options = {
style: 'img' //style: img、elec、ter
style: 'elec',//style: img、elec、ter,cva,img_cva
crs: 'WGS84' // 使用84坐标系,默认为:GCJ02, img除外
}
viewer.imageryLayers.add(new Cesium.ImageryLayer( new GoogleImageryProvider(options)))
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dvgis/cesium-map",
"version": "3.0.1",
"version": "3.1.0",
"repository": "https://github.com/dvgis/cesium-map.git",
"homepage": "https://www.dvgis.cn",
"author": "Caven Chen <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions src/imagery/amap/AmapImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Date: 2020-01-15 20:31:28
*/

import AmapMercatorTilingScheme from './AmapMercatorTilingScheme'
import GCJ02TilingScheme from '../tiling-scheme/GCJ02TilingScheme'
import { UrlTemplateImageryProvider } from '@cesium/engine'

const TILE_URL = {
Expand All @@ -24,7 +24,7 @@ class AmapImageryProvider extends UrlTemplateImageryProvider {
options['subdomains'] = ['01', '02', '03', '04']
}
if (options.crs === 'WGS84') {
options['tilingScheme'] = new AmapMercatorTilingScheme()
options['tilingScheme'] = new GCJ02TilingScheme()
}
super(options)
}
Expand Down
5 changes: 2 additions & 3 deletions src/imagery/baidu/BaiduImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import {
Cartesian2,
WebMercatorTilingScheme,
DeveloperError,
ImageryProvider,
UrlTemplateImageryProvider,
} from '@cesium/engine'

import BaiduMercatorTilingScheme from './BaiduMercatorTilingScheme'
import BD09TilingScheme from '../tiling-scheme/BD09TilingScheme'

const TILE_URL = {
img: '//shangetu{s}.map.bdimg.com/it/u=x={x};y={y};z={z};v=009;type=sate&fm=46',
Expand All @@ -35,7 +34,7 @@ class BaiduImageryProvider extends UrlTemplateImageryProvider {
for (let i = 0; i < 19; i++) {
resolutions[i] = 256 * Math.pow(2, 18 - i)
}
options['tilingScheme'] = new BaiduMercatorTilingScheme({
options['tilingScheme'] = new BD09TilingScheme({
resolutions,
rectangleSouthwestInMeters: new Cartesian2(-20037726.37, -12474104.17),
rectangleNortheastInMeters: new Cartesian2(20037726.37, 12474104.17),
Expand Down
13 changes: 9 additions & 4 deletions src/imagery/google/GoogleImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
*/

import { UrlTemplateImageryProvider } from '@cesium/engine'
import GCJ02TilingScheme from '../tiling-scheme/GCJ02TilingScheme'

const TILE_URL = {
img: '//mt{s}.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali',
elec: '//mt{s}.google.cn/vt/lyrs=m@207000000&hl=zh-CN&gl=CN&src=app&x={x}&y={y}&z={z}&s=Galile',
ter: '//mt{s}.google.cn/vt/lyrs=t@131,r@227000000&hl=zh-CN&gl=cn&x={x}&y={y}&z={z}&s=Galile',
img: 'https://gac-geo.googlecnapps.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}',
elec: 'https://gac-geo.googlecnapps.cn/maps/vt?lyrs=m&x={x}&y={y}&z={z}',
cva: 'https://gac-geo.googlecnapps.cn/maps/vt?lyrs=h&x={x}&y={y}&z={z}',
ter: 'https://gac-geo.googlecnapps.cn/maps/vt?lyrs=t@131,r&x={x}&y={y}&z={z}',
img_cva: 'https://gac-geo.googlecnapps.cn/maps/vt?lyrs=y&x={x}&y={y}&z={z}',
}

class GoogleImageryProvider extends UrlTemplateImageryProvider {
Expand All @@ -19,7 +22,9 @@ class GoogleImageryProvider extends UrlTemplateImageryProvider {
options.protocol || '',
TILE_URL[options.style] || TILE_URL['elec'],
].join('')
options['subdomains'] = options.subdomains || ['1', '2', '3']
if (options.crs === 'WGS84') {
options['tilingScheme'] = new GCJ02TilingScheme()
}
super(options)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const LL2MC = [
],
]

class BaiduMercatorProjection {
class BD09Projection {
constructor() {
this.isWgs84 = false
}
Expand Down Expand Up @@ -404,4 +404,4 @@ class BaiduMercatorProjection {
}
}

export default BaiduMercatorProjection
export default BD09Projection
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {
defined,
} from '@cesium/engine'

import BaiduMercatorProjection from './BaiduMercatorProjection'
import BD09Projection from '../projection/BD09Projection.js'
import CoordTransform from '../../transform/CoordTransform'

class BaiduMercatorTilingScheme extends WebMercatorTilingScheme {
class BD09TilingScheme extends WebMercatorTilingScheme {
constructor(options) {
super(options)
let projection = new BaiduMercatorProjection()
let projection = new BD09Projection()
this._projection.project = function (cartographic, result) {
result = result || {}
result = CoordTransform.WGS84ToGCJ02(
Expand Down Expand Up @@ -58,7 +58,7 @@ class BaiduMercatorTilingScheme extends WebMercatorTilingScheme {
* @param y
* @param level
* @param result
* @returns {module:cesium.Rectangle|*}
* @returns {Rectangle|*}
*/
tileXYToNativeRectangle(x, y, level, result) {
const tileWidth = this.resolutions[level]
Expand Down Expand Up @@ -107,4 +107,4 @@ class BaiduMercatorTilingScheme extends WebMercatorTilingScheme {
}
}

export default BaiduMercatorTilingScheme
export default BD09TilingScheme
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {

import CoordTransform from '../../transform/CoordTransform'

class AmapMercatorTilingScheme extends WebMercatorTilingScheme {
class GCJ02TilingScheme extends WebMercatorTilingScheme {
constructor(options) {
super(options)
let projection = new WebMercatorProjection()
Expand Down Expand Up @@ -44,4 +44,4 @@ class AmapMercatorTilingScheme extends WebMercatorTilingScheme {
}
}

export default AmapMercatorTilingScheme
export default GCJ02TilingScheme

0 comments on commit 063ebe4

Please sign in to comment.