高德地图js api添加自定义底图切换,添加谷歌影像底图

//初始化地图
function initMapNew(){

    //定义谷歌卫星切片图层
    var googleLayer = new AMap.TileLayer({
          getTileUrl: 'http://mt{1,2,3,0}.google.cn/vt/lyrs=s&hl=zh-CN&gl=cn&x=[x]&y=[y]&z=[z]&s=Galile'
        });
    map = new AMap.Map(id,{
        resizeEnable:true,
        zoom:zoom,
        center:[117.219499,39.015873],
    });
    AMapUI.loadUI(['control/BasicControl'], function(BasicControl) {
    
        //图层切换控件
        map.addControl(new BasicControl.LayerSwitcher({
            position: 'rt',
            baseLayers: [{
                enable: true,
                id: 'tile',
                name: '矢量图',
                layer: new AMap.TileLayer()
            }, {
                id: 'satellite',
                name: '谷歌影像图',
                layer: googleLayer
            }],
        }));
    });

    //显示工具条
    map.plugin(["AMap.ToolBar"],function(){
        //加载工具条
        var tool = new AMap.ToolBar();
        map.addControl(tool);    
    });

}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Vue高德地图自定义标记可以通过以下步骤进行: 1. 引入高德地图JavaScript API 在Vue组件的script标签中引入高德地图JavaScript API,例如: ``` <script src="https://webapi.amap.com/maps?v=1.4.15&key=你的key"></script> ``` 其中key为你的高德地图开发者账号的应用key。 2. 定义地容器 在Vue组件的template标签中定义地容器,例如: ``` <template> <div id="map-container"></div> </template> ``` 其中id为map-container的div元素用于承载地。 3. 初始化地对象 在Vue组件的script标签中,通过AMap.Map类初始化地对象,例如: ``` <script> export default { mounted() { const map = new AMap.Map('map-container', { zoom: 13, center: [116.397428, 39.90923] }); } } </script> ``` 其中zoom表示地缩放级别,center表示地中心点坐标。 4. 自定义标记标 在Vue组件的script标签中,通过AMap.Icon类定义自定义标记标,例如: ``` <script> export default { mounted() { const icon = new AMap.Icon({ size: new AMap.Size(50, 50), image: 'https://webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png', imageSize: new AMap.Size(50, 50) }); } } </script> ``` 其中size表示标记标尺寸,image表示标记片地址,imageSize表示标记标显示尺寸。 5. 添加自定义标记 在Vue组件的script标签中,通过AMap.Marker类添加自定义标记,例如: ``` <script> export default { mounted() { const map = new AMap.Map('map-container', { zoom: 13, center: [116.397428, 39.90923] }); const icon = new AMap.Icon({ size: new AMap.Size(50, 50), image: 'https://webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png', imageSize: new AMap.Size(50, 50) }); const marker = new AMap.Marker({ position: [116.397428, 39.90923], icon: icon, offset: new AMap.Pixel(-25, -25) }); marker.setMap(map); } } </script> ``` 其中position表示标记位置坐标,icon表示标记标,offset表示标记标偏移量。 6. 完整代码 ``` <template> <div id="map-container"></div> </template> <script> export default { mounted() { const map = new AMap.Map('map-container', { zoom: 13, center: [116.397428, 39.90923] }); const icon = new AMap.Icon({ size: new AMap.Size(50, 50), image: 'https://webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png', imageSize: new AMap.Size(50, 50) }); const marker = new AMap.Marker({ position: [116.397428, 39.90923], icon: icon, offset: new AMap.Pixel(-25, -25) }); marker.setMap(map); } } </script> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值