I've set up a layer on my leaflet map and have a capitalCities.js file that contains data for markers I want to add to the map. Here's a snippet from the capitalCities file:
let capitals = [{"CountryName":"Somaliland","CapitalName":"Hargeisa","CapitalLatitude":"9.55","CapitalLongitude":"44.050000","CountryCode":"NULL","ContinentName":"Africa"},{"CountryName":"South Georgia and South Sandwich Islands","CapitalName":"King Edward Point","CapitalLatitude":"-54.283333","CapitalLongitude":"-36.500000","CountryCode":"GS","ContinentName":"Antarctica"},{"CountryName":"French Southern and Antarctic Lands","CapitalName":"Port-aux-Français","CapitalLatitude":"-49.35","CapitalLongitude":"70.216667","CountryCode":"TF","ContinentName":"Antarctica"}];
I'm trying to figure out the best approach for adding these markers to the map. I've been considering using an ajax request like the one below, but I'm struggling with how to integrate it with the leaflet layers map. So far, this is what I have in my JS file:
let capitalCityLat; let capitalCityLon;
This is the ajax request I'm currently working with:
$.ajax({
url: "js/capitalCities.js",
type: 'POST',
dataType: 'json',
data: {
capital: $('CapitalLatitude', 'CapitalLongitude' ).val()
},
success: function(result) {
Any advice or guidance would be greatly appreciated.
Thank You