google places search api and “Listings by” Text

邮差的信 提交于 2019-12-06 09:21:06

The issue is because the Text "Listing by bla bla" is added every time you create a new instance of google.maps.places.PlacesService. To resolve this make sure that only one instance of the PlacesService is created.One solution which worked for me was having a variable store the first time it loads and then call it from next time on.

//Have a local variable
var placesService;

//Method that will be using the search.
performNearbySearch(placesRequest) {

  //Check if the PlacesService is already instantiated else create it. 
  if (!this.placesService) {
    this.placesService = new google.maps.PlacesService(this.gmap);
  }

  //Create a placesRequest
  var request = placesRequest;

  //Call the API.
  this.placesService.nearbySearch(request, < callback Function > , true));
}

This way only the first time The "Listing Appears".

Check this for more information https://groups.google.com/forum/#!topic/google-maps-js-api-v3/sQ-isvqfdBM

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!