高德 自定義覆蓋物 信息窗體,站點名稱顯示;

 效果圖,數據需自己模擬;


 

val = {
    name: 'xxx城市',
    position: [123.34534566,41.423443]
}


let marker = new AMap.Marker({
     icon:new AMap.Icon({
     image:'https://a.amap.com/jsapi_demos/static/resource/img/pin.png',
     size:new AMap.Size(32,32),
     imageSize:new AMap.Size(32,32)
     }),

     offset:new AMap.Pixel(-16,-32),
     position: val.position,
     map: map,
     title: val.name,
     });


      marker.setLabel({
      offset: new AMap.Pixel(30, 1),
      content: val.name, //設置文本標註內容
      direction: 'right', //設置文本標註方位
      style: labelStyle   // 自定義文本樣式
      });
      marker.setMap(map);



/**
* labelStyle 自定義樣式如下:
* backgroundColor: "#0c64dee3"
* fillColor: "white"
*/

}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章