如何删除默认标记?

我使用的是 Google Map API V3,我注意到这里有很多标记,尽管我并不需要它们。例如,一些学校或其他地方在点击时会出现 InfoWindows。

有没有什么办法可以把它们移除,还是根本不可能?

64964 次浏览

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?

更新:好的,这些并不是正常意义上的“标记”,它们只是兴趣点,它们的行为就像标记一样,你可以点击它们并看到信息窗口。在我看来,这些可能是MapTypeStyleFeatureType类,可能是Poi.Medical、Poi.Park、Transit.Station.Rail等类型。我想知道你是否可以使用maptypestyle。也许是这样的:

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.

You might have a look at custom styled maps.

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