在网站上插入高德地图的方法分享。
1、在头部body加入以下代码:
<script src="https://webapi.amap.com/maps?v=1.4.15&key=key值"></script> <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
2、正文地图区域,记得给container定义宽和高:
<div id="container"></div>
3、css代码:
#container {width:100%; height: 550px; }4、底部调用地图js:
<script>
var marker, map = new AMap.Map("container", {
resizeEnable: true,
center: [120.188258,30.121094],
zoom: 16
});
map.setMapStyle('amap://styles/whitesmoke');
marker = new AMap.Marker({
icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
position: [120.188258,30.121094]
});
marker.setMap(map);
</script>注意: [120.188258,30.121094] 根据具体的地址坐标填写。坐标获取:https://lbs.amap.com/dev/mapstyle/edit?styleid=4bce31e306518094153989f12d3e9804amap:/
yles/whitesmoke 为自定义地图样式,如需更改参见:
https://lbs.amap.com/api/javascript-api/guide/map/map-style/
yles/whitesmoke 为自定义地图样式,如需更改参见:https://lbs.amap.com/api/javascript-api/guide/map/map-style/
我是有底线的
扫描二维码手机查看该文章
文章引用:https://www.qinghuahulian.com/news/webzhishi/1213.html




