Auto Commit

上级 f48a4a07
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="text/javascript" src='https://a.amap.com/jsapi_demos/static/citys.js'></script>
<script type="module" src="/src/main.js"></script> <script type="module" src="/src/main.js"></script>
</body> </body>
</html> </html>
...@@ -18,16 +18,46 @@ function initMap() { ...@@ -18,16 +18,46 @@ function initMap() {
zoom: 4, //初始化地图级别 zoom: 4, //初始化地图级别
center: [104.06, 35.67], //初始化地图中心点位置 center: [104.06, 35.67], //初始化地图中心点位置
}); });
generatePoints().forEach((item) => { // generatePoints().forEach((item) => {
const marker = new AMap.Marker({ // const marker = new AMap.Marker({
position: new AMap.LngLat(item.position[0], item.position[1]), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9] // position: new AMap.LngLat(item.position[0], item.position[1]), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
title: '北京' // title: '北京'
}); // });
// 将创建的点标记添加到已有的地图实例: // // 将创建的点标记添加到已有的地图实例:
map.add(marker); // map.add(marker);
}) // })
var style = [{
url: 'https://a.amap.com/jsapi_demos/static/images/mass0.png',
anchor: new AMap.Pixel(6, 6),
size: new AMap.Size(11, 11)
}, {
url: 'https://a.amap.com/jsapi_demos/static/images/mass1.png',
anchor: new AMap.Pixel(4, 4),
size: new AMap.Size(7, 7)
}, {
url: 'https://a.amap.com/jsapi_demos/static/images/mass2.png',
anchor: new AMap.Pixel(3, 3),
size: new AMap.Size(5, 5)
}
];
var mass = new AMap.MassMarks(citys, {
opacity: 0.8,
zIndex: 111,
cursor: 'pointer',
style: style
});
var marker = new AMap.Marker({ content: ' ', map: map });
mass.on('mouseover', function (e) {
marker.setPosition(e.data.lnglat);
marker.setLabel({ content: e.data.name })
});
mass.setMap(map);
}).catch(e => { }).catch(e => {
console.log(e); console.log(e);
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册