高德api标注点坐标
export function punctuationMap1 (dataLon , dataLat , icon ,content , map) {
map.setZoomAndCenter(14, [dataLon, dataLat]);
var viaMarker = new AMap.Marker({
position: new AMap.LngLat(dataLon,dataLat),
icon: icon,
offset: new AMap.Pixel(-13, -30)
});
viaMarker.content = content;
viaMarker.on('click', (e) => markerClickMap(e, map));
map.add([viaMarker]);
}
export function markerClickMap (e, map) {
var infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition());
}
export function initMapPublic (mapType , map , mapId) {
if(mapType == 0){
map = new AMap.Map(mapId , {
resizeEnable: true,
mapStyle: "amap://styles/darkblue",
center: [120.85087,31.712015],
zoom: 18,
});
}else if(mapType == 1){
map = new AMap.Map(mapId , {
resizeEnable: true,
layers: [new AMap.TileLayer.Satellite()],
center: [120.85087,31.712015],
zoom: 18,
});
}
var traffic = new AMap.TileLayer.Traffic({
'autoRefresh': true,
'interval': 180,
});
}
页面中引用方法
import {setCookie,getCookie,delCookie} from '../js/cookie.js';
在页面中调用地图创建的方法
initMapPublic(1,this.map2 ,mapWein);
initMapPublic(0,this.map1 ,map);
调用标点方法
createQueryBridgePoint(data){
let contentTemp = '名称:'+data.mNAME+'<br />方向:'+data.roadDirection+'<br>状态:'+data.mDesc;
punctuationMap1(data.lon ,data.lat ,car ,contentTemp,this.map1);
},