TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed elbarbary
NA
1.6k
278.4k
How to display more than locaions gps on googlemap?
Dec 30 2019 6:18 AM
I have foreach loop it loop to all locations and get gps location latitude and longtude of GPS1 and display it on google map
I need to collect all latitude and longtude from foreach loop then pass it to function LatLng
const coordinates = new google.maps.LatLng(values of lat , values of lng);
this
.partDetailsService.getLocationData(locationArr).subscribe(res => {
console.log(res);
res.forEach((item, index) => {
let dataLocation = res[index][
'_source'
][
'GPS1'
];
console.log(dataLocation);
let loc = dataLocation.split(
','
);
console.log(
"After"
);
console.log(loc);
//show latitude,longtude separated comma
console.log(loc[0].trim());
//show latitude
console.log(loc[1].trim());
//show Longtude
});
//=======================================================
How to pass values of loc[0].trim() and loc[1].trim() result of foreach loop
const
coordinates =
new
google.maps.LatLng(collection of lat result of foreach loop, collection of lng result of foreach loop);
const
mapOptions: google.maps.MapOptions = {
center: coordinates,
zoom: 8
};
const
marker =
new
google.maps.Marker({
position: coordinates,
title:
'Hello World!'
});
const
map =
new
google.maps.Map(
this
.gmap.nativeElement, mapOptions);
marker.setMap(map);
}
);
//=================================
}
onManagelocations.component.html
<div #mapContainer id=
"map"
></div>
Reply
Answers (
1
)
How to store value of latitude and longtude on two variables
how to get values of latitude and longtude on two variables