美文网首页vue系列
高德地图自定义marker

高德地图自定义marker

作者: litielongxx | 来源:发表于2022-08-01 17:32 被阅读0次

自定义marker后,会因为地图默认使用3d的造成实际位置偏移。
越缩放越明显,需要offset处理下。
常用在自定义图标和替换当前位置上。


image.png
  let marker = new AMap.Marker({
                        offset:new AMap.Pixel(-10,-14),// 图大小决定类似 tranformcss 一半
                        title: item.name,
                        position: item.arr,//位置
                        icon: new AMap.Icon({
                            image: "xx.png",
                            size: new AMap.Size(20, 26.5),
                            imageSize: new AMap.Size(20, 26.5)//图标大小
             })
      })

参考资料
https://www.cnblogs.com/istream/p/5940274.html

相关文章

网友评论

    本文标题:高德地图自定义marker

    本文链接:https://www.haomeiwen.com/subject/resjwrtx.html