I have a list of random latitude and longitude points and I am drawing a route between them. My question is how to bound this route within google map I made below utili
Probably This would be most simple solution for above mentioned problem, It worked for me very well.
Add all the waypoints to the target under GoogleMapOptions:camera, then it will automatically set the zoom and center the map with respect to Polyline( given Route).
loadMap() {
let mapOptions: GoogleMapOptions = {
camera: {
target: this.wayPoints,
zoom: 25,
tilt: 30
}
};
this.map = GoogleMaps.create('map_canvas', mapOptions);
this.map.one(GoogleMapsEvent.MAP_READY)
.then(() => {
console.log('Map is ready!');
this.map.addPolyline({
points:this.wayPoints,
color:'#586bff',
width: 8,
geodesic:true,
});
});
}
The waypoints( this.wayPoints ) should be in this format:
[{lat: 52.33806, lng: 8.61179},
{lat: 52.33812, lng: 8.61185},
{lat: 52.33812, lng: 8.61186},
{lat: 52.33812, lng: 8.61188}]