提交 08e7d544 编写于 作者: d-u-a's avatar d-u-a

update: H5 map组件支持用户在manifest配置key,增加错误提示信息

上级 8610f162
...@@ -29,7 +29,7 @@ export default { ...@@ -29,7 +29,7 @@ export default {
} }
}, },
mounted () { mounted () {
var key = 'WXTBZ-6WERU-ECCVS-BZJCK-LW5OJ-SIBOS' var key = __uniConfig.qqMapKey
this.src = `https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=uniapp` this.src = `https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=uniapp`
window.addEventListener('message', (event) => { window.addEventListener('message', (event) => {
var loc = event.data var loc = event.data
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<script> <script>
import SystemHeader from '../system-header' import SystemHeader from '../system-header'
const key = 'WXTBZ-6WERU-ECCVS-BZJCK-LW5OJ-SIBOS' const key = __uniConfig.qqMapKey
const referer = 'uniapp' const referer = 'uniapp'
const poimarkerSrc = 'https://apis.map.qq.com/tools/poimarker' const poimarkerSrc = 'https://apis.map.qq.com/tools/poimarker'
......
...@@ -9,7 +9,7 @@ function wgs84ToGcj02 (coords, success, error) { ...@@ -9,7 +9,7 @@ function wgs84ToGcj02 (coords, success, error) {
/** /**
* uniapp 内置key * uniapp 内置key
*/ */
var key = 'WXTBZ-6WERU-ECCVS-BZJCK-LW5OJ-SIBOS' var key = __uniConfig.qqMapKey
var url = `https://apis.map.qq.com/ws/coord/v1/translate?locations=${coords.latitude},${coords.longitude}&type=1&key=${key}&output=jsonp` var url = `https://apis.map.qq.com/ws/coord/v1/translate?locations=${coords.latitude},${coords.longitude}&type=1&key=${key}&output=jsonp`
getJSONP(url, {}, (res) => { getJSONP(url, {}, (res) => {
if ('locations' in res && res.locations.length) { if ('locations' in res && res.locations.length) {
...@@ -18,7 +18,7 @@ function wgs84ToGcj02 (coords, success, error) { ...@@ -18,7 +18,7 @@ function wgs84ToGcj02 (coords, success, error) {
latitude: res.locations[0].lat latitude: res.locations[0].lat
}) })
} else { } else {
error() error(res)
} }
}, error) }, error)
} }
...@@ -48,9 +48,9 @@ export function getLocation ({ ...@@ -48,9 +48,9 @@ export function getLocation ({
if (type === 'WGS84') { if (type === 'WGS84') {
callback(coords) callback(coords)
} else { } else {
wgs84ToGcj02(coords, callback, () => { wgs84ToGcj02(coords, callback, (err) => {
invoke(callbackId, { invoke(callbackId, {
errMsg: 'getLocation:fail' errMsg: 'getLocation:fail ' + JSON.stringify(err)
}) })
}) })
} }
......
...@@ -791,7 +791,7 @@ export default { ...@@ -791,7 +791,7 @@ export default {
maps = window.qq.maps maps = window.qq.maps
callback() callback()
} else { } else {
let key = 'XVXBZ-NDMC4-JOGUS-XGIEE-QVHDZ-AMFV2' let key = __uniConfig.qqMapKey
let callbackName = '_callback' + Date.now() let callbackName = '_callback' + Date.now()
window[callbackName] = function () { window[callbackName] = function () {
delete window[callbackName] delete window[callbackName]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册