Exemplo n.º 1
0
        private void OnPinClicked(TKCustomMapPin pin)
        {
            var firstPosition = Pins.First().Position;
            var position      = pin.Position;

            // if the user tapped the first marker, we'll close the gap.
            // and prevent them from adding more points.
            _allowedToAddPoint = _allowedToAddPoint &&
                                 Pins.Count > 1 &&
                                 !(Math.Abs(position.Latitude - firstPosition.Latitude) <= 0 && Math.Abs(position.Longitude - firstPosition.Longitude) <= 0);

            if (!_allowedToAddPoint)
            {
                var polygon = new TKPolygon
                {
                    Color       = Color.FromHex("#7f000000"),
                    StrokeColor = Color.Black,
                    StrokeWidth = 2
                };
                foreach (var line in Polylines)
                {
                    polygon.Coordinates.AddRange(line.LineCoordinates);
                }
                Polylines.Clear();
                Polygons.Clear();
                Pins.Clear();
                Polygons.Add(polygon);
            }
        }
Exemplo n.º 2
0
 private void ClearPolygon(object obj)
 {
     Pins.Clear();
     Polylines.Clear();
     Polygons.Clear();
     _allowedToAddPoint = true;
 }
Exemplo n.º 3
0
 internal void Limpar()
 {
     this.Mapa.Clear();
     MarcadoresColocados.Clear();
     VagasColocadas.Clear();
     Polylines.Clear();
     PolylinesCaminhoParaVaga.Clear();
 }
Exemplo n.º 4
0
        private void showRoute()
        {
            var routePoints = GooglePolylineCoder.DecodeGooglePolyline(webOrder.RouteMetrics);

            var polyline = new Polyline();

            polyline.StrokeColor = Color.Blue;
            polyline.StrokeWidth = 5f;
            //polyline.Tag = "POLYLINE"; // Can set any object

            foreach (var point in routePoints)
            {
                polyline.Positions.Add(new Position(point.Lat, point.Lon));
            }

            var positions = routePoints.Select(rp => new Position(rp.Lat, rp.Lon)).ToList();

            CenterMapFromPositions = positions;

            Polylines.Clear();
            Polylines.Add(polyline);



            var startPoint = routePoints.FirstOrDefault();
            var endPin     = routePoints.LastOrDefault();
            var startPin   = new Pin
            {
                Position    = new Position(startPoint.Lat, startPoint.Lon),
                IsDraggable = false,
                IsVisible   = true,
                Label       = "Старт",
                Address     = webOrder.SrcAddress.StreetOrPlace + ", " + webOrder.SrcAddress.House,
                Type        = PinType.Place
            };

            var assembly = typeof(ConfirmOrderPage).GetTypeInfo().Assembly;
            var stream   = assembly.GetManifestResourceStream($"taxi.Images.start_s.png");

            startPin.Icon = BitmapDescriptorFactory.FromStream(stream);

            var finishPin = new Pin
            {
                Position    = new Position(endPin.Lat, endPin.Lon),
                IsDraggable = false,
                IsVisible   = true,
                Label       = "Финиш",
                Type        = PinType.Place,
                Address     = webOrder.DstAddresses[0].StreetOrPlace + ", " + webOrder.DstAddresses[0].House
            };

            stream         = assembly.GetManifestResourceStream($"taxi.Images.finish_s.png");
            finishPin.Icon = BitmapDescriptorFactory.FromStream(stream);

            Pins.Add(startPin);
            Pins.Add(finishPin);
        }
