如何更改 Google 地图标记的颜色?

问题描述:

我正在使用 Google Maps API 来构建一个充满标记的地图,但我希望一个标记能从其他标记中脱颖而出.我认为,最简单的做法是将标记的颜色更改为蓝色,而不是红色.这是一件简单的事情还是我必须以某种方式创建一个全新的图标?如果我必须创建一个新图标,最简单的方法是什么?

I'm using the Google Maps API to build a map full of markers, but I want one marker to stand out from the others. The simplest thing to do, I think, would be to change the color of the marker to blue, instead of red. Is this a simple thing to do or do I have to create a whole new icon somehow? If I do have to create a new icon, what's the easiest way to do that?

由于地图 v2 已弃用,您可能对 v3 地图感兴趣:https://developers.google.com/maps/documentation/javascript/markers#simple_icons

Since maps v2 is deprecated, you are probably interested in v3 maps: https://developers.google.com/maps/documentation/javascript/markers#simple_icons

对于 v2 地图:

http://code.google.com/apis/maps/文档/overlays.html#Icons_overview

您将有一组逻辑处理所有常规"引脚,另一组逻辑使用定义的新标记处理特殊"引脚.

You would have one set of logic do all the 'regular' pins, and another that does the 'special' pin(s) using the new marker defined.