- 在html页引入
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=你的key"></script>
- 开始使用
<script>
data() {
return {
markerIcon: {
iconHospital: require("@/views/vsp/assist/img/mapIcon.png")
}
}
},
created() {
this.initMap()
},
methods: {
initMap() {
let that = this;
let map = new AMap.Map('container', {
resizeEnable: true,
zoom: 13,
zooms: [10, 20],
center: [119.859852, 29.192916],
mapStyle: "amap://styles/fresh"
});
that.map = map;
let marker = new AMap.Marker({
position: [119.859852, 29.192916],
});
marker.setMap(that.map);
marker.setLabel({
offset: new AMap.Pixel(0, -8),
content: "<div style='color: #4b89eb'>仁康医院</div>",
direction: 'top'
});
}
}
</script>
高德地图web端api开发参考手册