Ejemplo n.º 1
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                NativeMap.Clear();
                NativeMap.InfoWindowClick += OnInfoWindowClick;
                NativeMap.SetInfoWindowAdapter(this);

                foreach (var pin in customPins)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                    marker.SetTitle(pin.Pin.Label);
                    marker.SetSnippet(pin.Pin.Address);
                    //marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));

                    NativeMap.AddMarker(marker);
                }
                isDrawn = true;
            }
        }
Ejemplo n.º 2
0
        private void DrawGrid()
        {
            System.Diagnostics.Debug.Write("@@@@@ DrawGrid");

            customMap.GenerateGrid();

            if (customMap.GridLines == null)
            {
                return;
            }

            //smaže vše na mapě
            NativeMap.Clear();

            RedrawLoggedPositions();
            //drawnPositionsIndices.Clear();

            foreach (GridLine line in customMap.GridLines)
            {
                PolylineOptions lineOptions = GetLine();

                lineOptions.Add(new LatLng(line.start.Latitude, line.start.Longitude));
                lineOptions.Add(new LatLng(line.end.Latitude, line.end.Longitude));

                NativeMap.AddPolyline(lineOptions);
            }

            CircleOptions gridCenterCircle = new CircleOptions();

            gridCenterCircle.InvokeCenter(new LatLng(customMap.activeLocation.Center.Latitude, customMap.activeLocation.Center.Longitude));
            gridCenterCircle.InvokeRadius(50);
            gridCenterCircle.InvokeFillColor(Android.Graphics.Color.DarkSlateBlue);
            gridCenterCircle.InvokeStrokeColor(0X66FF0000);
            gridCenterCircle.InvokeStrokeWidth(2);

            NativeMap.AddCircle(gridCenterCircle);
        }
Ejemplo n.º 3
0
        public void update()
        {
            try
            {
                NativeMap.Clear();


                var polylineOptions = new PolylineOptions();
                polylineOptions.InvokeColor(0x66FF0000);
                foreach (var pin in ((CustomMap)Element).CustomPins)
                {
                    BitmapDescriptor icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.pin);


                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                    marker.SetTitle(pin.Pin.Label);
                    marker.SetSnippet(pin.Pin.Address);
                    marker.SetIcon(icon);
                    if (pin.Id != "1")
                    {
                        MoveAble_Marker = NativeMap.AddMarker(marker);
                    }
                    else
                    {
                        NativeMap.AddMarker(marker);
                    }
                }
                //
                foreach (var position in ((CustomMap)Element).RouteCoordinates)
                {
                    polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }
                NativeMap.AddPolyline(polylineOptions);
            }
            catch { }
        }
Ejemplo n.º 4
0
        public void OnMarkerDragEnd(Marker marker)
        {
            LatLng dragPosition = marker.Position;
            double dragLat      = dragPosition.Latitude;
            double dragLong     = dragPosition.Longitude;
            // Log.i("info", "on drag end :" + dragLat + " dragLong :" + dragLong);

            // Toast.makeText(getApplicationContext(), "Marker Dragged..!", Toast.LENGTH_LONG).show();

            var marker2 = new MarkerOptions();

            marker2.SetPosition(new LatLng(dragLat, dragLong));
            marker2.SetTitle("New Point");
            // marker2.SetSnippet("New Address");
            marker2.SetSnippet("Latitude:" + dragLat + " Longitude:" + dragLong);
            marker2.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));
            marker2.Draggable(true);

            NativeMap.AddMarker(marker2);

            // NativeMap.Clear();
            var pin = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.Place,
                    Position = new Position(dragLat, dragLong),
                    Label    = "Xamarin San Francisco Office",
                    Address  = "394 Pacific Ave, San Francisco CA"
                },
                Id  = "Xamarin",
                Url = "http://xamarin.com/about/"
            };

            customPins.Add(pin);
        }
        private void OnUpdateHighlight()
        {
            var highlightableMap = (HighlightableMap)Element;

            if (highlightableMap == null || NativeMap == null)
            {
                return;
            }

            NativeMap.Clear();

            if (highlightableMap?.Highlight == null)
            {
                return;
            }

            var fillColor       = highlightableMap.Highlight.FillColor.ToAndroid().ToArgb();
            var strokeColor     = highlightableMap.Highlight.StrokeColor.ToAndroid().ToArgb();
            var strokeThickness = highlightableMap.Highlight.StrokeThickness;

            foreach (var polygon in highlightableMap.Highlight.Polygons)
            {
                var polygonOptions = new PolygonOptions();

                polygonOptions.InvokeFillColor(fillColor);
                polygonOptions.InvokeStrokeColor(strokeColor);
                polygonOptions.InvokeStrokeWidth(strokeThickness);

                foreach (var position in polygon.Positions)
                {
                    polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }

                NativeMap.AddPolygon(polygonOptions);
            }
        }
