开发者

Google Maps API V3 prevent from adding "Listing by" when placing markers after a places search

开发者 https://www.devze.com 2023-03-05 01:47 出处:网络
I run a search using google.maps.places.PlacesService(map) and then I place markers on the map which is fine. I do this every time the \"dragend\" event occurs.

I run a search using google.maps.places.PlacesService(map) and then I place markers on the map which is fine. I do this every time the "dragend" event occurs.

But then, every time, it added on the right side o开发者_开发技巧f the map "Listing by yellowpages". So if I scroll 3 times, I get 3 "Listing by yellowpages". How do I remove that?


I had a similar problem using the Google Maps API. Turns out it was caused by the fact I was creating a new PlacesService object every time, and when I switched to having just the single PlacesService object, this problem went away.

So make sure you only have once PlacesService object created and linked to the map.


Show last listing-by only

lib jquery

service = new google.maps.places.PlacesService(map);
service.textSearch(request, function(request, status){
    if(status==google.maps.places.PlacesServiceStatus.OK){
        $('.listing-by-map').hide();
        $('#map div').last().addClass('listing-by-map');
        //...
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消