4 files modified
1 files added
| | |
| | | if (!res.state) { |
| | | console.log(res) |
| | | if (typeof res.intlat === "string") { |
| | | window.parent.showTip("获取定位失败") |
| | | // that.parent.showTip("获取定位失败") |
| | | //向uniapp传值 |
| | | uni.postMessage({ |
| | | data: { |
| | | action: 'message' |
| | | } |
| | | }); |
| | | uni.getEnv(function(res) { |
| | | console.log('当前环境:' + JSON.stringify(res)); |
| | | }); |
| | | } else { |
| | | that.addIcon([res.intlat[1], res.intlat[0]]); |
| | | } |
| | |
| | | window.qq = window.qq || {}, qq.maps = qq.maps || {}, window.soso || (window.soso = qq), soso.maps || (soso.maps = qq |
| | | .maps), qq.maps.Geolocation = function() { |
| | | "use strict"; |
| | | var e = [], |
| | | t = null, |
| | | o = 0, |
| | | n = "_geoIframe_" + Math.ceil(1e7 * Math.random()), |
| | | i = document.createElement("iframe"), |
| | | r = null, |
| | | s = null, |
| | | a = null, |
| | | c = null, |
| | | u = function(u, l) { |
| | | if (!u) return void alert("请输入key!"); |
| | | if (!l) return void alert("请输入referer!"); |
| | | var p = document.getElementById(n); |
| | | if (!p) { |
| | | i.setAttribute("id", n), i.setAttribute("allow", "geolocation"); |
| | | var g = "https:"; |
| | | i.setAttribute("src", g + "//web.byisf.com/txdw/tools/geolocation?key=" + u + "&referer=" + l), i |
| | | .setAttribute("style", "display: none; width: 100%; height: 30%"), document.body ? document.body |
| | | .appendChild(i) : document.write(i.outerHTML); |
| | | var m = this; |
| | | window.addEventListener("message", function(n) { |
| | | var i = n.data; |
| | | if (i && "geolocation" == i.module) { |
| | | if (clearTimeout(c), e.length > 0) { |
| | | var u = e.shift(); |
| | | u.sucCb && u.sucCb(i) |
| | | } |
| | | o = 2, m.executeNextGeo(), t && t(i) |
| | | } else { |
| | | s = (new Date).getTime(); |
| | | var l = s - r; |
| | | if (l >= a) { |
| | | if (e.length > 0 && "geo" === e[0].type) { |
| | | var u = e.shift(), |
| | | p = { |
| | | type: "fail", |
| | | code: 5, |
| | | message: "The request" |
| | | }; |
| | | u.errCb && u.errCb(p) |
| | | } |
| | | clearTimeout(c), o = -1, m.executeNextGeo() |
| | | } |
| | | if (e.length > 0 && "ip" === e[0].type) { |
| | | var u = e.shift(); |
| | | u.errCb && u.errCb(p) |
| | | } |
| | | } |
| | | }, !1) |
| | | } |
| | | }; |
| | | return u.prototype.executeNextGeo = function() { |
| | | 1 !== o && e.length > 0 && (o = 1, e[0].geoprocess()) |
| | | }, u.prototype.getLocation = function(t, n, i) { |
| | | if (i && i.timeout) { |
| | | var r = new RegExp("^[0-9]*$"); |
| | | if (!r.test(i.timeout)) return void alert("timeout 请输入数字") |
| | | } |
| | | if (e.length > 10) throw new Error("geolocation queue must be lass than 10"); |
| | | e.push({ |
| | | sucCb: t, |
| | | errCb: n, |
| | | option: i, |
| | | geoprocess: this.getOnceLocation, |
| | | type: "geo" |
| | | }), 1 !== o && (o = 1, this.getOnceLocation()) |
| | | }, u.prototype.getOnceLocation = function() { |
| | | var t = e[0] && e[0].option; |
| | | r = (new Date).getTime(), a = t && t.timeout ? +t.timeout : 1e4, clearTimeout(c), c = setTimeout( |
| | | function() { |
| | | if (e.length > 0) { |
| | | var t = e.shift(); |
| | | t.errCb && t.errCb() |
| | | } |
| | | }, a), document.getElementById(n).contentWindow.postMessage("getLocation", "*") |
| | | }, u.prototype.getIpLocation = function(t, n) { |
| | | if (e.length > 10) throw new Error("geolocation queue mast be lass than 10"); |
| | | e.push({ |
| | | sucCb: t, |
| | | errCb: n, |
| | | geoprocess: this.getOnceIpLocation, |
| | | type: "ip" |
| | | }), 1 !== o && (o = 1, this.getOnceIpLocation()) |
| | | }, u.prototype.getOnceIpLocation = function() { |
| | | document.getElementById(n).contentWindow.postMessage("getLocation.robust", "*") |
| | | }, u.prototype.watchPosition = function(e) { |
| | | t = e, document.getElementById(n).contentWindow.postMessage("watchPosition", "*") |
| | | }, u.prototype.clearWatch = function() { |
| | | t = null, document.getElementById(n).contentWindow.postMessage("clearWatch", "*") |
| | | }, u |
| | | }(); |
| | | window.qq = window.qq || {}, qq.maps = qq.maps || {}, window.soso || (window.soso = qq), soso.maps || (soso.maps = qq.maps), qq.maps.Geolocation = function () { "use strict"; var e = [], t = null, o = 0, n = "_geoIframe_" + Math.ceil(1e7 * Math.random()), i = document.createElement("iframe"), r = null, s = null, a = null, c = null, u = function (u, l) { if (!u) return void alert("请输入key!"); if (!l) return void alert("请输入referer!"); var p = document.getElementById(n); if (!p) { i.setAttribute("id", n), i.setAttribute("allow", "geolocation"); var g = "https:"; i.setAttribute("src", g + "//apis.map.qq.com/tools/geolocation?key=" + u + "&referer=" + l), i.setAttribute("style", "display: none; width: 100%; height: 30%"), document.body ? document.body.appendChild(i) : document.write(i.outerHTML); var m = this; window.addEventListener("message", function (n) { var i = n.data; if (i && "geolocation" == i.module) { if (clearTimeout(c), e.length > 0) { var u = e.shift(); u.sucCb && u.sucCb(i) } o = 2, m.executeNextGeo(), t && t(i) } else { s = (new Date).getTime(); var l = s - r; if (l >= a) { if (e.length > 0 && "geo" === e[0].type) { var u = e.shift(), p = { type: "fail", code: 5, message: "The request" }; u.errCb && u.errCb(p) } clearTimeout(c), o = -1, m.executeNextGeo() } if (e.length > 0 && "ip" === e[0].type) { var u = e.shift(); u.errCb && u.errCb(p) } } }, !1) } }; return u.prototype.executeNextGeo = function () { 1 !== o && e.length > 0 && (o = 1, e[0].geoprocess()) }, u.prototype.getLocation = function (t, n, i) { if (i && i.timeout) { var r = new RegExp("^[0-9]*$"); if (!r.test(i.timeout)) return void alert("timeout 请输入数字") } if (e.length > 10) throw new Error("geolocation queue must be lass than 10"); e.push({ sucCb: t, errCb: n, option: i, geoprocess: this.getOnceLocation, type: "geo" }), 1 !== o && (o = 1, this.getOnceLocation()) }, u.prototype.getOnceLocation = function () { var t = e[0] && e[0].option; r = (new Date).getTime(), a = t && t.timeout ? +t.timeout : 1e4, clearTimeout(c), c = setTimeout(function () { if (e.length > 0) { var t = e.shift(); t.errCb && t.errCb() } }, a), document.getElementById(n).contentWindow.postMessage("getLocation", "*") }, u.prototype.getIpLocation = function (t, n) { if (e.length > 10) throw new Error("geolocation queue mast be lass than 10"); e.push({ sucCb: t, errCb: n, geoprocess: this.getOnceIpLocation, type: "ip" }), 1 !== o && (o = 1, this.getOnceIpLocation()) }, u.prototype.getOnceIpLocation = function () { document.getElementById(n).contentWindow.postMessage("getLocation.robust", "*") }, u.prototype.watchPosition = function (e) { t = e, document.getElementById(n).contentWindow.postMessage("watchPosition", "*") }, u.prototype.clearWatch = function () { t = null, document.getElementById(n).contentWindow.postMessage("clearWatch", "*") }, u }(); |
| New file |
| | |
| | | window.qq = window.qq || {} |
| | | qq.maps = qq.maps || {} |
| | | window.soso || (window.soso = qq) |
| | | soso.maps || (soso.maps = qq.maps); |
| | | (function () { |
| | | function getScript (src) { |
| | | var protocol = (window.location.protocol == "https:") ? "https://" : "http://" |
| | | src = src && (src.indexOf("http://") === 0 || src.indexOf("https://") === 0) ? src : protocol + src |
| | | document.write('<' + 'script src="' + src + '"' + ' type="text/javascript"><' + '/script>') |
| | | } |
| | | qq.maps.__load = function (apiLoad) { |
| | | delete qq.maps.__load |
| | | apiLoad([["2.4.142", "T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", 0], ["https://mapapi.qq.com/", "jsapi_v2/2/4/142/mods/", "https://mapapi.qq.com/jsapi_v2/2/4/142/theme/", true], [1, 18, 34.519469, 104.461761, 4], [1645433081331, "https://pr.map.qq.com/pingd", "https://pr.map.qq.com/pingd"], ["https://apis.map.qq.com/jsapi", "https://apikey.map.qq.com/mkey/index.php/mkey/check", "https://sv.map.qq.com/xf", "https://sv.map.qq.com/boundinfo", "https://sv.map.qq.com/rarp", "https://apis.map.qq.com/api/proxy/search", "https://apis.map.qq.com/api/proxy/routes/", "https://confinfo.map.qq.com/confinfo", "https://overseactrl.map.qq.com"], [[null, ["https://rt0.map.gtimg.com/tile", "https://rt1.map.gtimg.com/tile", "https://rt2.map.gtimg.com/tile", "https://rt3.map.gtimg.com/tile"], "png", [256, 256], 3, 19, "114", true, false], [null, ["https://m0.map.gtimg.com/hwap", "https://m1.map.gtimg.com/hwap", "https://m2.map.gtimg.com/hwap", "https://m3.map.gtimg.com/hwap"], "png", [128, 128], 3, 18, "110", false, false], [null, ["https://p0.map.gtimg.com/sateTiles", "https://p1.map.gtimg.com/sateTiles", "https://p2.map.gtimg.com/sateTiles", "https://p3.map.gtimg.com/sateTiles"], "jpg", [256, 256], 1, 19, "101", false, false], [null, ["https://rt0.map.gtimg.com/tile", "https://rt1.map.gtimg.com/tile", "https://rt2.map.gtimg.com/tile", "https://rt3.map.gtimg.com/tile"], "png", [256, 256], 1, 19, "", false, false], [null, ["https://sv0.map.qq.com/hlrender/", "https://sv1.map.qq.com/hlrender/", "https://sv2.map.qq.com/hlrender/", "https://sv3.map.qq.com/hlrender/"], "png", [256, 256], 1, 19, "", false, false], [null, ["https://rtt2.map.qq.com/rtt/", "https://rtt2a.map.qq.com/rtt/", "https://rtt2b.map.qq.com/rtt/", "https://rtt2c.map.qq.com/rtt/"], "png", [256, 256], 1, 19, "", false, false], null, [["https://rt0.map.gtimg.com/vector/", "https://rt1.map.gtimg.com/vector/", "https://rt2.map.gtimg.com/vector/", "https://rt3.map.gtimg.com/vector/"], [256, 256], 3, 18, "114", ["https://rt0.map.gtimg.com/icons/", "https://rt1.map.gtimg.com/icons/", "https://rt2.map.gtimg.com/icons/", "https://rt3.map.gtimg.com/icons/"], []], null], ["https://s.map.qq.com/TPano/v1.1.2/TPano.js", "map.qq.com/", ""], "{\"ver\":5,\"isup\":1,\"url\":\"https://mapstyle.qpic.cn/fileupdate/jsauto/style?id=30&version=5\"}"], loadScriptTime) |
| | | } |
| | | var loadScriptTime = (new Date).getTime() |
| | | getScript("https://mapapi.qq.com/jsapi_v2/2/4/142/main.js") |
| | | |
| | | })() |
| | |
| | | //url解码 |
| | | this.getdata = this.getQueryVariable('data') || data |
| | | |
| | | console.log(this.getdata, 456) |
| | | this.map = this.beginMap(this.map, this.getdata) //创建并接受map |
| | | this.map.invalidateSize(true) //应用地图高度 |
| | | }, |
| | |
| | | getLocationData () { |
| | | var that = this |
| | | var geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq") |
| | | var positionNum = 0 |
| | | var options = { |
| | | timeout: 8000 |
| | | } |
| | | |
| | | var options = { |
| | | timeout: 8000 //延时 |
| | | } |
| | | var geocoder |
| | | var latLng |
| | | // 定位成功之后调用的方法 |
| | | function showPosition (position) { |
| | | |
| | | that.regionName = position.district || position.city |
| | | |
| | | console.log(position) |
| | | |
| | | var adCode = position.adCode //邮政编码 |
| | | var nation = position.nation //中国 |
| | | var city = position.city //城市 |
| | | var addr = position.addr //详细地址 |
| | | that.lat = position.lat // |
| | | that.lng = position.lng //火星坐标 //TODO 实现业务代码逻辑 |
| | | |
| | | if (that.LXdhStart != null) { |
| | | that.map.removeLayer(that.LXdhStart) |
| | | } |
| | | // 逆地址解析(经纬度到地名转换过程) |
| | | geocoder = new qq.maps.Geocoder({ |
| | | complete: function (res) { |
| | | if (that.LXdhStart != null) { |
| | | that.map.removeLayer(that.LXdhStart) |
| | | } |
| | | |
| | | //绘制起点和终点 |
| | | that.LXdhStart = L.markerClusterGroup() |
| | | //绘制起点和终点 |
| | | that.LXdhStart = L.markerClusterGroup() |
| | | |
| | | var transportIcon = L.Icon.extend({ //图标初始化 |
| | | options: { |
| | | iconSize: [50, 50], // 图标尺寸 |
| | | var transportIcon = L.Icon.extend({ //图标初始化 |
| | | options: { |
| | | iconSize: [50, 50], // 图标尺寸 |
| | | } |
| | | }) |
| | | |
| | | var qd = new transportIcon({ |
| | | iconUrl: './img/dingw.gif' |
| | | }) |
| | | |
| | | that.LXdhStart.addLayer(L.marker([that.lat, that.lng], { |
| | | icon: qd, |
| | | })) |
| | | |
| | | that.map.addLayer(that.LXdhStart) |
| | | |
| | | } |
| | | }) |
| | | |
| | | var qd = new transportIcon({ |
| | | iconUrl: './img/dingw.gif' |
| | | }) |
| | | latLng = new qq.maps.LatLng(that.lat, that.lng) |
| | | |
| | | that.LXdhStart.addLayer(L.marker([that.lat, that.lng], { |
| | | icon: qd, |
| | | })) |
| | | |
| | | that.map.addLayer(that.LXdhStart) |
| | | geocoder.getAddress(latLng) |
| | | |
| | | }; |
| | | |
| | | function showErr () { |
| | | //TODO 如果出错了调用此方法 |
| | | }; |
| | | console.log('定位失败') |
| | | } |
| | | |
| | | geolocation.getLocation(showPosition, showErr, options) |
| | | }, |
| | | } |
| | | |
| | | }, |
| | | created () { }, |
| | | mounted () { |
| | | this.getDataList() |
| | | this.getLocationData() |
| | | |
| | | }, |
| | | wacth: {} |
| | | }) |
| | |
| | | <!-- <script src="../map/lib/layui/layui.js" charset="utf-8"></script> --> |
| | | |
| | | <!-- 百度地图api --> |
| | | <script type="text/javascript" src="https://mapapi.qq.com/web/mapComponents/geoLocation/v/geolocation.min.js"> |
| | | </script> |
| | | <!-- <script type="text/javascript" src="https://mapapi.qq.com/web/mapComponents/geoLocation/v/geolocation.min.js"> |
| | | </script> --> |
| | | |
| | | <script charset="utf-8" src="./js/geolocation.min.js"></script> |
| | | |
| | | <script charset="utf-8" src="./js/getPosition.js"></script> |
| | | |
| | | |
| | | |
| | | <!-- axios支持 --> |
| | | <script src="../map/lib/axios.js"></script> |
| | |
| | | |
| | | <body> |
| | | <div id="mapVue"> |
| | | |
| | | <div class="dingwei" @click="locationMap"> |
| | | <img style="width: 80%;height: 80%;" src="./img/dingwei.png" alt=""> |
| | | </div> |
| | | |
| | | <div id="map"> |
| | | |