Wechat web page development, how to solve the positioning problem

problem description

recently opened Wechat web page, the project needs to use location function. So Amap jsApi was used. My phone is ios, the location is very normal, but when I switch to some Android phones, I can"t locate it, which directly indicates what geographic location permission is not available. But the mobile phone sets gps, ah, permissions, ah, these are all turned on. I would like to ask you how to solve the problem of Wechat web page development and positioning. Do you have to use Wechat sdk?


aren't you asking for trouble if you want to display a web page in Wechat but don't want to use sdk?


generic api . navigator.geolocation another restriction point is that the website domain name must start with https, otherwise ios cannot use

.
var getCurrentLocation = () => {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition, showError)
  } else {
    console.log('')
  }
}

var showPosition = (position) => {
  store.state.latitude = position.coords.latitude
  store.state.longitude = position.coords.longitude
  // Vue.prototype.$notify({
  //   mes: ':' + position.coords.latitude + ',' + position.coords.longitude
  // })
}
Menu