Use an SVG for a marker in Google Maps?

前端 未结 5 679
爱一瞬间的悲伤
爱一瞬间的悲伤 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:09

    On Google Maps API v3 it's working just fine for me with this code (which also handles resizing):

    var marker = new google.maps.Marker({
      position: new google.maps.LatLng(lat, lng),
      icon: new google.maps.MarkerImage('/path/to/icon.svg',
        null, null, null, new google.maps.Size(64,64)),
      draggable: false,
      map: map
    });
    

提交回复
热议问题