I have a question in order to developing a web app using dynamic maps with JSON files. I'm using Visual Studio 2015 with MVC 5.
At this moment i have developed complete app but I'm unable to draw points (with Lat and Lng) in a Leaflet map from a JSON File.
My JSON file is similar to:
[{
"latitud": 43.526523590087891,
"longitud": -5.6150951385498047
}, {
"latitud": 43.511680603027344,
"longitud": -5.6671133041381836
},
.
//More Lat-Lng Points
.
{
"latitud": 43.526451110839844,
"longitud": -5.6140098571777344
}]
Currently, I'm using a example of heatmap but is imposible for me represent markers when i try to get coordinates from my JSON file.
Any help?
Best Answer
You have a JSON but Leaflet really likes geoJSONs, so you should convert the JSON to geoJSON first, or directly load a geoJSON. So for your example, if you have:
You can restructure the JSON to a geoJSON:
And last but not least, you can add your new geoJSON to the map:
A full code example to display your points on a map would look like this:
Hope this solves your problem! Cheers