Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work in Leaflet 1.8.0 #171

Open
Nazanne opened this issue May 11, 2022 · 8 comments
Open

Does not work in Leaflet 1.8.0 #171

Nazanne opened this issue May 11, 2022 · 8 comments

Comments

@Nazanne
Copy link

Nazanne commented May 11, 2022

In Leaflet 1.8.0 the map immediately jumps to a new location each time the map is clicked to create a measurement point. This behavior is easily reproachable by updating the demo to Leaflet 1.8.0. For now I've had to revert to Leaflet 1.7.1.

@agishk
Copy link

agishk commented May 20, 2022

@Nazanne Did you find some solution on this? As the measure was perfectly working fine with lower version but not with 1.8.0.

@Nazanne
Copy link
Author

Nazanne commented May 20, 2022

@agishk I did not find a direct solution. At this point I'm using mapbox.js instead of Leaflet.

@Falke-Design
Copy link

The fix would be:

 // get state vars and interface ready for measure
  _startMeasure: function() {
    this._locked = true;
    this._measureVertexes = L.featureGroup().addTo(this._layer);
    this._captureMarker = L.marker(this._map.getCenter(), {
      clickable: true,
      zIndexOffset: this.options.captureZIndex,
      opacity: 0,
      autoPanOnFocus : false
    }).addTo(this._layer);

Workaround:

L.Control.Measure.include({
	// set icon on the capture marker
	_setCaptureMarkerIcon: function () {
		// disable autopan
		this._captureMarker.options.autoPanOnFocus = false;

		// default function
		this._captureMarker.setIcon(
			L.divIcon({
				iconSize: this._map.getSize().multiplyBy(2)
			})
		);
	},
});

var measure = L.control.measure({}).addTo(map);

@ksalamy
Copy link

ksalamy commented May 25, 2022

This did it! Thanks Falke-Design!

@karasma3
Copy link

i am experiencing the same behaviour but with the leaflet version 1.7.1 and leaflet-measure 3.1.0.
@Falke-Design thanks for the workaround, hope this will be fixed in the newer version

bre7 added a commit to bre7/leaflet-measure that referenced this issue Aug 26, 2022
@karasma3
Copy link

@bre7 will this be merged soon?

@bre7
Copy link

bre7 commented Sep 14, 2022

Last commit on Apr 8, 2018 so my guess is...no.
It's just a fork with @Falke-Design's fix.

@abewartech
Copy link

export const MeasureControl = createControlComponent((props) => new Control.Measure(props));

L.Control.Measure.include({ _setCaptureMarkerIcon: function () { this._captureMarker.options.autoPanOnFocus = false; this._captureMarker.setIcon( L.divIcon({ iconSize: this._map.getSize().multiplyBy(2), }), ); }, });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants