pixelToLatlng Method
This method returns the latitude and longitude of a point in the canvas in reference of a tileMap()
.
Usage
pixelToLatlng(x, y)
Get the latitude and longitude coordinates for a (x,y) pixel position. Returns an object with lat and lng.
x: x coordinate.
y: xycoordinate.
Examples:
if (mouseIsPressed) {
// Store the current latitude and longitude of the mouse position
const position = myMap.pixelToLatlng(mouseX, mouseY);
}
An interactive example can be built like this: