微信开发——使用微信接口(获取地理位置) (2)

访问微信接口(获取地理位置接口)

wx.getLocation({ debug: false, type: \'wgs84\', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入\'gcj02\' success(res) { console.log("wx.getLocation"); var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90 var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。 var gpsPoint = new BMap.Point(longitude, latitude); BMap.Convertor.translate(gpsPoint, 0, initMap); //转换坐标 }, fail(err){ console.log(err); } });

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgwjfz.html