谷歌地图标记 - 自定义颜色的图像

时间:2014-10-25 14:30:03

标签: google-maps svg google-maps-markers

我想使用100种不同颜色的标记。我可以通过复制和绘制100种颜色的标记来实现这一点,但如果可能的话,如果可能的话,可以更容易地制作一个透明图像并在运行时绘制它,或者为每个标记动态构建SVG。有什么选择?

 var marker = new google.maps.Marker( {            
                position: position,
                map: map,
                icon: 'http://example.com/mymarker.png
                });

enter image description here

感谢

1 个答案:

答案 0 :(得分:0)

这有效......

         var SVG_icon = {               
            path: 'M  0,0,  0,-40,  20,-30 , 0,-20,  z',                
            // set custom fillColor on each iteration
            fillColor: fillColour,
            fillOpacity: 0.7,
            scale: 1,
            strokeColor: 'black',
            strokeWeight: 2
          };

        // create marker and put it on map
        var marker = new google.maps.Marker({
            position: myLocation,
            icon: SVG_icon,
            map: map
        });

SVG生成标志的示例

enter image description here

相关问题