Hi! I'm new to Leaflet, and enjoying it so far.
I'm making a simple map of the US, overlaid with the state boundaries, loaded in as GeoJSON. Since the GeoJSON is large (1.6MB), I have it in a separate external file, rather than directly in my JavaScript. Thus, I'm instantiating the Leaflet map first, then using jQuery to do an asynchronous call back to the server to retrieve the GeoJSON. Once the file is loaded, it is inserted as a new GeoJSON layer on the map:
$.get("data/state-outlines_20m.json", function(data) {
alert("geojson file loaded");
//When GeoJSON is loaded
var geojsonLayer = new L.GeoJSON(data); //New GeoJSON layer
map.addLayer(geojsonLayer); //Add layer to map
});
This works perfectly when serving from localhost, but not at all once moved to an external server. In that case, the alert is fired (the file is loaded into memory), but Leaflet throws a JS error: Error: Invalid GeoJSON object.
Any thoughts on what to test next to troubleshoot this? Thanks!