in the below posted code i would like to loop through the contents of the array
features[0]["values_"]["geometry"]["flatCoordinates"]
for all the console statements that are outside the for-loop, they gets printed and they contain data.however, when i run the App, i receive the following error
ERROR TypeError: Cannot set property '0' of undefined
to solve this issue i commented out the first two lines inside the for-loop, and the values of the variable 'i' gets printed. only when i acrivate the first two lines inside the loop the error message is received. please let me know how to fix this error
code:
private renderSelectedSite(){
var features = (new GeoJSON()).readFeatures(this.selectedSite.geometry);
console.log("this.selectedSite.geometry: ",this.selectedSite.geometry)
console.log("features ",features)
console.log("features ",features[0]["values_"]["geometry"]["flatCoordinates"])
console.log("features ",features[0]["values_"]["geometry"]["flatCoordinates"].length)//84
console.log("features ",features[0]["values_"]["geometry"]["flatCoordinates"][0])//736437.816446109
var points: any[];
for (var i = 0; i < features[0]["values_"]["geometry"]["flatCoordinates"].length; i++) {
var e = features[0]["values_"]["geometry"]["flatCoordinates"][i];
points[i] = transform(e,'EPSG:4326','EPSG:3857');
console.log("points[i] ",i)
}