francoisromain / leaflet-markers-canvas

A Leaflet plugin to render many markers in a canvas instead of the DOM
GNU Affero General Public License v3.0
42 stars 15 forks source link

how can i rotate marker #3

Closed FazelSaeedi closed 2 years ago

FazelSaeedi commented 3 years ago

hi please create an example that can CreateMarker EditsameMarker change angle of marker (use for flight )

Michael-372 commented 2 years ago

I was able to rotate my markers like so:

    const marker = L.marker(latLong, {
      icon: L.icon({
        iconUrl: 'myIcon.png'.
        iconSize: [20, 20],
        iconAnchor: [10, 10],
        rotationAngle: 45,  // Pick your rotation
      }),
    });

If you want to try to change the angle of a marker after drawing I think you could probably do something like:

    const markerCanvas = new L.MarkersCanvas();

    let marker = L.marker(latLong, {
      icon: L.icon({
        iconUrl: 'myIcon.png'.
        iconSize: [20, 20],
        iconAnchor: [10, 10],
        rotationAngle: 45,  // Pick your rotation
      }),
    });

    markerCanvas.addMarkers([marker]);  // Draw at 45
    markerCanvas.removeMarkers([marker]);

    let marker = L.marker(latLong, {
      icon: L.icon({
        iconUrl: 'myIcon.png'.
        iconSize: [20, 20],
        iconAnchor: [10, 10],
        rotationAngle: 90,  // Pick your rotation
      }),
    });
    markerCanvas.addMarkers([marker]);  // Draw at 90