How do I remove default markers?

Google MapsGoogle Maps-Api-3Google Maps-MarkersInfowindow

Google Maps Problem Overview


I'm using Google Map API V3 and I noticed there are a lot of markers which are here even though I don't need them. For examples, some schools or other places with InfoWindows appearing when clicking on them.

Is there any way I can remove them or is it just not possible?

Google Maps Solutions


Solution 1 - Google Maps

The only markers that should show up on the map are those you add yourself. Care to share your code or a page where we can see this happening?

Update: ok, these aren't really 'markers' in the normal sense of the word, they're just points of interest, which happen to behave like markers in that you can click on them and see infowindows. It seems to me that these might be of the class MapTypeStyleFeatureType, probably of types like poi.medical, poi.park, transit.station.rail and so on. I wonder if you could use the MapTypeStyle. Maybe something like this:

var myStyles =[
	{
		featureType: "poi",
		elementType: "labels",
		stylers: [
		      { visibility: "off" }
		]
	}
];

var myOptions = {
	zoom: 10,
	center: homeLatlng,
	mapTypeId: google.maps.MapTypeId.ROADMAP,
	styles: myStyles 
};

You might also want to look at the Styled Map Wizard

Update, July 2016: The Maps API also now has an option you can specify in the MapOptions, clickableIcons, which if you set to false, the icons for these POIs will appear but clicking them doesn't open Google's infowindows. This saves you having to set the styles to hide the icons unless you want to, if all you need to do is prevent the clicks opening the infowindows. Just set clickableIcons: false in the options you initialise the Map with.

Solution 2 - Google Maps

You might have a look at custom styled maps.

There is also a wizard that helps to build the options array.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWeierView Question on Stackoverflow
Solution 1 - Google MapsduncanView Answer on Stackoverflow
Solution 2 - Google MapsJiri KrizView Answer on Stackoverflow