Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

What is GeoJson? Using Leaflet.JS

I used Leaflet.js at my previous job last year. I think in C# code, we created a FeatureCollection (something like that). We also had Geometry column in the database.

1. Now, I have an address and have its longitude and latitude. I get this, for example, from Google API.  I'll save this in the database

2. In Leaflet.JS, I can use GeoJson --> https://leafletjs.com/examples/geojson/

My questions... can I just use the Longitude and Latitude of the address with Leaflet.js?  how does GeoJson come into play ... I don't know why that project had a Geometry column in the database? Why do I need GeoJson? How can I create GeoJson for an address?
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Camillia

ASKER

If you were storing map data that you would need to display on a map then this would be the way to store it.

I think I stored it in a JS file at my last job and used the JS file with Leaflet to show a location on the map. There was a C# code to create that GeoJson written by another developer and I used the output of the C# code to save the data in a JS file.

Question
If I don't use GeoJson and just want to save the longitude and Latitude ... I can only save that and use lan and lat to display a location on the map with Leaflet.Js, Correct? if no, I'll look at GeoJson. (I don't have the code from my previous job)
That is fine - the GeoJson is just a way to specify map data that you would want to add to your map in one go. So you can add a lot of things to your map with a single call - passing in the GeoJSON file as opposed to lots of individual calls to create the objects you want to see on your map.
ah, I get it.

One last question...at my last job, the Geometry column in the database was to store this GeoJson data, I'm guessing. Correct?
Difficult to say as I was personally not at your last job :) but judging from the name it sounds like that could be the case.
Hahaha thanks.
great info, as always. Thanks.
You are welcome.