I need help
I work with the here map api I try to display the contours around a city and I have this as an error
const shape = res.response.isoline[0].component[0].shape.map(z => z.split(','));
here is the complete piece of code
const requestIsolineShape = options => {
const params = {
'mode': fastest;${options.mode};traffic:enabled,
'start': geo!${options.center.lat},${options.center.lng},
'range': options.range,
'rangetype': options.rangeType,
'departure': ${options.date}T${options.time}:00,
};
return new Promise((resolve, reject) => { router.calculateIsoline( params, res => { const shape = res.response.isoline[0].component[0].shape.map(z => z.split(',')); resolve( shape ); }, err => reject(err) ); }); } ;
Please double check in console(Network tab) of browser which parameters are sent to Routing isoline service and check the response.
It seems are you using Routing API v7.2 then please play with playground on https://refclient.ext.here.com/ - click there on "New Tab +"
Better solution if you switch to new version 8 of Routing API and use this service which direct integrated to JS API: https://developer.here.com/documentation/maps/3.1.30.7/api_reference/H.service.RoutingService8.html#calculateIsoline
Example:
let routingParams = {
'routingMode': 'fast',
'transportMode': 'car',
'origin':'52.5,13.4',
'range[type]': 'time',
'range[values]': '900',
};
// Define a callback function to process the routing response
let onResult = function(result) {
if (result.isolines.length) {
result.isolines[0].polygons.forEach((polygon) => {
// Create a linestring to use as a point source for the isoline
const linestring = H.geo.LineString.fromFlexiblePolyline(polygon.outer);
// Create a polygon and a marker representing the isoline
const isolinePolygon = new H.map.Polygon(linestring, {
style: { strokeColor: 'blue', lineWidth: 3 }
});
// Create a marker for the start point
const isolineCenter = new H.map.Marker(result.departure.place.location);
// Add the polygon and marker to the map
map.addObjects([isolinePolygon, isolineCenter]);
// Center and zoom the map so that the whole isoline polygon is
// in the viewport
map.getViewModel().setLookAtData({bounds: isolinePolygon.getBoundingBox()});
});
}
};
// Assumption: the platform is instantiated.
// Get an instance of the routing service
let router = platform.getRoutingService(null, 8);
// Call the Isoline Routing API to calculate an isoline
router.calculateIsoline(
routingParams,
onResult,
console.error
);
Playground for v8: https://demo.routing.ext.here.com/