This query is an extension of a previous one, regarding data in the ngOnInit section which differs from the markers object.
Data fetched from http get in my data.service.ts is being appended to:
items:any = [];
ngOnInit() {
this.dataService.fetchData(this.slug)
.subscribe(
(data) => {
this.checkData(data);//this function will append the data to this.items
}
);
}
checkData(data) {
if (data.length === 0) {
return this.router.navigate(['']);
}
return this.items = data;
}
markers =[
{
lat: 51.673858,
lng: 7.815982
},
{
lat: 51.373858,
lng: 7.215982
},
{
lat: 51.723858,
lng: 7.895982
}
]
How can I replace the existing markers object with my this.items object (which contains lat and lng)?
https://i.sstatic.net/VKQ8A.jpg
The answer provided by @Eric N was correct, converting the marker.latitude and marker.longitude to parseFloat().