Ejemplo n.º 6
0
        protected override void OnMapReady(GoogleMap map)
        {
            var bottom = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 8, Resources.DisplayMetrics);
            var left   = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 8, Resources.DisplayMetrics);
            var right  = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 8, Resources.DisplayMetrics);
            var top    = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 48, Resources.DisplayMetrics);

            map.SetPadding(left, top, right, bottom);
            map.SetMapStyle(MapStyleOptions.LoadRawResourceStyle(Context, Resource.Raw.my_map_customization));
            map.InfoWindowClick += OnInfoWindowClick;
            map.SetInfoWindowAdapter(this);

//            var latLng = new LatLng(Communities.LagosLatitude, Communities.LagosLongitude);
//            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
//            builder.Target(latLng);
//            builder.Zoom(15);
//            CameraPosition cameraPosition = builder.Build();
//            CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);
//            map.MoveCamera(cameraUpdate);

            base.OnMapReady(map);
            MapReady?.Invoke(this);
            LocationAccessChanged(MainActivity.IsLocationAccessGranted);
            LocationSettingsChanged(MainActivity.IsLocationEnabled);
            NativeMap.UiSettings.ZoomControlsEnabled = false;

            var cuPolygonOptions = new PolygonOptions();

            cuPolygonOptions.InvokeStrokeColor(Android.Graphics.Color.Argb(255, 219, 62, 68));
            cuPolygonOptions.InvokeStrokeWidth(15.0f);
            foreach (Community cyclesCommunity in Communities.CyclesCommunities)
            {
                cyclesCommunity.PolygonCoordinates.ForEach(lng => { cuPolygonOptions.Add(lng); });
                NativeMap.AddPolygon(cuPolygonOptions).Tag = cyclesCommunity.ShortName;
            }
        }
