fetchAllRiders(){
this.http.get( this.API + '/driver/all').map( res => res.json())
.subscribe( data => data.map( rider =>{
var distances = [];
this.geocoder.geocode({location: {lat: rider.driver_lat, lng: rider.driver_lng}}, async function(results, status){
if( status == google.maps.GeocoderStatus.OK){
//then find distance matrix of each rider
this.distanceMatrixService.getDistanceMatrix({
origins: [this.from],
destinations: [results[0].formatted_address],
travelMode: google.maps.TravelMode.DRIVING
}, async function(response, status ){
if( status == google.maps.GeocoderStatus.OK){
await distances.push(response.rows[0].elements[0].distance.text );
}
} )
console.log( distances );
}
})
} )
//looping ends
);
}
but i keep getting errors :
this.distanceMatrixService is undefined meanwhile its defined in my constructor.
please what am i doing wrong. thanks