Skip to content

Commit e77c8f7

Browse files
committed
feat: google地图自动检测是否支持
1 parent 1086cd0 commit e77c8f7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

resource/2021/1117_gps.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,22 @@ var pageControl = {
3434
"http://mt2.google.cn/vt/lyrs=y&hl=zh-CN&gl=cn&x=[x]&y=[y]&z=[z]&s=Galil",
3535
zIndex: 3,
3636
});
37+
38+
const amapSatelliteLayer = new AMap.TileLayer.Satellite();
39+
const amapRoadNetLayer = new AMap.TileLayer.RoadNet();
40+
3741
const map = new AMap.Map(mapContainer, {
3842
resizeEnable: true,
3943
zoom: 15,
4044
center: [116.397428, 39.90923],
41-
layers: [googleLayer],
45+
layers: [amapSatelliteLayer, amapRoadNetLayer],
4246
});
47+
48+
const testGoogleImage = new Image();
49+
testGoogleImage.src = `//mt2.google.cn/vt/lyrs=y&hl=zh-CN&gl=cn&x=17294&y=15469&z=15&s=Galil?t=${+Math.random()}`;
50+
testGoogleImage.onload = () => {
51+
map.setLayers([googleLayer]);
52+
};
4353
/* var marker = new AMap.Marker({
4454
position: new AMap.LngLat(116.397428, 39.90923), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
4555
title: "北京",
@@ -107,7 +117,7 @@ var pageControl = {
107117
})
108118
);
109119
}
110-
120+
111121
return markers;
112122
},
113123
getFiles: function (fileList) {
@@ -216,9 +226,8 @@ var pageControl = {
216226
gps2Google(GPSLongitude)
217227
)}${GPSLongitudeRef}`;
218228
this.dumpDetail("gps坐标", `${lon},${lat}`, googleUrl);
219-
}else{
220-
this.dumpDetail("gps坐标", '无GPS坐标,统一显示在天安门');
221-
229+
} else {
230+
this.dumpDetail("gps坐标", "无GPS坐标,统一显示在天安门");
222231
}
223232

224233
var detailFields = {

0 commit comments

Comments
 (0)