匹配行政区划 http://lbs.qq.com/tool/getpoint/getpoint.html http://yt-public.oss-cn-hangzhou.aliyuncs.com/javascripts/xzqhdm.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| mounted() { yt.ready.then(() => { yt.getApiList().then((item) => { $this.isAppUpload = item.list.indexOf('uploadImage')>-1?true:false; }) yt.getLocation().then(res => { Toast(JSON.stringify(res)) this.latLng = res this.mapScript('https://map.qq.com/api/js?v=2.exp&callback=mapInit'); this.mapScript("https://apis.map.qq.com/ws/geocoder/v1/?location=" + res.lat + "," + res.lng + "&key=2AHBZ-4QQWG-UXGQS-IXB4Q-L5WXO-D7FD6&output=jsonp&callback=mapData"); }) }) window.mapInit = this.mapInit; window.mapData = this.mapData; }, methods: { mapData(res){ console.log(res) }, mapInit(lat, lng) { var myLatlng = new qq.maps.LatLng($this.latLng.lat, $this.latLng.lng); var myOptions = { zoom: 17, center: myLatlng, mapTypeId: qq.maps.MapTypeId.ROADMAP } var map = new qq.maps.Map(document.getElementById("container"), myOptions); }, mapScript(url){ var script = document.createElement("script"); script.type = "text/javascript"; script.src = url; document.body.appendChild(script); } }
|