Ejemplo n.º 1
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CreateJourney);

            #region setup map markers
            currentLocation = new MarkerOptions();
            currentLocation.SetTitle("Current Position");
            currentLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));
            currentLocation.SetPosition(getCurrentPosition());
            currentLocation.Visible(false);

            fromLocation = new MarkerOptions();
            fromLocation.SetTitle("From Here");
            fromLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
            fromLocation.SetPosition(getCurrentPosition());
            fromLocation.Visible(false);

            toLocation = new MarkerOptions();
            toLocation.SetTitle("To Here");
            toLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
            toLocation.SetPosition(getCurrentPosition());
            toLocation.Visible(false);

            #endregion

            // Create your application here
            InitMapFragment();
            SetupCurrentLocationButton();
            SetupSetLocationButton();
            SetupSetFromButton();
            SetupSetToButton();
            SetupForm();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// initializes the <see cref="MarkerOptions"/>
        /// </summary>
        /// <param name="markerOptions">Instance of the marker options</param>
        /// <param name="setPosition">if <value>true</value>, the position will be updated</param>
        /// <returns><see cref="Task"/></returns>
        public async Task InitializeMarkerOptionsAsync(MarkerOptions markerOptions, bool setPosition = true)
        {
            if (setPosition)
            {
                markerOptions.SetPosition(new LatLng(Pin.Position.Latitude, Pin.Position.Longitude));
            }

            if (!string.IsNullOrWhiteSpace(Pin.Title))
            {
                markerOptions.SetTitle(Pin.Title);
            }
            if (!string.IsNullOrWhiteSpace(Pin.Subtitle))
            {
                markerOptions.SetSnippet(Pin.Subtitle);
            }

            await UpdateImageAsync(markerOptions);

            markerOptions.Draggable(Pin.IsDraggable);
            markerOptions.Visible(Pin.IsVisible);
            markerOptions.SetRotation((float)Pin.Rotation);
            if (Pin.Image != null)
            {
                markerOptions.Anchor((float)Pin.Anchor.X, (float)Pin.Anchor.Y);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a marker to the map
        /// </summary>
        /// <param name="pin">The Forms Pin</param>
        private async void AddPin(TKCustomMapPin pin)
        {
            pin.PropertyChanged += OnPinPropertyChanged;

            var markerWithIcon = new MarkerOptions();

            markerWithIcon.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));

            if (!string.IsNullOrWhiteSpace(pin.Title))
            {
                markerWithIcon.SetTitle(pin.Title);
            }
            if (!string.IsNullOrWhiteSpace(pin.Subtitle))
            {
                markerWithIcon.SetSnippet(pin.Subtitle);
            }

            await this.UpdateImage(pin, markerWithIcon);

            markerWithIcon.Draggable(pin.IsDraggable);
            markerWithIcon.Visible(pin.IsVisible);
            if (pin.Image != null)
            {
                markerWithIcon.Anchor((float)pin.Anchor.X, (float)pin.Anchor.Y);
            }

            this._markers.Add(pin, this._googleMap.AddMarker(markerWithIcon));
        }
Ejemplo n.º 4
0
        public void OnMapClick(LatLng point)
        {
            Toast.MakeText(null, point.ToString(), ToastLength.Long);
            var marcador = new MarkerOptions().SetPosition(point).SetTitle("ponto");

            _map.AddMarker(marcador);
            marcador.Visible(true);
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SearchJourney);

            #region setup map markers
            currentLocation = new MarkerOptions();
            currentLocation.SetTitle("Current Position");
            currentLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));
            currentLocation.SetPosition(getCurrentPosition());
            currentLocation.Visible(false);

            fromLocation = new MarkerOptions();
            fromLocation.SetTitle("From Here");
            fromLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
            fromLocation.SetPosition(getCurrentPosition());
            fromLocation.Visible(false);

            toLocation = new MarkerOptions();
            toLocation.SetTitle("To Here");
            toLocation.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
            toLocation.SetPosition(getCurrentPosition());
            toLocation.Visible(false);

            fromCircleOp = new CircleOptions();
            fromCircleOp.InvokeCenter(getCurrentPosition());
            fromCircleOp.InvokeRadius(1000);
            fromCircleOp.InvokeFillColor(0X66FF0000);
            fromCircleOp.InvokeStrokeColor(0X66FF0000);
            fromCircleOp.InvokeStrokeWidth(0);
            fromCircleOp.Visible(false);


            toCircleOp = new CircleOptions();
            toCircleOp.InvokeCenter(getCurrentPosition());
            toCircleOp.InvokeRadius(1000);
            toCircleOp.InvokeFillColor(Color.Green);
            toCircleOp.InvokeStrokeColor(Color.Green);
            toCircleOp.InvokeStrokeWidth(0);
            toCircleOp.Visible(false);
            #endregion

            // Create your application here
            InitMapFragment();
            SetupCurrentLocationButton();
            SetupSearchButton();
            SetupSetFromButton();
            SetupSetToButton();
            SetupForm();
        }
