dapriett / nativescript-google-maps-sdk

Cross Platform Google Maps SDK for Nativescript
MIT License
244 stars 164 forks source link

How to draw polyline between two points using nativescript-google-maps-sdk #312

Open arunkumart07 opened 5 years ago

arunkumart07 commented 5 years ago

I have set of lat and lng point that is received from google direction api. Now i want to draw polylines between those points. Can anyone help me to draw polyline.

tylerablake commented 5 years ago

Hi,

This is how I did it inside of the onMapReady function:

onMapReady = (event) => { const mapView = event.object; const polyline = new mapsModule.Polyline(); polyline.addPoint(mapsModule.Position.positionFromLatLng(someLatitude, someLongitude)); polyline.addPoint(mapsModule.Position.positionFromLatLng(someOtherLatitude, someOtherLongitude)); polyline.visible = true; polyline.width = 2; polyline.geodesic = false; polyline.color = new Color("#DD00b3fd"); mapView.addPolyline(polyline);

Let me know if you have any issues. Hope this isn't too late!

thukuwanjiku commented 5 years ago

Thanks alot @tylerablake I had been looking for this.