0

I'm using leaflet 0.7. I'm wondering what spatial reference system is used when a new marker is created? Also, how does this impact my use of maps? (I'm using leaflet .7 because of dependency requirements from other plugins). I'm using ESRI base map tiles from the esri-leaflet plugin, which I think are EPSG:3857. I have data in a postgis database in EPSG:4269. When I use the latlong from a new marker in leaflet, I get errors when trying to use that to compare it to spatial data in my database - IE find nearest geometries. I keep reading on the internet that leaflet uses 3857. However, when I transform the point from 3857 to 4269, my spatial queries don't work. However, when I do something like this, and assume the point is in 4326 in leaflet and then transform to 4269, it works - ST_Transform(ST_SetSRID(ST_MakePoint(-96.78427, 32.78299),4326),4269)).

So -

  1. Is this the case that a new marker in leaflet has coordinates stored in EPSG:4326?

  2. If I add a map tile layer like ESRI that is EPSG:3857, or some other coordinate system, even though I transform the coordinate clicks from the markers for use in the DB, does this mean that the points don't quite line up as they should on the map?

1 Answer 1

0

In applications that display EPSG:3857 basemap tiles, latlngs supplied to L.markers are reprojected, but not transformed. Another way of saying this is that Leaflet assumes that lat/long coordinates share the same WGS84 (EPSG:4326) datum as the basemap tiles.

The good news is that Esri's hosted tile services (which use the tiling scheme popularized by Google) won't allow you to zoom the map in close enough for the error introduced by failing to transform your NAD83 coordinates to be noticeable.

2
  • So, if I wanted to allow a user to click on a map, and I wanted to gather two of those clicks and accurately measure the distance between them, how would I handle this, if I wanted to do it as accurately as possible? The user is associating that click with what they see on the map, IE an intersection. So, I assume that the distance measure would need to be done in whatever SRS the basemap is in? If lets say, I know this measure is only being done in North Texas, could I transform the chosen coordinates to an SRS more specific for the North Texas area and measure distance accurately?
    – cs1337
    Commented Jun 25, 2016 at 16:35
  • plugins like 'leaflet-measure' use the Haversine formula under the hood to calculate geodesic distances between lat/long coordinate pairs. github.com/ljagis/leaflet-measure Commented Jun 27, 2016 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.