收藏
回答

微信小程序获取地理位置?

微信小程序在开发者工具上可以获取到地理位置,但是在微信中获取不到地理位置,是什么原因呢? 

wx.getLocation({

                type: 'wgs84',

                altitude: false,

                success: (res) => {

                    that.setData({

                        latitude: res.latitude,

                        longitude: res.longitude

                    })

                    let locationString = res.latitude + "," + res.longitude;

                    wx.request({

                        url: 'http://apis.map.qq.com/ws/geocoder/v1/',

                        data: {

                            "key""ABCDEFHJ,KL",

                            "location": locationString

                        },

                        method: 'GET',

                        success: function (res) {

                            that.setData({

                                position: res.data.result.address_component.street_number

                            })

                        }

                    });


                },

                fail: () => {


                },

                complete: () => { }

            });


回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签