Ejemplo n.º 6
0
        private void SetupSetToButton()
        {
            Button animateButton = FindViewById <Button>(Resource.Id.buttonSetTo);

            animateButton.Click += (sender, e) => {
                toLocation.SetPosition(_map.CameraPosition.Target);
                toLocation.Visible(true);
                if (toMarker != null)
                {
                    toMarker.Remove();
                }
                toMarker = _map.AddMarker(toLocation);
            };
        }
        //geolocation
        private void InitCurrentPositionMarker()
        {
            MarkerOptions    options = new MarkerOptions();
            BitmapDescriptor icon    = BitmapDescriptorFactory.FromResource(Resource.Drawable.carrier_marker);

            options.SetIcon(icon);

            options.SetPosition(this.map.CameraPosition.Target);
            options.SetTitle("Twoja pozycja");
            options.Visible(false);

            this.mCurrentPosition     = map.AddMarker(options);
            this.mCurrentPosition.Tag = new MarkerTag {
                Type = MarkerType.CurrentPosition
            };

            UpdateCurrentPosition();
        }
Ejemplo n.º 8
0
        public void OnMapClick(LatLng point)
        {
            //Drawable vectorDrawable = Resources.GetDrawable(Resource.Drawable.Icon);
            //vectorDrawable.SetBounds(0, 0, 32, 32);
            //Bitmap bm = Bitmap.CreateBitmap(32, 32, Bitmap.Config.Argb8888);
            //Canvas canvas = new Canvas(bm);
            //vectorDrawable.Draw(canvas);
            //var dec = BitmapDescriptorFactory.FromBitmap(bm);

            var marker = new MarkerOptions();

            marker.SetTitle("Oooh");
            //marker.SetIcon(dec);
            marker.SetPosition(new LatLng(point.Latitude - 0.01, point.Longitude - 0.01));
            marker.SetSnippet("blaaa blaa heel veel tekst");
            marker.Visible(true);
            _map.AddMarker(marker);
        }
Ejemplo n.º 9
0
        private void SetupCurrentLocationButton()
        {
            Button currentLocationButton = FindViewById <Button>(Resource.Id.buttonFindMe);

            currentLocationButton.Click += (sender, e) => {
                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(getCurrentPosition());
                builder.Zoom(18);
                builder.Bearing(155);
                CameraPosition cameraPosition = builder.Build();

                // AnimateCamera provides a smooth, animation effect while moving
                // the camera to the the position.
                currentLocation.SetPosition(getCurrentPosition());
                currentLocation.Visible(true);
                _map.AddMarker(currentLocation);
                _map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition));
            };
        }
Ejemplo n.º 10
0
        private void SetupSetToButton()
        {
            Button animateButton = FindViewById <Button>(Resource.Id.buttonSearchJourneySetTo);

            animateButton.Click += (sender, e) => {
                toLocation.SetPosition(_map.CameraPosition.Target);
                toLocation.Visible(true);
                if (toMarker != null)
                {
                    toMarker.Remove();
                }
                toMarker = _map.AddMarker(toLocation);
                toCircleOp.InvokeCenter(_map.CameraPosition.Target);
                toCircleOp.InvokeRadius(rangeFinder.Progress * 500);
                toCircleOp.Visible(true);
                if (toCircle != null)
                {
                    toCircle.Remove();
                }
                toCircle = _map.AddCircle(toCircleOp);
            };
        }
