Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Map = new MKMapView(View.Bounds)
            {
                RotateEnabled = true,
                ScrollEnabled = true,
                ZoomEnabled   = true,
                Delegate      = new MapDelegate(),
                MapType       = MKMapType.Standard
            };

            View.AddSubview(Map);

            foreach (var location in SampleData.Locations)
            {
                Map.AddOverlay(MKPolygon.FromCoordinates(location.BoundaryData
                                                         .Select(boundaryLocation => new CLLocationCoordinate2D(boundaryLocation.Latitude, boundaryLocation.Longitude))
                                                         .ToArray()));

                Map.AddAnnotation(new MKPointAnnotation
                {
                    Title      = location.Title,
                    Coordinate = new CLLocationCoordinate2D(location.Latitude, location.Longitude)
                });
            }

            Map.ShowAnnotations(Map.Annotations, true);
        }
Ejemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            SetupNavigationBar();

            Title = Constants.MapMarkers;

            _locationManager = new CLLocationManager();
            _locationManager.RequestWhenInUseAuthorization();

            _map.ShowsUserLocation = true;

            MarkerListFromRepository = ViewModel.MarkerList;

            if (MarkerListFromRepository.Any())
            {
                foreach (MapMarkerEntity coord in MarkerListFromRepository)
                {
                    _map.AddAnnotations(new MKPointAnnotation()
                    {
                        Title      = Constants.MapMarker,
                        Coordinate = new CLLocationCoordinate2D(coord.Latitude, coord.Longitude)
                    });
                }
            }

            var longPress = new UILongPressGestureRecognizer(LongPress);

            _map.AddGestureRecognizer(longPress);

            _map.ShowAnnotations(_map.Annotations, false);

            View = _map;
        }
Ejemplo n.º 3
0
Archivo: vcMap.cs Proyecto: pauZc/8_iOS
        // Perform any additional setup after loading the view, typically from a nib.

        private MKDirectionsRequest Add_Annotation(MKPointAnnotation[] anotacion, CLLocationCoordinate2D[] coord, MKMapView mapView)
        {
            mapView.ShowAnnotations(new MKPointAnnotation[] { anotacion[0], anotacion[1] }, false);

            var entydict = new NSDictionary();

            var req = new MKDirectionsRequest()
            {
                Source        = new MKMapItem(new MKPlacemark(coord[0], entydict)),
                Destination   = new MKMapItem(new MKPlacemark(coord[1], entydict)),
                TransportType = MKDirectionsTransportType.Automobile
            };

            return(req);
        }