I'm learning how to build GIS web applications, and I'm getting an HTTP Error 404.3 - Not Found trying to load a geojson file into a map built with leaflet. I'w checking the map directly online in my website
In I have inserted this tag that calls the AJAX file:
The script is:
var geojsonLayer = new L.GeoJSON.AJAX('/.../data/attractions.geojson', {pointToLayer: function(feature, latlng) {
var str = "<h4>"+feature.properties.name+"</h4><hr>";
str += "<a href='"+feature.properties.web+"' target='blank'>";
str += "<img src='img/"+feature.properties.image+"' width='200px'>";
str += "</a>";
return L.marker(latlng).bindPopup(str);
}});
geojsonLayer.addTo(mymap);
Everything is right, but I read this error loading my geojson.
I think the problem is with the geojson file extension, but I don't know how I can handle it. I use a windows hosting through Aruba. The file is not damaged (I tried to open it on Qgis without problems)
I just fixed the problem, I hope to help someone to save time since I lost hours today.
Basically, you just need to replace ".geojson" with ".json" (without changing the file extension).
I do not understand why, and if you have the answer please let me now, but now it works.