二维码防伪系统

新闻中心

各种活动实时推动

在网站上插入高德地图的方法

发布时间:2024-12-09 点击次数:195

在网站上插入高德地图的方法分享。

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/

copy © 2025 星澜网络 All Rights Reserved

备案号:鲁ICP备2023015769号