Ejemplo n.º 11
0
        public void pinplacer(GoogleMap map, string name, Double Lat, Double Long, string type)
        {
            MarkerOptions markerOpt1 = new MarkerOptions();

            markerOpt1.SetPosition(new LatLng(Lat, Long));
            markerOpt1.SetTitle(name);
            if (name == "Water Hazard")
            {
                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure);
                markerOpt1.SetIcon(bmDescriptor);
            }
            else if (name == "Fire Hazard")
            {
                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed);
                markerOpt1.SetIcon(bmDescriptor);
            }
            else if (name == "Debris Hazard")
            {
                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow);
                markerOpt1.SetIcon(bmDescriptor);
            }
            else if (name == "Closed Road")
            {
                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueOrange);
                markerOpt1.SetIcon(bmDescriptor);
            }
            else
            {
                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen);
                markerOpt1.SetIcon(bmDescriptor);
            }

            markerOpt1.Visible(true);
            markerOpt1.Draggable(false);

            map.AddMarker(markerOpt1);
        }
Ejemplo n.º 12
0
        public void DrawTripOnMap(string json)
        {
            var directionData = JsonConvert.DeserializeObject <DirectionParser>(json);

            //Decode Encoded Route
            var points = directionData.routes[0].overview_polyline.points;
            var line   = PolyUtil.Decode(points);

            ArrayList routeList = new ArrayList();

            foreach (LatLng item in line)
            {
                routeList.Add(item);
            }
            //double distance = 0;
            //Xamarin.Essentials.Location source;
            //Xamarin.Essentials.Location dest;
            //for(int i=0; i<line.Count-1; i++)
            //{
            //    source = new Xamarin.Essentials.Location(line[i].Latitude, line[i].Longitude);
            //    dest = new Xamarin.Essentials.Location(line[i + 1].Latitude, line[i + 1].Longitude);
            //    distance += source.CalculateDistance(dest, DistanceUnits.Kilometers);
            //    routeList.Add(line[i]);
            //    if (i == line.Count - 2)
            //        routeList.Add(line[i + 1]);
            //}

            //Draw Polylines on Map
            PolylineOptions polylineOptions = new PolylineOptions()
                                              .AddAll(routeList)
                                              .InvokeWidth(10)
                                              .InvokeColor(Color.Teal)
                                              .InvokeStartCap(new SquareCap())
                                              .InvokeEndCap(new SquareCap())
                                              .InvokeJointType(JointType.Round)
                                              .Geodesic(true);

            Android.Gms.Maps.Model.Polyline mPolyline = map.AddPolyline(polylineOptions);

            //Get first point and lastpoint
            LatLng firstpoint = line[0];
            LatLng lastpoint  = line[line.Count - 1];

            //Pickup marker options
            MarkerOptions pickupMarkerOptions = new MarkerOptions();

            pickupMarkerOptions.SetPosition(firstpoint);
            pickupMarkerOptions.SetTitle("Pickup Location");
            pickupMarkerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));

            //Destination marker options
            MarkerOptions destinationMarkerOptions = new MarkerOptions();

            destinationMarkerOptions.SetPosition(lastpoint);
            destinationMarkerOptions.SetTitle("Destination");
            destinationMarkerOptions.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));


            MarkerOptions driverMarkerOptions = new MarkerOptions();

            driverMarkerOptions.SetPosition(firstpoint);
            driverMarkerOptions.SetTitle("Current Location");
            driverMarkerOptions.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.position));
            driverMarkerOptions.Visible(false);


            pickupMarker = map.AddMarker(pickupMarkerOptions);
            Marker destinationMarker = map.AddMarker(destinationMarkerOptions);

            driverLocationMarker = map.AddMarker(driverMarkerOptions);

            //Get Trip Bounds
            double southlng = directionData.routes[0].bounds.southwest.lng;
            double southlat = directionData.routes[0].bounds.southwest.lat;
            double northlng = directionData.routes[0].bounds.northeast.lng;
            double northlat = directionData.routes[0].bounds.northeast.lat;

            LatLng       southwest = new LatLng(southlat, southlng);
            LatLng       northeast = new LatLng(northlat, northlng);
            LatLngBounds tripBound = new LatLngBounds(southwest, northeast);

            map.AnimateCamera(CameraUpdateFactory.NewLatLngBounds(tripBound, 100));
            map.SetPadding(40, 40, 40, 40);
            pickupMarker.ShowInfoWindow();

            duration       = directionData.routes[0].legs[0].duration.value;
            distance       = directionData.routes[0].legs[0].distance.value;
            durationstring = directionData.routes[0].legs[0].duration.text;
            distanceString = directionData.routes[0].legs[0].distance.text;
        }
