4

我正在使用Leaflt-routing-machine插件,我需要将标记的颜色从蓝色更改为红色,请问有什么建议吗?!

4

1 回答 1

3

我相信这应该可以正常工作

var redIcon = new L.Icon({
  iconUrl: 'https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-red.png',
  shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
  iconSize: [25, 41],
  iconAnchor: [12, 41],
  popupAnchor: [1, -34],
  shadowSize: [41, 41]
});



 L.Routing.control({
      waypoints: [
        L.latLng(57.74, 11.94),
        L.latLng(57.6792, 11.949)
      ],
      collapsible: true, // hide/show panel routing
      autoRoute: true, // possibility to take autoRoute
      language : 'fr', 
     // THIS IS ESPECIALLY WHAT YOU SHOULD ADD (createMarker):
      createMarker: function(i, wp, nWps) {
        return L.marker(wp.latLng, {icon: redIcon });
      },
      // ...
    }).addTo(this.map);
于 2019-10-17T10:17:50.700 回答