I am using mapbox javascript API to do some cool stuff on a map. Now I have a map location (latitude, longitude) pair and I want to set the view to this location then use javascript to simulate a click at this location. The problem is that I need to find out the screen position (x, y) pair of this location after setting the view. But how do I do that?
It seems there is an API L.ICRS. I tried but it returned NaN for both x and y -- please check my example javascript codes below.
var latlng = [40.444621, -79.943231]
map.setView(latlng, 13);
L.CRS.EPSG3857.latLngToPoint(latlng, 13);
Can anybody help me on that? My final goal is to simulate a click at that position.
Thank you very much!
Use the latLngToContainerPoint method off of the map
object.
project is the equivalent function for GL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With