Ejemplo n.º 7
0
        private void NativeMap_MapClick(object sender, GoogleMap.MapClickEventArgs e)
        {
            if (DeliveryAddressPopUp.DeliveryAddresscheck == 0)
            {
                ShopListPage.Lat1 = e.Point.Latitude.ToString();
                ShopListPage.Lng1 = e.Point.Longitude.ToString();

                MessagingCenter.Send(
                    new LoggedInUser {
                }, "test");
            }
            if (DeliveryAddressPopUp.DeliveryAddresscheck == 1)
            {
                DeliveryAddressPopUp.Lat = e.Point.Latitude.ToString();
                DeliveryAddressPopUp.Lng = e.Point.Longitude.ToString();

                MessagingCenter.Send(
                    new LoggedInUser {
                }, "test");
            }
            try
            {
                NativeMap.Clear();

                BitmapDescriptor icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.customer);
                var marker            = new MarkerOptions();
                marker.SetPosition(new LatLng(e.Point.Latitude, e.Point.Longitude));
                marker.SetIcon(icon);

                MoveAble_Marker = NativeMap.AddMarker(marker);
                isDrawn         = true;
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 8
0
        private void AddPushPins(MapView mapView, IEnumerable <CustomPin> pins)
        {
            foreach (var formsPin in pins)
            {
                var markerWithIcon = new MarkerOptions();

                markerWithIcon.SetPosition(new LatLng(formsPin.Position.Latitude, formsPin.Position.Longitude));
                markerWithIcon.SetTitle(formsPin.Label);
                markerWithIcon.SetSnippet(formsPin.Address);

                switch (formsPin.Type)
                {
                case SuggestionType.Event:
                    _pinIcon = BitmapDescriptorFactory.FromResource(EventResource);
                    markerWithIcon.SetIcon(_pinIcon);
                    break;

                case SuggestionType.Restaurant:
                    _pinIcon = BitmapDescriptorFactory.FromResource(RestaurantResource);
                    markerWithIcon.SetIcon(_pinIcon);
                    break;

                default:
                    markerWithIcon.SetIcon(BitmapDescriptorFactory.DefaultMarker());
                    break;
                }

                NativeMap.AddMarker(markerWithIcon);

                _tempMarkers.Add(new CustomMarkerOptions
                {
                    Id            = formsPin.Id,
                    MarkerOptions = markerWithIcon
                });
            }
        }
Ejemplo n.º 9
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == CustomMap.PointsProperty.PropertyName)
            {
                if (NativeMap == null)
                {
                    return;
                }

                var customMap = (CustomMap)Element;
                foreach (var point in customMap.Points)
                {
                    var options = new CircleOptions();
                    options.InvokeStrokeWidth(0)
                    .InvokeFillColor(point.Heat.ToAndroid())
                    .InvokeRadius(200d)
                    .InvokeCenter(new LatLng(point.Location.Latitude, point.Location.Longitude));

                    NativeMap.AddCircle(options);
                }
            }
        }
        protected override Marker CreateNativeItem(Pin outerItem)
        {
            var opts = new MarkerOptions()
                       .SetPosition(new LatLng(outerItem.Position.Latitude, outerItem.Position.Longitude))
                       .SetTitle(outerItem.Label)
                       .SetSnippet(outerItem.Address)
                       .SetSnippet(outerItem.Address)
                       .Draggable(outerItem.IsDraggable)
                       .SetRotation(outerItem.Rotation)
                       .Anchor((float)outerItem.Anchor.X, (float)outerItem.Anchor.Y)
                       .InvokeZIndex(outerItem.ZIndex)
                       .Flat(outerItem.Flat)
                       .SetAlpha(1f - outerItem.Transparency);

            if (outerItem.Icon != null)
            {
                opts.SetIcon(outerItem.Icon.ToBitmapDescriptor());
            }

            var marker = NativeMap.AddMarker(opts);

            // If the pin has an IconView set this method will convert it into an icon for the marker
            if (outerItem?.Icon?.Type == BitmapDescriptorType.View)
            {
                marker.Visible = false; // Will become visible once the iconview is ready.
                TransformXamarinViewToAndroidBitmap(outerItem, marker);
            }
            else
            {
                marker.Visible = outerItem.IsVisible;
            }

            // associate pin with marker for later lookup in event handlers
            outerItem.NativeObject = marker;
            return(marker);
        }
 private void DibujaPines()
 {
     if (!isDrawn)
     {
         NativeMap.Clear();
         foreach (var pin in formsMap.Pins)
         {
             var marker = new MarkerOptions();
             marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
             marker.SetTitle(pin.Label);
             marker.SetSnippet(pin.Address);
             if (pin.Label == "Ud esta aqui")
             {
                 marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pinaqui));
             }
             else
             {
                 marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ecobici));
             }
             NativeMap.AddMarker(marker);
         }
     }
     isDrawn = true;
 }