Ejemplo n.º 13
0
        public void OnMapReady(GoogleMap map)
        {
            pinproccessor(map);
            map.MyLocationEnabled = true;
            map.MyLocationChange += (latitude, longitude) =>
            {
                var latitude1  = latitude;
                var longitude1 = longitude;
            };

            map.MoveCamera(
                CameraUpdateFactory.NewLatLng(
                    new LatLng(39.8283, -98.5795)));
            map.AnimateCamera(
                CameraUpdateFactory.ZoomTo(3));

            Button button = FindViewById <Button>(Resource.Id.button);

            Button button2 = FindViewById <Button>(Resource.Id.button_2);

            button2.Visibility = ViewStates.Invisible;

            Button button3 = FindViewById <Button>(Resource.Id.button_3);

            button3.Visibility = ViewStates.Invisible;

            Button button4 = FindViewById <Button>(Resource.Id.button_4);

            button4.Visibility = ViewStates.Invisible;

            Button button5 = FindViewById <Button>(Resource.Id.button_5);

            button5.Visibility = ViewStates.Invisible;

            Button button6 = FindViewById <Button>(Resource.Id.safehouse);

            EditText supplies = FindViewById <EditText>(Resource.Id.supplies);

            supplies.Visibility = ViewStates.Invisible;

            TextView supplies_text = FindViewById <TextView>(Resource.Id.supplies_text);

            supplies_text.Visibility = ViewStates.Invisible;

            TextView pins = FindViewById <TextView>(Resource.Id.pins);

            TextView water = FindViewById <TextView>(Resource.Id.water);

            water.Visibility = ViewStates.Invisible;

            TextView fire = FindViewById <TextView>(Resource.Id.fire);

            fire.Visibility = ViewStates.Invisible;

            TextView debris = FindViewById <TextView>(Resource.Id.debris);

            debris.Visibility = ViewStates.Invisible;

            TextView road = FindViewById <TextView>(Resource.Id.road);

            road.Visibility = ViewStates.Invisible;


            button.Click += (o, e) =>
            {
                if (pins.Visibility == ViewStates.Invisible)
                {
                    pins.Visibility = ViewStates.Visible;
                }

                else
                {
                    pins.Visibility = ViewStates.Invisible;
                }

                if (button2.Visibility == ViewStates.Invisible)
                {
                    button2.Visibility = ViewStates.Visible;
                }

                else
                {
                    button2.Visibility = ViewStates.Invisible;
                }

                if (water.Visibility == ViewStates.Invisible)
                {
                    water.Visibility = ViewStates.Visible;
                }

                else
                {
                    water.Visibility = ViewStates.Invisible;
                }

                if (fire.Visibility == ViewStates.Invisible)
                {
                    fire.Visibility = ViewStates.Visible;
                }

                else
                {
                    fire.Visibility = ViewStates.Invisible;
                }

                if (button3.Visibility == ViewStates.Invisible)
                {
                    button3.Visibility = ViewStates.Visible;
                }

                else
                {
                    button3.Visibility = ViewStates.Invisible;
                }

                if (debris.Visibility == ViewStates.Invisible)
                {
                    debris.Visibility = ViewStates.Visible;
                }

                else
                {
                    debris.Visibility = ViewStates.Invisible;
                }

                if (button4.Visibility == ViewStates.Invisible)
                {
                    button4.Visibility = ViewStates.Visible;
                }

                else
                {
                    button4.Visibility = ViewStates.Invisible;
                }

                if (road.Visibility == ViewStates.Invisible)
                {
                    road.Visibility = ViewStates.Visible;
                }

                else
                {
                    road.Visibility = ViewStates.Invisible;
                }

                if (button5.Visibility == ViewStates.Invisible)
                {
                    button5.Visibility = ViewStates.Visible;
                }

                else
                {
                    button5.Visibility = ViewStates.Invisible;
                }
            };


            var markerlist = new List <Marker>();


            button2.Click += (o, e) =>
            {
                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(latitude, longitude));
                Title = "Water Hazard";
                markerOpt1.SetTitle(Title);

                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueAzure);
                markerOpt1.SetIcon(bmDescriptor);
                markerOpt1.Visible(true);
                markerOpt1.Draggable(true);
                Marker newe = map.AddMarker(markerOpt1);
                markerlist.Append(newe);

                string email = Intent.GetStringExtra("email") ?? "0";
                string url   = "http://35.22.42.160:3000/pins?name=" + Title + "&lat=" + latitude + "&lon=" + longitude + "&type=water&email=" + email;

                FetchDBAsync(url, "GET");
            };

            button3.Click += (o, e) =>
            {
                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(latitude, longitude));
                Title = "Fire Hazard";
                markerOpt1.SetTitle(Title);

                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed);
                markerOpt1.SetIcon(bmDescriptor);
                markerOpt1.Visible(true);
                markerOpt1.Draggable(true);
                Marker newe = map.AddMarker(markerOpt1);
                markerlist.Append(newe);

                string email = Intent.GetStringExtra("email") ?? "0";
                string url   = "http://35.22.42.160:3000/pins?name=" + Title + "&lat=" + latitude + "&lon=" + longitude + "&type=fire&email=" + email;

                FetchDBAsync(url, "GET");
                Console.Out.Write(markerlist.ToString());
            };

            button4.Click += (o, e) =>
            {
                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(latitude, longitude));
                Title = "Debris Hazard";
                markerOpt1.SetTitle(Title);

                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow);
                markerOpt1.SetIcon(bmDescriptor);
                markerOpt1.Visible(true);
                markerOpt1.Draggable(true);
                Marker newe = map.AddMarker(markerOpt1);
                markerlist.Append(newe);

                string email = Intent.GetStringExtra("email") ?? "0";
                string url   = "http://35.22.42.160:3000/pins?name=" + Title + "&lat=" + latitude + "&lon=" + longitude + "&type=debris&email=" + email;

                FetchDBAsync(url, "GET");
            };

            button5.Click += (o, e) =>
            {
                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(latitude, longitude));
                Title = "Closed Road";
                markerOpt1.SetTitle(Title);

                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueOrange);
                markerOpt1.SetIcon(bmDescriptor);
                markerOpt1.Visible(true);
                markerOpt1.Draggable(true);
                Marker newe = map.AddMarker(markerOpt1);
                markerlist.Append(newe);

                string email = Intent.GetStringExtra("email") ?? "0";
                string url   = "http://35.22.42.160:3000/pins?name=" + Title + "&lat=" + latitude + "&lon=" + longitude + "&type=safehouse&email=" + email;

                FetchDBAsync(url, "GET");
            };

            button6.Click += (o, e) =>
            {
                //supplies.Visibility = ViewStates.Visible;
                //supplies_text.Visibility = ViewStates.Visible;
                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(latitude, longitude));
                Title = "Safe House";
                markerOpt1.SetTitle(Title);

                var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen);
                markerOpt1.SetIcon(bmDescriptor);
                markerOpt1.Visible(true);
                markerOpt1.Draggable(true);
                Marker newe = map.AddMarker(markerOpt1);
                markerlist.Append(newe);

                string email = Intent.GetStringExtra("email") ?? "0";
                string url   = "http://35.22.42.160:3000/pins?name=" + Title + "&lat=" + latitude + "&lon=" + longitude + "&type=safehouse&email=" + email;

                FetchDBAsync(url, "GET");
            };
        }
