I'm trying to use GeoJson in Here Maps. I'm new to Here Maps API, so I'm following the official example to load a GeoJson and everything works fine if I load the GeoJson from an url. Now I want to load the GeoJson from a JS Object, but the geojson.Reader
method seems that only allows to read an url. Is it possible to load an Object?
var myGeoJsonObject = ...
function showGeoJSONData (map) {
var reader = new H.data.geojson.Reader(myGeoJsonObject), {
style: function (mapObject) {
if (mapObject instanceof H.map.Polygon) {
mapObject.setStyle({
fillColor: 'rgba(255, 0, 0, 0.5)',
strokeColor: 'rgba(0, 0, 255, 0.2)',
lineWidth: 3
});
}
}
});
reader.parse();
map.addLayer(reader.getLayer());
}
From the docs, it seems that you have two options:
.parse
method on the instance and pass your GeoJSON object. You can still pass an options object to the constructor: