Google会将搜索更改选定的位置地址

时间:2018-01-11 07:45:53

标签: angular google-maps google-places-api google-places

我在Angular 5应用程序中实现了google places插件:

我使用了以下配置代码:

// load Places Autocomplete
  const autocomplete = new google.maps.places.Autocomplete(
    this.searchElementRef.nativeElement,
    {
      types: []
    }
  );

  autocomplete.addListener('place_changed', () => {
    this.ngZone.run(() => {
      const place = autocomplete.getPlace();
      console.log('place', place);
      console.log('lat', place.geometry.location.lat());
      console.log('lng', place.geometry.location.lng());
    });
  });

现在当我尝试搜索某些内容时:ex- sys它会显示如下列表:

Search 1

现在我选择的是第一个结果,即Syston United Kingdom,它给出了不同的结果,即Syston, Leicester LE7, UK

Search result

任何人都遇到过这个问题而且知道如何解决这个问题?

控制台结果:

Console Log

0 个答案:

没有答案