I work on a GIS web app using GeoDjango and I struggle reading and displaying a multipoint geometry on my map.
If I serialize my GEOSGeometry object to GeoJSON, I can get the following JSON file :
{ "type": "MultiPoint", "coordinates": [ [ X0, Y0, Z0 ], [ X1, Y1, Z1 ], ... ]}
Now, when I want to read this data using readGeometry()
as follows
var vectorSource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readGeometry(geojson_object),
});
I get the error SyntaxError: JSON.parse: expected property name or '}' at line 1 column 3 of the JSON data
I tried parsing my data using GeoJSONLint but it does seem correct.
So I tried to use readFeature()
(as I only have one feature) as a matter of testing with slight modification to my geojson file :
{ "type": "Feature", "geometry" : { "type": "MultiPoint", "coordinates": [ [ X0, Y0, Z0 ], [ X1, Y1, Z1 ], ... ] } }
Then I get TypeError: n.features.getArray is not a function
Again, if I use readFeatures()
on the same feature object, I get no error whereas it should expect a collection of features, right ?
What am I missing ? The openlayers documentation is not that clear to me.