I have a leaflet map, and I have a set of country borders in a long JSON file. I am trying to use the JSON coordinates to draw a solid green border along the border of a country displayed in the map object.
I do not want to draw a fully covered layer over the country either.
I have built a JS function that makes an Ajax call to request JSON border coordinates for a specific country.
When the JSON data is received, I apply and bound it to the map object.
function applyCountryBorder(countryname) {
var addresssObj = null;
jQuery.ajax({
type: 'GET',
dataType: 'json',
url: 'https://nominatim.openstreetmap.org/search?country=' + countryname.trim() + '&polygon_geojson=1&format=json',
async: true,
cache: true,
success: function(responseData) {
var polyline = L.polyline(responseData[0].geojson.coordinates, {
color: 'green',
weight: 14,
opacity: 1
}).addTo(map);
map.invalidateSize();
},
error: function(responseData) {
addresssObj = responseData;}
});
}
I expect the border of the specified country to have a bright, solid, thick, green line. But actually, the map and country borders remain unchanged and remain default.
What am I doing wrong? How can I achieve the desired goal?