Exemplo n.º 5
0
        void Calculate(List <Xamarin.Forms.GoogleMaps.Position> list)
        {
            OnCalculate?.Invoke(this, default(EventArgs));
            Polylines.Clear();
            var polyline = new Xamarin.Forms.GoogleMaps.Polyline();

            foreach (var p in list)
            {
                polyline.Positions.Add(p);
            }
            Polylines.Add(polyline);
            MoveToRegion(MapSpan.FromCenterAndRadius(new Position(polyline.Positions[0].Latitude, polyline.Positions[0].Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(0.50f)));

            var pin = new Xamarin.Forms.GoogleMaps.Pin
            {
                Type     = PinType.Place,
                Position = new Position(polyline.Positions.First().Latitude, polyline.Positions.First().Longitude),
                Label    = "First",
                Address  = "First",
                Tag      = string.Empty,
                Icon     = (Device.RuntimePlatform == Device.Android) ? BitmapDescriptorFactory.FromBundle("ic_taxi.png") : BitmapDescriptorFactory.FromView(new Image()
                {
                    Source = "ic_taxi.png", WidthRequest = 25, HeightRequest = 25
                })
            };

            Pins.Add(pin);
            var pin1 = new Xamarin.Forms.GoogleMaps.Pin
            {
                Type     = PinType.Place,
                Position = new Position(polyline.Positions.Last().Latitude, polyline.Positions.Last().Longitude),
                Label    = "Last",
                Address  = "Last",
                Tag      = string.Empty
            };

            Pins.Add(pin1);
        }
Exemplo n.º 6
0
 private void LimparRota()
 {
     Polylines.Clear();
 }
Exemplo n.º 7
0
        public void MostrarEstacionamentosNoMap(JArray lista)
        {
            foreach (Marcador marcador in MarcadoresColocados)
            {
                marcador.Marker.Remove();
                foreach (Polyline linha in marcador.Linhas)
                {
                    linha.Remove();
                }
            }
            MarcadoresColocados.Clear();

            foreach (Polyline linha in Polylines)
            {
                linha.Remove();
            }
            Polylines.Clear();
            foreach (var estacionamento in lista)
            {
                var latitude  = (estacionamento["Localizacao"])["Latitude"].Value <double>();
                var longitude = (estacionamento["Localizacao"])["Longitude"].Value <double>();
                var altitude  = (estacionamento["Localizacao"])["Altitude"].Value <float>();



                LatLng latlng = new LatLng(Convert.ToDouble(latitude), Convert.ToDouble(longitude));


                var           imagemMarcador = BitmapDescriptorFactory.FromResource(Resource.Drawable.parking);
                MarkerOptions options        = new MarkerOptions().SetPosition(latlng).SetTitle("").SetIcon(imagemMarcador);

                Marker ponto = Mapa.AddMarker(options);
                this.Markers.Add(ponto);
                Marcador marcador = new Marcador((JObject)estacionamento, ponto);
                MarcadoresColocados.Add(marcador);
                var pontos = (JArray)estacionamento["Pontos"];
                MostrarPontosNoMapa((JObject)estacionamento, pontos);
                if (!string.IsNullOrEmpty(estacionamento["ImagemBase64"].Value <string>()))
                {
                    try
                    {
                        var swbounds = new LatLng(estacionamento["SWBoundImagem"].Value <double>("Latitude"),
                                                  estacionamento["SWBoundImagem"].Value <double>("Longitude"));
                        var nebounds = new LatLng(estacionamento["NEBoundImagem"].Value <double>("Latitude"),
                                                  estacionamento["NEBoundImagem"].Value <double>("Longitude"));


                        LatLngBounds bounds = new LatLngBounds(swbounds, nebounds);



                        byte[] decodedString = Base64.Decode(estacionamento["ImagemBase64"].Value <string>(), Base64Flags.Default);

                        Bitmap decodedByte = BitmapFactory.DecodeByteArray(decodedString, 0, decodedString.Length);

                        var bitmapDescriptor = BitmapDescriptorFactory.FromBitmap(decodedByte);

                        GroundOverlayOptions newarkMap = new GroundOverlayOptions()
                                                         .InvokeImage(bitmapDescriptor).PositionFromBounds(bounds);

                        var overlay = Mapa.AddGroundOverlay(newarkMap);
                        overlay.Clickable        = true;
                        Mapa.GroundOverlayClick += (obj, args) =>
                        {
                            if (args.GroundOverlay.Id == overlay.Id)
                            {
                                if (STATUS_CONTROLE == StatusGUI.Normal)
                                {
                                    this.EstacionamentoSelecionado = (JObject)estacionamento;
                                    if (this.EstacionamentoSelecionadoEvent != null)
                                    {
                                        (this.EstacionamentoSelecionadoEvent).DynamicInvoke(EstacionamentoSelecionado);
                                    }
                                }
                            }
                            else
                            {
                                if ((Action)this.CliqueNoChaoEvent != null)
                                {
                                    CliqueNoChaoEvent.DynamicInvoke(args.GroundOverlay);
                                }
                            }
                        };
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }