您可以将标记图标声明为symbol https://developers.google.com/maps/documentation/javascript/3.exp/reference#Symbol并进行相应的定制。
new google.maps.Marker({
map: map,
position: map.getCenter(),
icon: {
path: google.maps.SymbolPath.CIRCLE,
fillColor: '#00F',
fillOpacity: 0.6,
strokeColor: '#00A',
strokeOpacity: 0.9,
strokeWeight: 1,
scale: 7
}
});
您可以使用每个属性来实现所需的外观。
如果你想要更详细的东西,我做了(免责声明:是我,因为我做到了) 使用图标字体(例如 font-awesome 或 Material 图标)来渲染图像的库 https://github.com/HuasoFoundries/ig_markerfactory(使用辅助画布,然后获取其 dataurl)。
它基本上是一个图像工厂,您可以将其用作
new google.maps.Marker({
map: map,
position: map.getCenter(),
icon: MarkerFactory.autoIcon({
label: 'f1b9',
font: 'FontAwesome',
color: '#CC0000',
fontsize: 20
})
});
您甚至可以省略font
属性,它将呈现您传递给它的文字文本。我有时用它来枚举标记。