示例#1
0
        async void Update(Xamarin.Forms.GoogleMaps.Position position)
        {
            if (Pins.Count == 1 && Polylines != null && Polylines?.Count > 1)
            {
                return;
            }

            var cPin = Pins.FirstOrDefault();

            if (cPin != null)
            {
                cPin.Position = new Position(position.Latitude, position.Longitude);
                cPin.Icon     = (Device.RuntimePlatform == Device.Android) ? BitmapDescriptorFactory.FromBundle("ic_taxi.png") : BitmapDescriptorFactory.FromView(new Image()
                {
                    Source = "ic_taxi.png", WidthRequest = 25, HeightRequest = 25
                });

                await MoveCamera(CameraUpdateFactory.NewPosition(new Position(position.Latitude, position.Longitude)));

                var previousPosition = Polylines?.FirstOrDefault()?.Positions?.FirstOrDefault();
                Polylines?.FirstOrDefault()?.Positions?.Remove(previousPosition.Value);
            }
            else
            {
                //END TRIP
                Polylines?.FirstOrDefault()?.Positions?.Clear();
            }
        }
示例#2
0
        private CodeValuePair HandlePolyline()
        {
            var codeValue = GetPair();
            var polyline  = new Polyline();

            while (!Ended)
            {
                switch (codeValue.Code)
                {
                case 0:

                    if (codeValue.Value != VERTEX)
                    {
                        Polylines.Add(polyline);
                        return(codeValue);
                    }
                    else
                    {
                        HandleVertexSegment(polyline);
                    }

                    break;

                default:
                    polyline.ParseCode(codeValue);
                    break;
                }
                codeValue = GetPair();
            }
            return(codeValue);
        }
示例#3
0
 private void ClearPolygon(object obj)
 {
     Pins.Clear();
     Polylines.Clear();
     Polygons.Clear();
     _allowedToAddPoint = true;
 }
示例#4
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);
            }
        }
示例#5
0
 internal void Limpar()
 {
     this.Mapa.Clear();
     MarcadoresColocados.Clear();
     VagasColocadas.Clear();
     Polylines.Clear();
     PolylinesCaminhoParaVaga.Clear();
 }
示例#6
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);
        }
示例#7
0
        void UpdateRoute()
        {
            if (RouteCoordinates.Count > 2)
            {
                polyline = new Polyline();
                foreach (GeoPosition p in RouteCoordinates)
                {
                    polyline.Positions.Add(new Position(p.Latitude, p.Longitude));
                }

                Polylines.Add(polyline);
                CenterMap();
            }
        }
        public void UpdateRouteView(Route route)
        {
            var locationCollection = new LocationCollection();

            foreach (var segment in route.Segments)
            {
                var point = segment.Figure.Points.First();
                locationCollection.Add(new Location()
                {
                    Latitude  = RadianToDegree(point.Latitude),
                    Longitude = RadianToDegree(point.Longitude)
                }
                                       );
            }
            Polylines.FirstOrDefault().Locations = locationCollection;
        }
示例#9
0
        private void DesenharRota(List <Position> lista)
        {
            if (lista.Count > 1)
            {
                var polyline = new Polyline();
                foreach (Position posi in lista)
                {
                    polyline.Positions.Add(posi);
                }

                polyline.IsClickable = true;
                polyline.StrokeColor = Color.Blue;
                polyline.StrokeWidth = 2f;
                Polylines.Add(polyline);
            }
        }
示例#10
0
 public void Delete(Entity entity)
 {
     if (entity is Box && Boxes.Contains((Box)entity))
     {
         Boxes.Remove((Box)entity);
     }
     if (entity is Polyline && Polylines.Contains((Polyline)entity))
     {
         Polylines.Remove((Polyline)entity);
     }
     if (entity is InsertedImage && InsertedImages.Contains((InsertedImage)entity))
     {
         InsertedImages.Remove((InsertedImage)entity);
     }
     if (entity is Circle && Circles.Contains((Circle)entity))
     {
         Circles.Remove((Circle)entity);
     }
 }
示例#11
0
        private void ParsePolylines(XmlReader r)
        {
            r.ReadStartElement();

            while (r.NodeType == XmlNodeType.Element)
            {
                if (r.Name == "Polyline")
                {
                    Polylines.Add(new GenericPosturePolyline(r));
                }
                else
                {
                    string outerXml = r.ReadOuterXml();
                    log.DebugFormat("Unparsed content in XML: {0}", outerXml);
                }
            }

            r.ReadEndElement();
        }
