javascript - Redrawing custom marker in leaflet -


i have created custom marker , added in draw control toolbar :

l.draw.mymarker = l.draw.marker.extend({     initialize : function(map, options) {         this.type = 'mymarker';         l.draw.feature.prototype.initialize.call(this, map, options);     } }); 

now can draw marker on map draw control toolbar.

requirements :

further need save details of mymarker in database (latlong ,options etc). later need redraw same markers fetching details db , displaying them on map.

problem :

found 1 solution re-create marker is:

//step 1. extending marker marker class l.mymarker = l.marker.extend({}); //step 2. recreating marker persisted data l.mymarker([lat, long], {}).addto(map); 

but want create instance of l.draw.mymarker drawn toolbar.

so need l.draw.mymarker([lat, long], {}).addto(map);

given circumstances, think going have duplicate of custom marker logic in extends l.marker able use outside of leaflet.draw context...because l.draw.marker extends l.draw.feature(https://github.com/leaflet/leaflet.draw/blob/master/src/draw/handler/draw.marker.js#l1), while leafet's marker extends l.layer(https://github.com/leaflet/leaflet/blob/master/src/layer/marker/marker.js#l5)..so that's not clear inheritance tree overriding things between two.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -