美文网首页
高德地图API

高德地图API

作者: 喵呜Yuri | 来源:发表于2018-02-12 14:47 被阅读91次

1 注册成为开发者

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word;"> http://lbs.amap.com/
</pre>

image

2 进入开发者中心控制台

image

3 创建新应用

image

4 添加新key

image

image

image
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.4&key=您申请的key值&plugin=AMap.ToolBar"></script> 
<script>
    
    

            
    map = new AMap.Map("position", {
        zoom: 18,
        center: ["{$map.longitude}", "{$map.latitude}"]//指定中心
    });
    marker = new AMap.Marker({
        map:map,
        position:["{$map.longitude}", "{$map.latitude}"]//指定标记
    })
    marker.setLabel({
        offset: new AMap.Pixel(20, 20),//修改label相对于maker的位置
        content: '{$map.position}'
    });
    
    marker.on('click',function(e){
        marker.markOnAMAP({
            name:'{$map.position}',
            position:marker.getPosition()
        })
    })
    map.addControl(new AMap.ToolBar());//添加控件
<script>

相关文章

网友评论

      本文标题:高德地图API

      本文链接:https://www.haomeiwen.com/subject/ubgrtftx.html