public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            locationManager.RequestWhenInUseAuthorization();
            Mapa.ShowsUserLocation = true;

            Segmento.ValueChanged += (object sender, EventArgs e) => {
                switch (Segmento.SelectedSegment)
                {
                case 0:
                    Mapa.MapType = MKMapType.Standard;
                    break;

                case 1:
                    Mapa.MapType = MKMapType.Satellite;
                    break;

                case 2:
                    Mapa.MapType = MKMapType.Hybrid;
                    break;

                default:
                    break;
                }
            };

            Mapa.AddAnnotation(new MKPointAnnotation()
            {
                Title      = "Anotacion",
                Coordinate = new CLLocationCoordinate2D(21.1665143, -101.71766129999999)
            });
        }
示例#2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            try
            {
                if (_posiciones.Count >= 2)
                {
                    var primera = _posiciones[0];
                    var ultima  = _posiciones[_posiciones.Count - 1];

                    var Centrar = new CLLocationCoordinate2D(primera.Coordenada.Latitud, primera.Coordenada.Longitud);
                    var Altura  = new MKCoordinateSpan(.1, .1);
                    var Region  = new MKCoordinateRegion(Centrar, Altura);

                    Mapa.SetRegion(Region, true);

                    _posiciones.ForEach(x => Mapa.AddAnnotation(
                                            new MKPointAnnotation()
                    {
                        Title      = x.ViajeId.ToString(),
                        Coordinate = new CLLocationCoordinate2D()
                        {
                            Latitude  = x.Coordenada.Latitud,
                            Longitude = x.Coordenada.Longitud
                        }
                    }));

                    var origen        = new CLLocationCoordinate2D(primera.Coordenada.Latitud, primera.Coordenada.Longitud);
                    var destino       = new CLLocationCoordinate2D(ultima.Coordenada.Latitud, ultima.Coordenada.Longitud);
                    var Info          = new NSDictionary();
                    var OrigenDestino = new MKDirectionsRequest()
                    {
                        Source      = new MKMapItem(new MKPlacemark(origen, Info)),
                        Destination = new MKMapItem(new MKPlacemark(destino, Info))
                    };
                    var Direcciones = new MKDirections(OrigenDestino);
                    Direcciones.CalculateDirections((response, error) =>
                    {
                        var ruta  = response.Routes[0];
                        var Linea = new MKPolylineRenderer(ruta.Polyline)
                        {
                            LineWidth   = 5.0f,
                            StrokeColor = UIColor.Orange
                        };
                        Mapa.OverlayRenderer = (mapView, overlay) => Linea;
                        Mapa.AddOverlay(ruta.Polyline, MKOverlayLevel.AboveRoads);
                    });
                }
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex);
                MostrarMensaje("Error: ", ex.Message);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //SE CREA LA LISTA  Y MANDA LLAMAR EL METOOO DE CARGAR DATOS Y SE LO ASIGNA
            var Lista = CargarDatos();


            //EMPIEZA A CREAR LAS NUEVAS ANOTACIONES DE UNA FORMA DINAMICA
            Lista.ForEach(x => Mapa.AddAnnotation(new MKPointAnnotation()
            {
                Title      = x.Titulo,
                Coordinate = new CLLocationCoordinate2D()
                {
                    Latitude  = x.Latitud,
                    Longitude = x.Longitud
                }
            }));


            //DIRECCIONES
            var bajio  = new CLLocationCoordinate2D(21.152676, -101.711698);
            var laguna = new CLLocationCoordinate2D(25.510326, -103.453235);
            var Info   = new NSDictionary();


            var OrigenDestino = new MKDirectionsRequest()
            {
                Source      = new MKMapItem(new MKPlacemark(bajio, Info)),
                Destination = new MKMapItem(new MKPlacemark(laguna, Info)),
            };
            //SE CREA LA INSTANCIA PARA LAS DIRECCIONES
            var Direcciones = new MKDirections(OrigenDestino);

            //NOS AYUDARA A CARGAR LAS DIRECCIONES Y MARCARLO EN EL MAPA
            Direcciones.CalculateDirections((response, error) =>
            {
                if (error == null)
                {
                    var ruta  = response.Routes[0];
                    var Linea = new MKPolylineRenderer(ruta.Polyline)
                    {
                        LineWidth   = 5.0f,
                        StrokeColor = UIColor.Blue
                    };

                    //	SE CREA UN NUEVA CAPA
                    Mapa.OverlayRenderer = (res, err) => Linea;
                    // SE AGREGA LA NUEVA CAPA AL MAPA
                    Mapa.AddOverlay(ruta.Polyline, MKOverlayLevel.AboveRoads);
                }
            });
        }
示例#4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            double x, y;

            x = 42.364260;
            y = -71.120824;

            // Perform any additional setup after loading the view, typically from a nib.
            Mapa.MapType = MKMapType.Standard;
            Mapa.AddAnnotation(new CustomAnnotation("Xamarin", new CLLocationCoordinate2D(x, y)));
            CLLocationCoordinate2D Centrar = new CLLocationCoordinate2D(x, y);
            MKCoordinateSpan       Altura  = new MKCoordinateSpan(.002, .002);
            MKCoordinateRegion     Region  = new MKCoordinateRegion(Centrar, Altura);

            Mapa.SetRegion(Region, true);
        }
