Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Leaflet LatLng to x,y pixels image overlay

I have a leaflet map created from an image using imageOverlay for indoor map rendering purposes, I'm wondering given the leaflet latitudes and longitudes how to get the x,y pixels of the image.

like image 637
Louis Lesmana Avatar asked Apr 18 '17 18:04

Louis Lesmana


1 Answers

The simplest conversion for setting and getting pixel coordinates from Lat/Lng system is to use:

  1. Project: to convert from lat/lng to pixels project(<LatLng> latlng, <Number> zoom)
  2. Unproject: to convert from pixels to lat/lng unproject(<Point> point, <Number> zoom)

Always you can refer to Leaflet reference

P.S: consider the Map CRS is set to Simple

like image 133
Mahdi Alkhatib Avatar answered Oct 06 '22 19:10

Mahdi Alkhatib