vue使用腾讯地图
创始人
2024-11-10 17:42:12
0

官方地址

先来展示效果图(输入框、文字就不管了自己写就行)

1、创建应用和Key

参照官方文档即可

2、页面引入

在public\index.html页面引入

其中key绑定的值就是

可以上代码了

init() {       this.$nextTick(()=>{         //获取dom节点         var drawContainer = document.getElementById('mapContainer');         // var center = new window.TMap.LatLng(39.984104, 116.307503);//设置中心点坐标   lat: 23.228237   lng: 113.273747         //如果是回显的话直接把经纬度传进去就行         var center = new window.TMap.LatLng(this.latitude, this.longitude);         this.map = new window.TMap.Map(drawContainer, {           zoom: 18,           // pitch: 40,           center: center,           draggable: true,           scrollable: true,           mapStyleId: "style 1"         });         // 初始化marker         this.marker = new window.TMap.MultiMarker({           id: 'marker-layer', // 图层id           map: this.map,           geometries: [             {               "id": "1",   //点标记唯一标识,后续如果有删除、修改位置等操作,都需要此id               "styleId": 'myStyle',  //指定样式id               "position": new TMap.LatLng(this.latitude, this.longitude),  //点标记坐标位置               "properties": {}             }           ]         })                  this.map.on("click", (evt) => {           console.log(evt.poi)           // this.searchValue = evt.poi.name           this.latitude = evt.poi.latLng.lat           this.longitude = evt.poi.latLng.lng           this.jingdu = evt.poi.latLng.lng           this.weidu = evt.poi.latLng.lat           // this.address = evt.poi.name           //点击地图进行标点           this.addPoint(this.latitude,this.longitude)            //逆地址解析,根据经纬度获取当前地址名称           this.getAreaCode()                         });       })            },  addPoint(latitude,longitude) {         //修改id为1的点标记的位置  点可以设置多个,我这里只需要一个因此修改就行         this.marker.updateGeometries([             {             "styleId":"myStyle",             "id": "1",             "position": new window.TMap.LatLng(latitude, longitude),             }         ])     }, //地址逆解析获取详细地址     getAreaCode( ) {     //这里可以直接this.$jsonp地址传入你的经纬度;       this.$jsonp("https://apis.map.qq.com/ws/geocoder/v1/?", {         location: this.latitude+ ',' + this.longitude, // 经纬度         key: "xxxxxx", //这里就是要开启那个service不然会报错让你开启         output: "jsonp", // output必须jsonp   不然会超时       }).then((res) => {       //获取到的res 就是继续的地址的所有信息;         console.log(res)       });     },

相关内容

热门资讯

受玩家影响!pokemmo脚本... 受玩家影响!pokemmo脚本,hhpoker辅助软件下载,学习教程(存在有挂)1、hhpoker辅...
第一分钟辅助!多乐小程序辅助器... 第一分钟辅助!多乐小程序辅助器免费,总是是有辅助方法(有挂详细)1、用户打开应用后不用登录就可以直接...
软件辅助挂!wepoker免费... 软件辅助挂!wepoker免费脚本,德州hhpoker脚本,窍门教程(有挂教程)wepoker免费脚...
第六分钟辅助!微信小程序辅助有... 第六分钟辅助!微信小程序辅助有哪些,都是真的有辅助攻略(有挂细节)1、第六分钟辅助!微信小程序辅助有...
值得注意的是!德州真人透视脚本... 值得注意的是!德州真人透视脚本,大菠萝辅助器,讲义教程(有挂教程)1、德州真人透视脚本脚本辅助下载、...
第8分钟辅助!多乐够级辅助,切... 第8分钟辅助!多乐够级辅助,切实是真的有辅助神器(证实有挂)1、多乐够级辅助辅助器安装包、多乐够级辅...
今日!wepoker怎么设置房... 今日!wepoker怎么设置房间,智星德州可以透视吗,教程书教程(有挂方法)1、用户打开应用后不用登...
第2分钟辅助!丽水都莱辅助器,... 第2分钟辅助!丽水都莱辅助器,其实真的是有辅助挂(有挂细节)1、完成丽水都莱辅助器辅助器v3.3的残...
黑科技技巧!hhpoker是真... 黑科技技巧!hhpoker是真的假的,wepoker辅助器怎么弄,讲义教程(详细教程)1、wepok...
第一分钟辅助!中至上饶有没有挂... 第一分钟辅助!中至上饶有没有挂车,其实是真的有辅助技巧(证实有挂)1、在中至上饶有没有挂车插件功能辅...