Skip to content

Commit

Permalink
added zoom functionality for route extension
Browse files Browse the repository at this point in the history
	- will, by default zoom to the bounds of the calculated route
	- can be disabled via options (bool)zoomTo
  • Loading branch information
axeffwettercom committed Feb 28, 2014
1 parent 5353ec2 commit 873915f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions EXTENSIONS.md
Expand Up @@ -51,6 +51,7 @@ or an array
trafficMode: 'default', //can be enabled, disabled, default
width: 4, //width in px of the route drawn on the map
color: '#ff6347', //color of the route drawn on the map
zoomTo: false, //will disable zooming to bounds of calculated route
onroute: function(route){} //optional callbacks that gets the list of maneuvers with some
//basic info, plus total time (seconds) and length (meters)
}
Expand Down
7 changes: 6 additions & 1 deletion src/extensions/route.js
Expand Up @@ -31,7 +31,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
marker: {
text: '#',
textColor: '#fff'
}
},
zoomTo: true
};

function normalize(position){
Expand Down Expand Up @@ -100,6 +101,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
this.marker(w.originalPosition, o);
}, this));
this.map.objects.add(routeContainer);
/*Zoom map to bounds of route*/
if(options.zoomTo){
this.map.zoomTo(routeContainer.getBoundingBox(), false, "default");
}
/*Now let's look into the route infos*/
leg = r.legs && r.legs.length && r.legs[0];
info.time = leg.travelTime;
Expand Down

0 comments on commit 873915f

Please sign in to comment.