I'm trying to read a .geoJson file that will add some points to a map. my data file lookes like this:
{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "start": "1970", "end": "1972" },"geometry": { "type": "Point", "coordinates": [ 11.924550479340329, 55.94619451008279 ] } },
{ "type": "Feature", "properties": { "start": "1975", "end": "1976" }, "geometry": { "type": "Point", "coordinates": [ 12.06219628503271, 55.909617190392566 ] } }, { "type": "Feature", "properties": { "start": "1979", "end": "1980" }, "geometry": { "type": "Point", "coordinates": [ 12.06219628503271, 55.909617190392566 ] } },
{ "type": "Feature", "properties": { "start": "1980", "end": "1985" }, "geometry": { "type": "Point", "coordinates": [ 12.284822339303718, 55.639778377234506 ] } }
]
};
so this is the data.geojson.
as you can see there are start date and end date and i need to use this to put it in a timeline else i would just have used addTo(map) and all the points will be there.
but my code to call my file is:
var points = null;
$.getJSON("data.geojson", function(data) {
points = L.geoJson(data);
});
to try and test if the code works I did a "points.addTo(map);" and it all went blank on my screen, I'm sure my data works because when i write the code like this:
$.getJSON("data.geojson", function(data) {
points = L.geoJson(data).addTo(map);
});
I can see all the points. But by doing this I can't use my data for the right purpose. Hope some one can help me with this problem.