Ejemplo n.º 12
0
        protected override NativeTileOverlay CreateNativeItem(TileLayer outerItem)
        {
            var opts = new TileOverlayOptions();

            ITileProvider nativeTileProvider;

            if (outerItem.MakeTileUri != null)
            {
                nativeTileProvider = new DroidUrlTileLayer(outerItem.MakeTileUri, outerItem.TileSize);
            }
            else if (outerItem.TileImageSync != null)
            {
                nativeTileProvider = new DroidSyncTileLayer(outerItem.TileImageSync, outerItem.TileSize);
            }
            else
            {
                nativeTileProvider = new DroidAsyncTileLayer(outerItem.TileImageAsync, outerItem.TileSize);
            }
            var nativeTileOverlay = NativeMap.AddTileOverlay(opts.InvokeTileProvider(nativeTileProvider));

            // associate pin with marker for later lookup in event handlers
            outerItem.NativeObject = nativeTileOverlay;
            return(nativeTileOverlay);
        }
Ejemplo n.º 13
0
 public void OnMapLoaded()
 {
     Map.Projection = new ProjectionImpl(NativeMap);
     NativeMap.OnResume();
     Map.SendLoaded();
 }
Ejemplo n.º 14
0
 protected override void OnMapReady(GoogleMap map)
 {
     base.OnMapReady(map);
     NativeMap.InfoWindowClick += OnInfoWindowClick;
     NativeMap.SetInfoWindowAdapter(this);
 }
Ejemplo n.º 15
0
 void UpdateCenter()
 {
     NativeMap.SetCenterCoordinate(Map.Center.ToNative(), false);
 }
Ejemplo n.º 16
0
 void UpdateShowUserLocation()
 {
     NativeMap.SetShowsUserLocation(Map.ShowUserLocation);
 }
        protected override void OnMapReady(GoogleMap map)
        {
            base.OnMapReady(map);

            NativeMap.SetOnMapClickListener(this);
        }
Ejemplo n.º 18
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            string imageURL = null, imageURLAux = null;
            Bitmap imageBitmap = null;

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                NativeMap.Clear();

                var polylineOptions = new PolylineOptions();
                polylineOptions.InvokeColor(Android.Graphics.Color.Rgb(244, 67, 54));

                foreach (var position in routeCoordinates)
                {
                    polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                }

                NativeMap.AddPolyline(polylineOptions);

                if (pinsCoordinates != null && pinsCoordinates.Count > 0)
                {
                    foreach (var pin in pinsCoordinates)
                    {
                        var marker = new MarkerOptions();
                        marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
                        marker.SetTitle(pin.Label);
                        marker.SetSnippet(pin.Address);

                        imageURL = pin.IconUrl;
                        if (imageURL == "" || imageURL == null)
                        {
                            marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.location_pin));
                        }
                        else
                        {
                            if (imageURLAux != imageURL)
                            {
                                // chaca se o arquivo com o ícone ja existe,
                                // é necessário remover as '/' e as '\' por conta do sistema de pastas
                                if (!fileService.CheckFile(pin.IconUrl.Replace("/", "_").Replace("\\", "_"), true))
                                {
                                    fileService.SaveImage(pin.IconUrl.Replace("/", "_").Replace("\\", "_"), pin.IconUrl);
                                    marker.SetIcon(BitmapDescriptorFactory.FromBitmap(fileService.LoadImage(pin.IconUrl.Replace("/", "_").Replace("\\", "_"))));
                                    //marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.location_pin));
                                }
                                else
                                {
                                    marker.SetIcon(BitmapDescriptorFactory.FromBitmap(fileService.LoadImage(pin.IconUrl.Replace("/", "_").Replace("\\", "_"))));
                                }
                            }
                            else
                            {
                                marker.SetIcon(BitmapDescriptorFactory.FromBitmap(imageBitmap));
                            }

                            NativeMap.AddMarker(marker);
                        }
                    }
                    isDrawn = true;
                }
            }
        }
 protected override void OnMapReady(Android.Gms.Maps.GoogleMap googleMap)
 {
     base.OnMapReady(googleMap);
     NativeMap.SetPadding(0, 0, 0, 500);
 }
Ejemplo n.º 20
0
 protected override void OnMapReady(GoogleMap map)
 {
     base.OnMapReady(map);
     NativeMap.SetOnMapLoadedCallback(this);
 }
