Thursday, 12 September 2013

Center Map based on Route

Center Map based on Route

How do I center the Google Map based on the center-point of the route,
without using fitbounds? Is it possible to use map.setCenter? I have
commented out the line that I need I need help with.
google.maps.event.addListener(dr, 'directions_changed', function() {
var route = dr.getDirections().routes[0];
var path = route.overview_path;
es.getElevationAlongPath({
path: path,
samples: Math.max(50, path.length * 2)
}, function(result, status) {
if (status == google.maps.ElevationStatus.OK) {
drawElevation(result);
recalcHeight();
if (fitBounds) {
map.setZoom(route.bounds);
//map.setCenter();
fitBounds = false;
}
}
else {
$('#error').text(status).show();
}
recalcHeight();
});
});

No comments:

Post a Comment