I'm starting with some valid GeoJSON which I've built using https://geojson.io. My desire is to load it in an Openlayers 5 map.
I started with this tutorial, and attempted to use a remote source in place of a local one. The relevant block looks like the following:
var map = new Map({
layers: [
new TileLayer({
source: new OSM()
})
],
target: "map",
view: new View({
center: [-13739617.939346, 6179221.917031],
zoom: 11
})
});
map.once("postrender", () => {
axios.get(jsonUrl).then(({ data } = {}) => {
const jsonSource = new VectorSource({
features: new GeoJSON().readFeatures(data, {
featureProjection: "EPSG:4326"
})
});
const jsonLayer = new VectorLayer({
source: jsonSource,
style: jsonStyleFunction
});
map.addLayer(jsonLayer);
});
});
When I fail to load, I was able to use console logs to determine that there the breaking point wasn't the get request. I was also able to see the there was the same number of featureChangeKeys_
in the jsonSource
const as there were features in my JSON object:
featureChangeKeys_:
39: (2) [{…}, {…}]
41: (2) [{…}, {…}]
43: (2) [{…}, {…}]
45: (2) [{…}, {…}]
47: (2) [{…}, {…}]