NativeScript Directions plugin
From the command prompt go to your app's root folder and execute:
tns plugin add nativescript-directions
Demo app (XML + TypeScript)
Want to dive in quickly? Check out the demo app! Otherwise, continue reading.
You can run the demo app from the root of the project by typing
npm run demo.ios.device or
npm run demo.android.
Demo app (Angular)
This plugin is part of the plugin showcase app I built using Angular.
Not all devices have the Google (Android) or Apple (iOS) Maps app installed. Well, most do of course, but on an Android simulator you may be out of luck, so let's check beforehand:
// require the pluginvar Directions = Directions;// instantiate the pluginvar directions = ;directions;
// require the plugin;// instantiate the plugin;directions.available.then;
This function opens the native Maps app with a predefined
If you don't pass
from the current location of the user will be used.
address is specified then
lng will be ignored.
If you pass in an Array of
to addresses, then the last item is the destination, the others become 'waypoints'.
Note that if there's an ocean in between
to you won't be able to get directions, don't blame this plugin for that 😁
- Perhaps add Android-specific options like opening the map in StreetView mode, or pre-defining the transportation type (walk/bike/car).