Nativescript-directions

plugins

#1

Hello,
In android while using Nativescript-directions plugin to add path between two points it opens Google Maps instead of my Nativescript application.How i can fix this??

Following is my typescript code:

directions.navigate({
from: {
lat: 52.215987,
lng: 5.282764
},
to: [{
address: “Hof der Kolommen 34, Amersfoort, Netherlands”,
},
{
address: “Aak 98, Wieringerwerf, Netherlands”
}]
}).then(() => {
console.log(“Success.”);
}, error => {
console.log(error);
});


#2

I think you want to use nativescript google maps sdk plugin instead.

The purpose of nativescript directions plugin is to open the naitve maps app and show directions.


#3

Hello @multishiv19 ,
I used nativescript-google-maps-sdk. It is showing me google map and also allowing me to add marker on specific lat long. But i am not getting how to draw route between two points(Lat long) using this plugin.
Do you have any solution?


#4

I would suggest to read about it in google docs. There is a way to draw lines. You might have to use the native API to do that separately for android and ios. Not sure if the plugin exposes any common api to do it.


#6

@multishiv19
As per instructions while creating API Key i am using Google Maps Android API.

import { MapView, Marker, Polyline, Position } from ‘nativescript-google-maps-sdk’;
Do i need to import anything else than nativescript-google-maps-sdk??


#7

@komal2694 You have to draw a Polyline but not just with source and destination lat / long if you want to show the directions. You will have to first use the directions api to get the points between source and destination (with extra params like driving mode etc.,) then use those points to draw Polyline.


Create route in nativescript2
#8

I have a similar problem -
I’m trying to turn to the Google directions service to get the time it takes to move between two points, and I do not know what to do in native script.
can you help me?


#9

You got to do nothing special for NativeScript. All you need is to hit the directions rest api to get points between source and destination, then draw lines using those points (Refer nativescript-google-maps-sdk plugin docs to know how you can draw lines).