示例#5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            CLLocationManager locationManager = new CLLocationManager();

            locationManager.RequestWhenInUseAuthorization();

            Mapa.ShowsUserLocation = true;

            // Perform any additional setup after loading the view, typically from a nib.
            Mapa.MapType = MKMapType.Standard;

            const double lat       = 42.374260;
            const double lon       = -71.120824;
            var          mapCenter = new CLLocationCoordinate2D(lat, lon);
            var          mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 2000, 2000);

            Mapa.CenterCoordinate = mapCenter;
            Mapa.Region           = mapRegion;


            //se asigna del delegate creado
            mapaDel       = new mapaDelegate();
            Mapa.Delegate = mapaDel;

            Mapa.AddAnnotation(new MKPointAnnotation
            {
                Title      = "MyAnnotation",
                Coordinate = new CLLocationCoordinate2D(42.364260, -71.120824)
            });

            Mapa.AddAnnotation(new CustomAnnotation("Xamarin", mapCenter));

            var coords        = new CLLocationCoordinate2D(42.364260, -71.120824);
            var circleOverlay = MKCircle.Circle(coords, 200);

            Mapa.AddOverlay(circleOverlay);
        }
示例#6
0
        public void HandleLocationChanged(object sender, LocationUpdatedEventArgs e)
        {
            // Handle foreground updates
            CLLocation location = e.Location;

            lblAltitude.Text  = location.Altitude + " meters";
            lblLongitude.Text = location.Coordinate.Longitude.ToString();
            lblLAtitude.Text  = location.Coordinate.Latitude.ToString();
            lblCourse.Text    = location.Course.ToString();
            lblSpeed.Text     = location.Speed.ToString();

            Mapa.ShowsUserLocation = true;

            //mapa
            Mapa.AddAnnotation(new MKPointAnnotation()
            {
                Title      = "Anotacion",
                Coordinate = new CLLocationCoordinate2D(Manager.latitude, Manager.longitude)
            });

            Console.WriteLine("foreground updated");

            Console.WriteLine("initial loc:" + Mapa.UserLocation.Coordinate.Latitude + "," + Mapa.UserLocation.Coordinate.Longitude);
        }
示例#7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Visor.Image = UIImage.FromFile("fp.jpg");
            string htmlString =
                "<HTML><BODY BGCOLOR=BLUE><p><center><h1>Hola Web Embebido</h1></center></p></body></html>";

            VisorWeb.LoadHtmlString(htmlString, new NSUrl
                                        ("./", true));
            Selector.ValueChanged += (s, e) => {
                switch (Selector.SelectedSegment)
                {
                case 0:
                    Mapa.MapType = MKMapType.Standard;
                    break;

                case 1:
                    Mapa.MapType = MKMapType.Satellite;
                    break;

                case 2:
                    Mapa.MapType = MKMapType.Hybrid;
                    break;
                }
            };
            Lista.ForEach(x => Mapa.AddAnnotation(new MKPointAnnotation()
            {
                Title      = x.Titulo,
                Coordinate = new CLLocationCoordinate2D()
                {
                    Latitude  = x.Latitud,
                    Longitude = x.Longitud
                }
            }));
            var Leon          = new CLLocationCoordinate2D(21.152676, -101.711698);
            var Cancun        = new CLLocationCoordinate2D(21.052743, -86.847242);
            var Tijuana       = new CLLocationCoordinate2D(32.526384, -117.028983);
            var Info          = new NSDictionary();
            var OrigenDestino = new MKDirectionsRequest()
            {
                Source      = new MKMapItem(new MKPlacemark(Leon, Info)),
                Destination = new MKMapItem(new MKPlacemark(Cancun, Info)),
            };
            var OrigenDestino2 = new MKDirectionsRequest()
            {
                Source      = new MKMapItem(new MKPlacemark(Leon, Info)),
                Destination = new MKMapItem(new MKPlacemark(Tijuana, Info)),
            };
            var RutaLeonCancun = new MKDirections(OrigenDestino);

            RutaLeonCancun.CalculateDirections((response, error) => {
                if (error == null)
                {
                    var ruta  = response.Routes [0];
                    var Linea = new MKPolylineRenderer(ruta.Polyline)
                    {
                        LineWidth   = 5.0f,
                        StrokeColor = UIColor.Red,
                    };
                    Mapa.OverlayRenderer = (Res, Err) => Linea;
                    Mapa.AddOverlay(ruta.Polyline, MKOverlayLevel.AboveRoads);
                }
            });
            var RutaLeonTijuana = new MKDirections(OrigenDestino2);

            RutaLeonTijuana.CalculateDirections((response, error) =>
            {
                if (error == null)
                {
                    var ruta  = response.Routes[0];
                    var Linea = new MKPolylineRenderer(ruta.Polyline)
                    {
                        LineWidth   = 5.0f,
                        StrokeColor = UIColor.Blue,
                    };
                    Mapa.OverlayRenderer = (Res, Err) => Linea;
                    Mapa.AddOverlay(ruta.Polyline, MKOverlayLevel.AboveRoads);
                }
            });
        }