I have a website pune.org that uses places API. As you can see however if I select markers the Listings by lines just keep getting added and eventually make the entire map area useless.
How can I reset the Listings by or ideally to just show Listings by of the marker that is currently selected?
Thanks,
Sandeep
You’re instantiating the Places Service several times in your code, every time the map pans for example. You need to set a global variable named service at the beginning, then instantiate the Places Service once (*during your map initialization would be appropriate). Then you can simply call the
service.searchmethod in your other functions, rather than instantiating the service over and over.So:
Then remove the other instances of
service = new google.maps.places.PlacesService(map);in your code and only callservice.search(request, callback);