vue-leaflet/Vue2Leaflet

`latLngToContainerPoint` gives wrong container point values

Closed this issue · 2 comments

Description

Leaflet API function latLngToContainerPoint gives wrong output with Vue2-Leaflet.

Live Demo

https://jsfiddle.net/bravik/rcsh14x8/8/

Also here is a fiddle with plain leaflet:
http://jsfiddle.net/bravik/42wopgrz/
to demonstrate that there is no such problem in plain version without Vue2-Leaflet

Steps to Reproduce

Try to click on the marker on fiddle.
The output on your right side would be a result of latLngToContainerPoint function for fixed marker LatLng. That should be a Point with x and y realted to map container.

Also mouseContainerPoint result would be outputed to compare the values.
They should be nearly the same if you click on marker.

Try to pan and zoom and click the marker.
The values would not match at all.

Then try to zoom in - the values for latLngToContainerPoint would show obviously impossible for container values. Probably the result is not related to container but to layer?

Expected Results

A point with x and y relatively to the container

Actual Results

Unrelated to container point value. Probably relatively to the map layer?

Browsers Affected

  • [X ] Chrome
  • [?] Firefox
  • [?] Edge
  • [?] Safari 9
  • [?] Safari 8
  • [?] IE 11

Versions

  • Leaflet: v1.6.0
  • Vue2Leaflet: v2.5.2

@bravik this is an interesting bug! Will take a look soon

mikeu commented

This appears to be a bug in the demo, not in the library. The original live demo displays what it calls the "marker container point", but it calculates that based on the location of the original centre of the map. Which is of course often nowhere near the marker on the screen or in the container, especially after zooming in and panning around.

Here is a fork of the fiddle, with the map.latLngToContainerPoint now called with the coordinates of the marker, instead of the coordinates of the initial map centre: https://jsfiddle.net/munderwood/jnbueqvz/

No matter how much you pan or zoom, clicking near the marker leads to very similar values for both the mouse click container point and the marker container point.