Leaflet / Leafdoc

A lightweight NaturalDocs-like LeafletJS-style documentation generator
54 stars 19 forks source link

Feature Request -Hide Marker Icon until Map Is Clicked #27

Closed bbehling closed 7 years ago

bbehling commented 7 years ago

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.

IvanSanchez commented 7 years ago

This is the issue tracker for Leafdoc, not for Leaflet.Draw. Please report issues/feature requests in the right repo.