Over the past three months I’ve had the privilege of working as an intern on the Google Maps API team here in Sydney. In that time, I’ve had the opportunity to implement draggable directions in the Maps API v3 - a feature highly sought after by developers. It has been a joy to watch this project grow from design musings to a launched feature.
Draggable directions allow a user to modify the route suggested by the Maps API to suit their tastes, for example to avoid traffic, or to modify stop overs on a long road trip. If you haven’t had a chance to play with draggable directions, I’d encourage you to try it below. The API implementation closely follows that on Google Maps; existing markers can be dragged around the map, and moving your mouse near the path allows you to click and drag a new point.
The API makes it easy to turn an ordinary directions path into a draggable route. The DirectionsRenderer now has a draggable option, which when true causes paths to be draggable when rendered. Paths are not draggable by default, so existing v3 applications will remain unchanged. API developers can be notified of changes to a path by listening to the directions_changed event on a DirectionsRenderer. This makes it easy to implement additional features like the Undo button above. For more information, check out the Documentation.
draggable
directions_changed
We hope that you and your users enjoy experimenting with draggable directions as much as I enjoyed implementing them. I’d encourage you to start creating your own applications with draggable directions; when you’re done, post a link to your experiments in the Maps API v3 Google Group. We’ll keep an eye out for the most fun and innovative ideas, and add them to our Demo Gallery.
Once again, I’d like to thank the Google Maps API team for all their help, from getting this project off the ground, to making an American intern feel at home in a new country.
Posted by Izaak Rubin, Maps API team
Give us feedback in our Product Forums.