Exemplo n.º 1
0
        public void DrawRouteToPlace(Route route, Place place)
        {
            if (MyLocation == null)
            {
                return;
            }

            map.Clear();

            string snippet = route.legs[0].distance.text +
                             ", " + route.legs[0].duration.text;

            var marker = new MarkerOptions();

            marker.SetTitle(place.name);
            marker.SetSnippet(snippet);
            marker.SetPosition(new LatLng(place.geometry.location.lat, place.geometry.location.lng));
            map.AddMarker(marker);

            var polyline = new PolylineOptions();

            polyline.InvokeColor(ContextCompat.GetColor(Activity.ApplicationContext, Resource.Color.route_polyline));
            var points = RouteHelper.GetPointsFromRoute(route);

            foreach (var point in points)
            {
                polyline.Add(new LatLng(point.lat, point.lng));
            }

            map.AddPolyline(polyline);

            UpdateCameraPosition(new LatLng(MyLocation.lat, MyLocation.lng));
        }