高德api标注点坐标

高德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参数
    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) {//创建地图--mapType(0是午夜蓝地图, 1是卫星图)
    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,     //是否自动刷新,默认为false
      'interval': 180,         //刷新间隔,默认180s
    });
}

页面中引用方法

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);   
    //经纬度,图标,窗口内容
},
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值