Ejemplo n.º 21
0
 internal Enumerator(ref NativeMap <TKey, TValue> map)
 {
     _entries = map._buffer;
     _count   = map._count;
     _index   = -1;
 }
Ejemplo n.º 22
0
        private void AddDroidPin(CustomPin pin)
        {
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
            marker.SetTitle(pin.Pin.Label);
            marker.SetSnippet(pin.Pin.Address);

            switch (pin.CrimeType)
            {
            case Models.CrimeType.Homicide:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.h_pin));
                break;

            case Models.CrimeType.Robbery:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ro_pin));
                break;

            case Models.CrimeType.Assault:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.a_pin));
                break;

            case Models.CrimeType.Burglary:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.b_pin));
                break;

            case Models.CrimeType.Rape:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ra_pin));
                break;

            case Models.CrimeType.Theft:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.t_pin));
                break;

            case Models.CrimeType.Prostition:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.p_pin));
                break;

            case Models.CrimeType.TheftFromAuto:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ta_pin));
                break;

            case Models.CrimeType.StolenVehicle:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.vt_pin));
                break;

            case Models.CrimeType.VehicleRecovery:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.rv_pin));
                break;

            case Models.CrimeType.Gun:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.g_pin));
                break;

            case Models.CrimeType.Other:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.o_pin));
                break;

            case Models.CrimeType.CriminalMischief:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.m_pin));
                break;

            case Models.CrimeType.DUI:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.d_pin));
                break;

            case Models.CrimeType.OtherSexAssault:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.s_pin));
                break;

            case Models.CrimeType.Narcotics:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.n_pin));
                break;

            default:
                marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.o_pin));
                break;
            }

            if (NativeMap != null)
            {
                NativeMap.AddMarker(marker);
            }
        }
Ejemplo n.º 23
0
 void ClearPushPins(MapView mapView) => NativeMap.Clear();
Ejemplo n.º 24
0
        private void drawMarkers(int markerSize)
        {
            LatLngBounds.Builder bounds = new LatLngBounds.Builder();
            NativeMap.Clear();
            List <LatLng> latLngList = new List <LatLng>();

            foreach (var point in customMap.Points)
            {
                var latlng = new LatLng(point.Latitude, point.Longitude);
                latLngList.Add(latlng);

                /*var marker = new MarkerOptions();
                 * marker.Anchor(0.5f, 0.5f);
                 * marker.SetPosition(latlng);
                 * BitmapDescriptor pic = null;
                 * if (!string.IsNullOrEmpty(point.PathToPicture))
                 * {
                 *  Bitmap bm = BitmapFactory.DecodeFile(point.PathToPicture);
                 *  if (bm != null)
                 *  {
                 *      var croppedBitmap = getCroppedBitmap(bm, markerSize);
                 *      pic = BitmapDescriptorFactory.FromBitmap(croppedBitmap);
                 *      bm = null;
                 *      croppedBitmap = null;
                 *  }
                 * }
                 *
                 * if (pic == null)
                 * {
                 *  pic = BitmapDescriptorFactory.FromResource(Resource.Drawable.place_unknown);
                 * }
                 *
                 * marker.SetIcon(pic);
                 * NativeMap.AddMarker(marker);
                 * bounds.Include(latlng);*/
            }
            List <PatternItem> pattern_lines = new List <PatternItem>();

            pattern_lines.Add(new Gap(10));
            //pattern_lines.Add(new Dash(20));
            PolylineOptions lineOptions = new PolylineOptions();

            foreach (var point in latLngList)
            {
                lineOptions.Add(point);
            }
            //lineOptions.InvokePattern(pattern_lines);
            lineOptions.InvokeWidth(10);
            NativeMap.AddPolyline(lineOptions);
            if (customMap.Points.Count > 1)
            {
                try
                {
                    NativeMap.MoveCamera(CameraUpdateFactory.NewLatLngBounds(bounds.Build(), 100));
                }
                catch (Java.Lang.Exception)
                {
                }
            }
            bounds.Dispose();
        }
