@@ -18,6 +18,9 @@ var pageControl = {
18
18
const fullBtn = $ ( ".fullscreen-btn" ) ;
19
19
const btnAmapTile = $ ( "#btnAmapTile" ) ;
20
20
const btnGoogleTile = $ ( "#btnGoogleTile" ) ;
21
+ const roadBtn = $ ( "#roadBtn" ) ;
22
+ const googlePioBtn = $ ( "#googlePioBtn" ) ;
23
+ var roadNetLayer = new AMap . TileLayer . RoadNet ( ) ;
21
24
22
25
fullBtn . addEventListener ( "click" , ( ) => {
23
26
$ ( ".container" ) . classList . toggle ( "fullscreen" ) ;
@@ -33,27 +36,54 @@ var pageControl = {
33
36
} ) ;
34
37
} ) ;
35
38
36
- const googleLayer = new AMap . TileLayer ( {
39
+ roadBtn . addEventListener ( "click" , ( e ) => {
40
+ if ( roadBtn . checked ) {
41
+ map . add ( roadNetLayer ) ;
42
+ } else {
43
+ map . remove ( roadNetLayer ) ;
44
+ }
45
+ } ) ;
46
+
47
+ googlePioBtn . addEventListener ( "click" , ( e ) => {
48
+ if ( googlePioBtn . checked ) {
49
+ map . add ( googleLayerWithPio ) ;
50
+ map . remove ( googleLayerPure ) ;
51
+ } else {
52
+ map . remove ( googleLayerWithPio ) ;
53
+ map . add ( googleLayerPure ) ;
54
+ }
55
+ } ) ;
56
+
57
+ const googleLayerPure = new AMap . TileLayer ( {
58
+ tileUrl :
59
+ "http://mt2.google.com/vt/lyrs=s&hl=zh-CN&gl=cn&x=[x]&y=[y]&z=[z]&s=Galil" ,
60
+ zIndex : 3 ,
61
+ } ) ;
62
+ const googleLayerWithPio = new AMap . TileLayer ( {
37
63
tileUrl :
38
64
"http://mt2.google.com/vt/lyrs=y&hl=zh-CN&gl=cn&x=[x]&y=[y]&z=[z]&s=Galil" ,
39
65
zIndex : 3 ,
40
66
} ) ;
41
- this . googleLayer = googleLayer ;
67
+ this . googleLayerPure = googleLayerPure ;
68
+ this . googleLayerWithPio = googleLayerWithPio ;
42
69
43
70
const amapSatelliteLayer = new AMap . TileLayer . Satellite ( ) ;
44
71
const amapRoadNetLayer = new AMap . TileLayer . RoadNet ( ) ;
45
72
46
73
const map = new AMap . Map ( mapContainer , {
47
74
resizeEnable : true ,
48
75
zoom : 15 ,
76
+ zooms : [ 2 , 30 ] ,
49
77
center : [ 116.397428 , 39.90923 ] ,
78
+ layers : [ new AMap . TileLayer . Satellite ( ) ]
50
79
} ) ;
51
80
52
81
const testGoogleImage = new Image ( ) ;
53
- testGoogleImage . src = `//mt2.google.com/vt/lyrs=y &hl=zh-CN&gl=cn&x=17294&y=15469&z=15&s=Galil?t= ${ + Math . random ( ) } ` ;
82
+ testGoogleImage . src = `//mt2.google.com/vt/lyrs=s &hl=zh-CN&gl=cn&x=17294&y=15469&z=15&s=Galil` ;
54
83
testGoogleImage . onload = ( ) => {
55
- map . add ( [ googleLayer ] ) ;
84
+ map . add ( [ googleLayerWithPio ] ) ;
56
85
} ;
86
+ //map.add(roadNetLayer);
57
87
/* var marker = new AMap.Marker({
58
88
position: new AMap.LngLat(116.397428, 39.90923), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
59
89
title: "北京",
@@ -334,11 +364,12 @@ var pageControl = {
334
364
} ,
335
365
//设置高德瓦片
336
366
setAMapTile ( ) {
337
- this . map . remove ( this . googleLayer ) ;
367
+ this . map . remove ( this . googleLayerWithPio ) ;
368
+ this . map . remove ( this . googleLayerPure ) ;
338
369
} ,
339
370
//设置谷歌瓦片
340
371
setGoogleTile ( ) {
341
- this . map . add ( this . googleLayer ) ;
372
+ this . map . add ( this . googleLayerWithPio ) ;
342
373
} ,
343
374
} ;
344
375
function initializegooglemap ( ) {
0 commit comments