Igor-Vladyka / leaflet.motion

A simple tool to animate polylines and polygons in different way
https://igor-vladyka.github.io/leaflet.motion/
MIT License
207 stars 44 forks source link

Method to get marker #7

Closed aswinkumar863 closed 5 years ago

aswinkumar863 commented 5 years ago

A method like getMarker helps to extend the marker functionality such as bind events to the Leaflet.motion's marker

Current workaround

var motionLine = L.motion.polyline( ... )
var marker = motionLine.__marker

Expected

var motionLine = L.motion.polyline( ... )
var marker = motionLine.getMarker()

Related Stackoverflow questions

Igor-Vladyka commented 5 years ago

Hi there,

Thanks for posting it, and answering all questions on stackoverflow :)

Just added getMarker() and getMarkers() logic to all motion components.

Please let me know if any,

Regards, Igor

aswinkumar863 commented 5 years ago

Thank you @Igor-Vladyka for your support. I will let you know if any :)

andrusha19 commented 4 years ago

Hi Now your demo gives an error in getMarker method: "Uncaught ReferenceError: marker is not defined"

In /dist folder you have this code:

getMarker: function () {
    if (this.markerOptions) {
        if (!this.__marker) {
                this.__marker = L.marker([0, 0], this.markerOptions);
                if (this.markerOptions.showMarker) {
        /* Here it should be this.__marker.addTo(this._map);*/
                     marker.addTo(this._map);   
                 }
        }
    }
    return this.__marker;
}

In source code it looks like:

getMarker: function () {
    return this.__marker;
}

Please correct code in /dist folder