Ejemplo n.º 14
0
        public void DrawPolylineOnMap(string json, GoogleMap mainMap)
        {
            Android.Gms.Maps.Model.Polyline mPolyLine;

            var directionData = JsonConvert.DeserializeObject <DirectionParser>(json);

            string durationString = directionData.routes[0].legs[0].duration.text;
            string distanceString = directionData.routes[0].legs[0].distance.text;

            var polylineCode = directionData.routes[0].overview_polyline.points;
            var line         = PolyUtil.Decode(polylineCode);

            LatLng    firstpoint = line[0];
            LatLng    lastpoint  = line[line.Count - 1];
            ArrayList routeList  = new ArrayList();

            int locationCount = 0;

            foreach (LatLng item in line)
            {
                routeList.Add(item);
                locationCount++;

                Console.WriteLine("Poistion " + locationCount.ToString() + " = " + item.Latitude + "," + item.Longitude.ToString());
            }

            PolylineOptions polylineOptions = new PolylineOptions()
                                              .AddAll(routeList)
                                              .InvokeWidth(10)
                                              .InvokeColor(Color.Teal)
                                              .Geodesic(true)
                                              .InvokeJointType(JointType.Round);

            mPolyLine = mainMap.AddPolyline(polylineOptions);

            // Location Marker
            MarkerOptions locationMarkerOption = new MarkerOptions();

            locationMarkerOption.SetPosition(firstpoint);
            locationMarkerOption.SetTitle("My Location");
            locationMarkerOption.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen));
            Marker locationmarker = mainMap.AddMarker(locationMarkerOption);

            // Destination Marker
            MarkerOptions destinationMarkerOption = new MarkerOptions();

            destinationMarkerOption.SetPosition(lastpoint);
            destinationMarkerOption.SetTitle("Destination");
            destinationMarkerOption.SetSnippet(durationString + ", " + distanceString);
            destinationMarkerOption.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
            Marker destinationMarker = mainMap.AddMarker(destinationMarkerOption);

            // Current Location Marker
            MarkerOptions positionMakerOption = new MarkerOptions();

            positionMakerOption.SetPosition(firstpoint);
            positionMakerOption.SetTitle("Current Location");
            positionMakerOption.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.positionmarker));
            positionMakerOption.Visible(false);
            currentPositionMarker = mainMap.AddMarker(positionMakerOption);

            // Location Circle
            CircleOptions locationCircleOption = new CircleOptions();

            locationCircleOption.InvokeCenter(firstpoint);
            locationCircleOption.InvokeRadius(30);
            locationCircleOption.InvokeStrokeColor(Color.Teal);
            locationCircleOption.InvokeFillColor(Color.Teal);
            mainMap.AddCircle(locationCircleOption);

            // Destination Circle
            CircleOptions destiationCircleOption = new CircleOptions();

            destiationCircleOption.InvokeCenter(lastpoint);
            destiationCircleOption.InvokeRadius(30);
            destiationCircleOption.InvokeStrokeColor(Color.Teal);
            destiationCircleOption.InvokeFillColor(Color.Teal);
            mainMap.AddCircle(destiationCircleOption);

            LatLng southwest = new LatLng(directionData.routes[0].bounds.southwest.lat, directionData.routes[0].bounds.southwest.lng);
            LatLng northeast = new LatLng(directionData.routes[0].bounds.northeast.lat, directionData.routes[0].bounds.northeast.lng);

            LatLngBounds tripBounds = new LatLngBounds(southwest, northeast);

            mainMap.AnimateCamera(CameraUpdateFactory.NewLatLngBounds(tripBounds, 150));
            mainMap.UiSettings.ZoomControlsEnabled = true;
            destinationMarker.ShowInfoWindow();
        }