| | |
| | | return layer; |
| | | }, |
| | | |
| | | createMarker({ position, icon, label, extData }) { |
| | | createMarker({ position, img, label = ' ', extData }) { |
| | | //创建 AMap.Icon 实例: |
| | | const icon = new AMap.Icon({ |
| | | size: new AMap.Size(30, 30), //图标尺寸 |
| | | image: img, //Icon 的图像 |
| | | // imageOffset: new AMap.Pixel(-9, -3), //图像相对展示区域的偏移量,适于雪碧图等 |
| | | imageSize: new AMap.Size(30, 30) //根据所设置的大小拉伸或压缩图片 |
| | | }); |
| | | const marker = new AMap.Marker({ |
| | | position: position, |
| | | offset: new AMap.Pixel(-10, -10), |
| | | // offset: new AMap.Pixel(-13, -30), |
| | | icon: icon, //添加 icon 图标 URL |
| | | title: label, |
| | | label: { |
| | |
| | | }, |
| | | extData |
| | | }); |
| | | map.add(marker); |
| | | // map.add(marker); |
| | | return marker; |
| | | } |
| | | }; |