Sat Nav Map Directions for PhoneGap

Maps with directions

Today I wrote a Cordova “Directions” Plugin to utilise native maps apps for “sat nav” style direction purposes (using latitude and longitude). You can view the source code here.

Install the plugin

1
$ cordova plugin add https://github.com/leecrossley/cordova-plugin-directions.git

That’s all the installation steps thanks to Cordova’s fantastic CLI and streamlined plugin architecture. You do not need to reference any JavaScript, the build command will add a directions object to your root automatically.

Get directions

After the deviceready event has been fired, pass latitude and longitude to the navigateTo function:

1
directions.navigateTo("51.50722", "-0.12750"); // latitude, longitude

That’s it! Really, it’s that simple. The Google maps app will open on Android and give directions from the device’s current location. Similarly, Bing maps will open on Windows Phone 8.

Platforms

I only needed support for Android and Windows Phone 8, it would be easy to add support for iOS too if anyone needs it. As usual, issues and pull requests on GitHub.

Note: I managed to write this entire post without making any one direction jokes.