Ejemplo n.º 25
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            try
            {
                base.OnElementPropertyChanged(sender, e);

                if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
                {
                    NativeMap.Clear();
                    NativeMap.InfoWindowClick += OnInfoWindowClick;

                    var polylineOptions = new PolylineOptions();
                    polylineOptions.InvokeColor(0x66FF0000);
                    foreach (var pin in ((CustomMap)Element).CustomPins)
                    {
                        BitmapDescriptor icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.driver);
                        if (pin.Id == "1")
                        {
                            icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.customer);
                        }
                        else if (pin.Id == "Xamarin")
                        {
                            icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.driver);
                        }
                        else
                        {
                            icon = BitmapDescriptorFactory.FromResource(Resource.Drawable.shopPin);
                        }

                        var marker = new MarkerOptions();
                        marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                        marker.SetTitle(pin.Pin.Label);
                        marker.SetSnippet(pin.Pin.Address);
                        marker.SetIcon(icon);
                        if (pin.Id != "1")
                        {
                            MoveAble_Marker = NativeMap.AddMarker(marker);
                        }
                        else
                        {
                            NativeMap.AddMarker(marker);
                        }
                    }
                    //
                    //foreach (var position in ((CustomMap)Element).RouteCoordinates)
                    //{
                    //    polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                    //}
                    //NativeMap.AddPolyline(polylineOptions);

                    isDrawn = true;

                    Device.StartTimer(TimeSpan.FromSeconds(10), () =>
                    {
                        update();

                        return(true);
                    });
                }
            }
            catch { }
        }
Ejemplo n.º 26
0
        public void DrawLineBetweenPins()
        {
            #region Bind Pin Numbers
            for (int i = 0; i < customPins.Count; i++)
            {
                var marker = new MarkerOptions();
                marker.SetPosition(new LatLng(customPins[i].Position.Latitude, customPins[i].Position.Longitude));

                if (i == 0)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_1));
                }
                else if (i == 1)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_2));
                }
                else if (i == 2)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_3));
                }
                else if (i == 3)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_4));
                }
                else if (i == 4)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_5));
                }
                else if (i == 5)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_6));
                }
                else if (i == 6)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_7));
                }
                else if (i == 7)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_8));
                }
                else if (i == 8)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_9));
                }
                else if (i == 9)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_10));
                }
                else if (i == 10)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_11));
                }
                else if (i == 11)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_12));
                }
                else if (i == 12)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_11));
                }
                else if (i == 13)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_12));
                }
                else if (i == 14)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_13));
                }
                else if (i == 15)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_14));
                }
                else if (i == 16)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_15));
                }
                else if (i == 17)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_16));
                }
                else if (i == 18)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_17));
                }
                else if (i == 19)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_18));
                }
                else if (i == 20)
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_19));
                }
                else
                {
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_20));
                }

                marker.SetTitle(customPins[i].Label);
                marker.SetSnippet(customPins[i].Address);
                //marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.route_pin_1));

                NativeMap.AddMarker(marker);
            }
            #endregion
            var polylineOptions = new PolylineOptions();
            polylineOptions.InvokeColor(0x662873DD);
            polylineOptions.InvokeZIndex(5);
            polylineOptions.InvokeWidth(7);

            foreach (var position in routeCoordinates)
            {
                polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }

            NativeMap.AddPolyline(polylineOptions);
        }
Ejemplo n.º 27
0
 protected override void RemoveNativeItem(Pin item)
 {
     NativeMap.RemoveAnnotation((NSObject)item.NativeObject);
     item.NativeObject = null;
 }
Ejemplo n.º 28
0
 protected override void RemoveNativeItem(Polyline item)
 {
     NativeMap.RemoveOverlay((NSObject)item.NativeObject);
     item.NativeObject = null;
 }
 private void ClearPushPins(MapView mapView)
 {
     NativeMap.Clear();
 }
Ejemplo n.º 30
0
 protected override void RemoveNativeItem(Circle item)
 {
     NativeMap.RemoveOverlay((NSObject)item.NativeObject);
 }