Use an SVG for a marker in Google Maps?

前端 未结 5 794
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 18:43

i know it\'s possible to add svg overlays to google maps. i\'m wondering if you can use svg files as markers. i tried setting it just like you would a png or jpg file, but nothi

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 19:00

    var marker = new google.maps.Marker({
            icon: {
                size: new google.maps.Size(21, 45),
                origin: new google.maps.Point(0, 0),
                anchor: new google.maps.Point(21, 45),
                url: `data:image/svg+xml;utf-8,
                            POINTCreated with Sketch.`
            }
        });
    

    Live example on codepen.

提交回复
热议问题