How can I create numbered map markers in Google Maps V3?

后端 未结 16 970
予麋鹿
予麋鹿 2020-11-28 18:13

I\'m working on a map that has multiple markers on it.

These markers use a custom icon, but I\'d also like to add numbers on top. I\'ve seen how this has been accomp

16条回答
  •  攒了一身酷
    2020-11-28 18:41

    I discovered the best way to do it. Use Snap.svg to create the svg and then use the function toDataURL() that creates the graphics data to include as icon. Note that I use the SlidingMarker class for the marker that gives me nice movement of the marker. With Snap.svg you can create any kind of graphics and your map will look fantastic.

    var s = Snap(100, 100);
    s.text(50, 50, store.name);
    // Use more graphics here.
    var marker = new SlidingMarker({
      position: {lat: store.lat, lng: store.lng},
      map: $scope.map,
      label: store.name, // you do not need this
      title: store.name, // nor this
      duration: 2000,
      icon: s.toDataURL()
    });
    

提交回复
热议问题