GeoJson FeatureCollection field summary not accessible, indexing not working

45 Views Asked by At

In my Angular Application, I get some GeoJSON as type FeatureCollection from OpenrouteService.

Inside my ts file, I just assign the response from OpenrouteService so some variable:

import { FeatureCollection } from 'geojson';
...
routeJson: FeatureCollection | undefined;

If you look at the response type on their side, the following should work: this.routeJson.features[0].properties.summary.distance But when I try this, I get the error: “Unresolved variable summary”

Instead, the following works:

<aside *ngIf="routeJson">
  <div>
     {{this.routeJson.features[0].properties!['summary'].distance}}
  </div>
</aside>

Why is my initial approach not working? Do I get something wrong here?

0

There are 0 best solutions below