-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
It would be helpful if we had an option to not show the Marker Icon until the map is clicked.
I was able to override this behavior in the L.Draw.Marker._onMouseMove Event by setting the opacity of the marker to 0.
L.Draw.Marker = L.Draw.Marker.extend({
_onMouseMove: function (e) {
var latlng = e.latlng;
this._tooltip.updatePosition(latlng);
this._mouseMarker.setLatLng(latlng);
if (!this._marker) {
this._marker = new L.Marker(latlng, {
icon: this.options.icon,
zIndexOffset: this.options.zIndexOffset,
opacity: 0, //Override: Hide marker
});
// Bind to both marker and map to make sure we get the click event.
this._marker.on('click', this._onClick, this);
this._map
.on('click', this._onClick, this)
.addLayer(this._marker);
}
else {
latlng = this._mouseMarker.getLatLng();
this._marker.setLatLng(latlng);
}
}
});
However, it would seem more feasible to do something like changing:
if (!this._marker)
to
if (!this._marker && this.options.showMarkerOnMouseMove)
Use case here is quite simple...we don't see the marker until the map is clicked, similar to the polygon draw.
Metadata
Metadata
Assignees
Labels
No labels