示例#12
0
        private void AddTappedLocationAndRaise(Position position)
        {
            if (!_allowedToAddPoint)
            {
                return;
            }

            Pins.Add(new TKCustomMapPin {
                Position = position, DefaultPinColor = Color.Teal
            });
            if (Pins.Count <= 1)
            {
                return;                  // can't make a line with 1 pin
            }
            var previous = Pins.Reverse().Skip(1).First();

            Polylines.Add(new TKPolyline {
                LineCoordinates = new List <Position> {
                    previous.Position, position
                }, Color = Color.Teal, LineWidth = 2
            });
        }
示例#13
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);
        }
示例#14
0
 public DroidGCode(Polylines printList)
 {
     polylineList = printList;
 }
示例#15
0
        public MapViewModel()
        {
            Points.Add(new PointItem
            {
                Name     = "Steinbake Leitdamm",
                Location = new Location(53.51217, 8.16603)
            });
            Points.Add(new PointItem
            {
                Name     = "Buhne 2",
                Location = new Location(53.50926, 8.15815)
            });
            Points.Add(new PointItem
            {
                Name     = "Buhne 4",
                Location = new Location(53.50468, 8.15343)
            });
            Points.Add(new PointItem
            {
                Name     = "Buhne 6",
                Location = new Location(53.50092, 8.15267)
            });
            Points.Add(new PointItem
            {
                Name     = "Buhne 8",
                Location = new Location(53.49871, 8.15321)
            });
            Points.Add(new PointItem
            {
                Name     = "Buhne 10",
                Location = new Location(53.49350, 8.15563)
            });

            Pushpins.Add(new PointItem
            {
                Name     = "WHV - Eckwarderhörne",
                Location = new Location(53.5495, 8.1877)
            });
            Pushpins.Add(new PointItem
            {
                Name     = "JadeWeserPort",
                Location = new Location(53.5914, 8.14)
            });
            Pushpins.Add(new PointItem
            {
                Name     = "Kurhaus Dangast",
                Location = new Location(53.447, 8.1114)
            });
            Pushpins.Add(new PointItem
            {
                Name     = "Eckwarderhörne",
                Location = new Location(53.5207, 8.2323)
            });

            Polylines.Add(new Polyline
            {
                Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
            });
            Polylines.Add(new Polyline
            {
                Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
            });
        }
示例#16
0
        /// <summary>
        /// Read and parse the DXF file
        /// </summary>
        public void Read()
        {
            bool entitysection = false;

            CodePair code = this.ReadPair();

            while ((code.Value != "EOF") && (!dxfReader.EndOfStream))
            {
                if (code.Code == 0)
                {
                    //Have we reached the entities section yet?
                    if (!entitysection)
                    {
                        //No, so keep going until we find the ENTIIES section (and since we are here, let's try to read the layers)
                        switch (code.Value)
                        {
                        case "SECTION":
                            string sec = ReadSection(ref code);
                            if (sec == "ENTITIES")
                            {
                                entitysection = true;
                            }
                            break;

                        case "LAYER":
                            Layer layer = ReadLayer(ref code);
                            Layers.Add(layer);
                            break;

                        default:
                            code = this.ReadPair();
                            break;
                        }
                    }
                    else
                    {
                        //Yes, so let's read the entities
                        switch (code.Value)
                        {
                        case "LINE":
                            Line line = ReadLine(ref code);
                            Lines.Add(line);
                            break;

                        case "CIRCLE":
                            Circle circle = ReadCircle(ref code);
                            Circles.Add(circle);
                            break;

                        case "ARC":
                            Arc arc = ReadArc(ref code);
                            Arcs.Add(arc);
                            break;

                        case "POINT":
                            Point point = ReadPoint(ref code);
                            Points.Add(point);
                            break;

                        case "TEXT":
                            Text text = ReadText(ref code);
                            Texts.Add(text);
                            break;

                        case "POLYLINE":
                            Polyline polyline = ReadPolyline(ref code);
                            Polylines.Add(polyline);
                            break;

                        case "LWPOLYLINE":
                            Polyline lwpolyline = ReadLwPolyline(ref code);
                            Polylines.Add(lwpolyline);
                            break;

                        default:
                            code = this.ReadPair();
                            break;
                        }
                    }
                }
                else
                {
                    code = this.ReadPair();
                }
            }
        }
示例#17
0
 private void LimparRota()
 {
     Polylines.Clear();
 }
示例#18
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)
                    {
                    }
                }
            }
        }