1

I am new to Leaflet. Am facing one issue when try to display GeoJSON file in Leaflet.

Issue:

Actually some GeoJSON file only am facing this problem. In my knowledge coordinates are in different format so that am facing this issue.

Please find below sample feature code: coordinates are in high values like [ 352.90679825050762, 891.44899536185403 ] so that it is not projecting properly. So can anyone explain how to convert/change the coordinates (working coordinates for Leaflet) like [ -2.978663816550748, 56.459992535783947 ]?

{ "type": "Feature", "properties": { "Layer": "ANNO-HATCH-ELEV", "SubClasses": "AcDbEntity:AcDbHatch", "ExtendedEntity": "     5      2", "Linetype": "ByBlock", "EntityHandle": "A3475", "Text": "ANSI32" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 352.90679825050762, 891.44899536185403 ], [ 352.90679825050762, 895.32399536185403 ], [ 343.90679825050762, 895.32399536185403 ], [ 343.90679825050762, 883.2927453618795 ], [ 352.90679825049301, 883.2927453618795 ], [ 352.90679825050762, 891.44899536185403 ] ] ] } } 
  • 3
    Your GeoJSON does not conform to the specification. Read tools.ietf.org/html/rfc7946#section-4 – IvanSanchez Jun 11 at 14:39
  • 2
    This is mysteriously similar to stackoverflow.com/questions/62275657/… from yesterday, so I'm forced to guess this is some kind of school assignment. – IvanSanchez Jun 11 at 14:40
  • Okay IvanSanchez.But that same geojson working fine in Openlayer.... – Ram prasad Jun 11 at 14:41
  • What actual CRS is meant to be represented in your GeoJSON file? – nmtoken Jun 11 at 14:53
  • The AcDbEntity:AcDbHatch property leads me to think that it's AutoCAD data, and not GIS data. – IvanSanchez Jun 11 at 15:05
0

Finally I got a solution by unprojecting CRS EPSG3857 then the same geojson file working fine in leaflet.

By adding,

L.CRS.EPSG3857.unproject(point) // where point is coords.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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