mding5692 mding5692 - 5 months ago 33
CSS Question

Disable infowindows for businesses and other POIs aside from your own polygons google maps

Google Maps allows Points of Interests such as Restaurants and stuff to appear clickable and displays their infowindows when clicked which is not what I want. I need only the infowindows attached to my polygons to be clickable and pop open infowindows. I noticed that a way of fixing this would be changing the style of the google maps:

[
{
featureType: "poi.business",
elementType: "labels",
stylers: [
{ visibility: "off" }
]
}
]


but infowindows still appeared for things like attractions and other random clickable things, how would I be able to disable the infowindows for things like these? Or can you just use featureType: "poi" and featureType: "transit" to set the visibility to off to fix this issue?

Answer

Ok I made a function that can remove most of the features:

                    /**
                     * Remove all other unnecessary infowindows by rendering Points of Interest invisible
                     * Takes the map, applicable for Google Maps API
                     **/
                     function suppressUnnecessayInfoWindows(mapUsed) {
                        // removes POIs and Transit features off the map
                        var noFeatures = [
                                {
                                    featureType: "poi",
                                    stylers: [
                                      { visibility: "off" }
                                    ]   
                                  },
                                  {
                                    featureType: "transit",
                                    stylers: [
                                      { visibility: "off" }
                                    ]   
                                  }
                                ];
                        // changes the style of the map so that the above is no longer visible
                        mapUsed.setOptions({styles: noFeatures});
                     }
Comments