- 接入腾讯地图插件后,用户的坐标错位,为什么却定位到了非洲大海里?
<template> <view class="content"> <map id="map" :latitude="latitude" :longitude="longitude" :style="{ width: '100%', height: windowHeight + 'px' }" :scale="10" @markertap="markTap"></map> </view> </template> <script> export default { data() { return { _mapContext: null, windowHeight: 0, latitude: 23.099994, longitude: 113.324520, } }, onLoad() { }, onReady() { uni.getSystemInfo({ success: (res) => { this.windowHeight = res.windowHeight; }, }); // 创建map对象 this._mapContext = uni.createMapContext("map", this); this.cluster(); }, methods: { markTap(e) { console.log('ccccccc') console.log(e) console.log('ccccccc') uni.showToast({ title: `客户名称${e.markerId}` }) }, // 点聚合 cluster() { // 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {}) this._mapContext.initMarkerCluster({ enableDefaultStyle: false, // 是否使用默认样式 zoomOnClick: true, // 点击聚合的点,是否改变地图的缩放级别 gridSize: 60, // 聚合计算时网格的像素大小,默认60 complete(res) { console.log('initMarkerCluster', res) } }); this._mapContext.on("markerClusterCreate", (res) => { console.log("markerClusterCreate", res); const clusters = res.clusters const markers = clusters.map(cluster => { const { center, clusterId, markerIds } = cluster return { ...center, width: 0, height: 0, clusterId, // 必须 label: { content: markerIds.length + '', fontSize: 16, color: '#ffffff', width: 50, height: 50, bgColor: '#00A3FA', borderRadius: 25, textAlign: 'center', anchorX: 0, anchorY: -20, } } }) this._mapContext.addMarkers({ markers, clear: false, complete(res) { console.log('clusterCreate addMarkers', res) } }) }); this._mapContext.on('markerCl
06-05 - 用户发布定位获取返回经纬度坐标,与实际地图定位不匹配。怎么解决?
/** * 中文地址解析为经纬度 * * @param address * @return */ public ResponseResult<RegeoModel> regeo(String address) { ResponseResult<RegeoModel> result = new ResponseResult<>(); result.setStatus(-1); try { String url = "https://apis.map.qq.com/ws/geocoder/v1/?address="; URIBuilder urlBuilder = new URIBuilder(url); urlBuilder.addParameter("address", address); urlBuilder.addParameter("key", key); HttpGet httpGet = new HttpGet(urlBuilder.build()); HttpResponse httpResponse = httpClient.execute(httpGet); if (validHttpStatusCode(httpResponse)) { result.setStatus(ResponseResult.status_success); String response = EntityUtils.toString(httpResponse.getEntity()); logger.debug("", response); JSONObject map = JSONObject.parseObject(response); if (map.getInteger("status") == 0) { JSONObject resultData = map.getJSONObject("result"); RegeoModel regeoModel = new RegeoModel(); JSONObject location = resultData.getJSONObject("location"); regeoModel.setLng(location.getBigDecimal("lng")); regeoModel.setLat(location.getBigDecimal("lat")); JSONObject addressComponents = resultData.getJSONObject("address_components"); regeoModel.setProvince(addressComponents.getString("province")); regeoModel.setCity(addressComponents.getString("city")); regeoModel.setDistrict(addressComponents.getString("district")); regeoModel.setStreet(addressComponents.getString("street")); JSONObject adInfo = resultData.getJSONObject("ad_info"); if (adInfo != null && adInfo.get("adcode") != null) { regeoModel.setAdCode(adInfo.getString("adcode")); } result.setData(regeoModel); return result; } else { result.setStatus(map.getInteger("status")); lo
06-05 - wx.getLocation接口为什么一直不通过,有什么类目要求吗?,场景也描述了
wx.getLocation接口为什么一直不通过,有什么类目要求吗?,场景也描述了,反复申请了几十次了,类目也换过
2022-11-10