如何在Ionic 3中获得更准确的地理定位

时间:2017-09-23 14:34:53

标签: ionic-framework ionic3

我开发了一款应用程序,需要在我提出要求时提供准确的地理位置信息。

到目前为止,它仅在大约40%的时间内正确地提供信息。有什么我想念的吗?

以下是为获取它而编写的函数。

 initMap(){

let optionsGPS = {timeout: 20000, enableHighAccuracy: true};
this.geolocation.getCurrentPosition(optionsGPS).then((position) => {

  let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
  let mylat =  position.coords.latitude;
  let mylng =  position.coords.longitude;
  let mylatlng = {
    'lat': mylat,
    'lng': mylng
  };

  let mapOptions = {
    center: latLng,
    zoom: 16,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }

  this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
  this.addMarker(mylatlng, 'You', 'you');

  for (let provider of this.myProviders) {

    this.addMarker(provider, provider['name'], provider['type']);
  }
});

}

非常感谢任何建议。

0 个答案:

没有答案