コード例 #1
0
 void _mapView_RegionWillChange(object sender, MKMapViewChangeEventArgs e)
 {
     if (_imageView != null)
     {
         UIView.Animate(0.2, () => _imageView.Alpha = 0, () => _imageView.Hidden = true);
     }
 }
コード例 #2
0
        private void CustomDelegate_OnRegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            var lat = map.Region.Center.Latitude;
            var lon = map.Region.Center.Longitude;

            CoreGraphics.CGPoint location = new CoreGraphics.CGPoint(lat, lon);
            //var coord = map.ConvertPoint(location, map);
            map.AddAnnotation(annotation);
            map.ReloadInputViews();
        }
コード例 #3
0
        private void NativeMap_RegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            // This
            if (_xamarinMap.OnRegionChanged != null)
            {
                _xamarinMap.OnRegionChanged();
            }

            // or this
            MessagingCenter.Send <object>(this, "RegionChanged");
        }
コード例 #4
0
 void MapView_RegionChanged(object sender, MKMapViewChangeEventArgs e)
 {
     var mapView = (MKMapView)sender;
     _geocoder.ReverseGeocodeLocation(new CLLocation(mapView.CenterCoordinate.Latitude, mapView.CenterCoordinate.Longitude), (placemarks, error) =>
         {
             if(placemarks.Any())
             {
                 var address = ABAddressFormatting.ToString(placemarks[0].AddressDictionary, addCountryName: false);
                 _addressChanged.Invoke(address);
             }
         });
 }
コード例 #5
0
        void MkMapViewOnRegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            if (Element == null)
            {
                return;
            }

            var mapModel  = (Map)Element;
            var mkMapView = (MKMapView)Control;

            mapModel.SetVisibleRegion(new MapSpan(new Position(mkMapView.Region.Center.Latitude, mkMapView.Region.Center.Longitude), mkMapView.Region.Span.LatitudeDelta, mkMapView.Region.Span.LongitudeDelta));
        }
コード例 #6
0
        private void MapViewOnRegionChanged(object sender, MKMapViewChangeEventArgs mkMapViewChangeEventArgs)
        {
            Console.WriteLine(GetZoomLevel());

            if (GetZoomLevel() > 17.3f)
            {
                Control.SetRegion(backupRegion, true);
            }
            else
            {
                backupRegion = Control.Region;
            }
        }
コード例 #7
0
        void MapView_RegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            var mapView = (MKMapView)sender;

            _geocoder.ReverseGeocodeLocation(new CLLocation(mapView.CenterCoordinate.Latitude, mapView.CenterCoordinate.Longitude), (placemarks, error) =>
            {
                if (placemarks.Any())
                {
                    var address = ABAddressFormatting.ToString(placemarks[0].AddressDictionary, addCountryName: false);
                    _addressChanged.Invoke(address);
                }
            });
        }
コード例 #8
0
        void MapRegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            var current = new Dictionary <string, AirportAnnotation> ();
            var added   = new List <AirportAnnotation> ();

            // Query for the list of airports in the new region
            foreach (var airport in GetAirports(mapView.Region))
            {
                AirportAnnotation annotation;

                if (annotations.ContainsKey(airport.FAA))
                {
                    // This airport is already in view...
                    annotation = annotations[airport.FAA];
                    annotation.UserCoordinates = coordinates;
                    annotations.Remove(airport.FAA);
                }
                else
                {
                    // This is a new annotation, keep track of it in 'added'
                    annotation = new AirportAnnotation(airport, coordinates);
                    added.Add(annotation);
                }

                current.Add(annotation.Airport.FAA, annotation);
            }

            if (annotations.Count > 0)
            {
                // Remove annotations that are no longer in view
                mapView.RemoveAnnotations(annotations.Values.ToArray());
                foreach (var annotation in annotations.Values)
                {
                    annotation.Dispose();
                }
                annotations.Clear();
            }

            if (added.Count > 0)
            {
                mapView.AddAnnotations(added.ToArray());
                foreach (var annotation in added)
                {
                    annotation.Dispose();
                }
            }

            annotations = current;
        }
コード例 #9
0
ファイル: MapPresenter.iOS.cs プロジェクト: weitzhandler/Uno
		private void OnRegionChanged(object sender, MKMapViewChangeEventArgs e)
		{
			if (!_changingCenter)
			{
				_changingCenter = true;

				try
				{
					_owner.Center = _internalMapView.Region.Center.ToGeopoint();
					UpdateZoomLevel();
				}
				finally
				{
					_changingCenter = false;
				}
			}
		}
コード例 #10
0
 void OnMapRegionChanged(object sender, MKMapViewChangeEventArgs e)
 {
     if (!customMap.OnSelect && !customMap.OnSearch)
     {
         s = sender as MKMapView;
         mapDraggedTime = DateTime.Now;
         CanFetch       = false;
         //var startTime = DateTime.Now.Add(TimeSpan.FromSeconds(2));
         //Device.StartTimer(TimeSpan.FromSeconds(5), () => {
         //    return true;
         //});
     }
     if (!customMap.OnSelect)
     {
         customMap.hideInfoView();
     }
 }
コード例 #11
0
        private async void MapView_RegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            if (Element == null)
            {
                return;
            }

            _mapView.ZoomEnabled    = true;
            _mapView.ScrollEnabled  = true;
            _mapView.RegionChanged -= MapView_RegionChanged;

            var center = _mapView.Region.Center;

            //This solves the problem of MKMAPVIEW to Reset its view to FirstLocation
            _customMap.MoveToRegion(new MapSpan(new Position(center.Latitude, center.Longitude), _mapView.Region.Span.LatitudeDelta, _mapView.Region.Span.LongitudeDelta));

            _mapView.RegionChanged += MapView_RegionChanged;

            if (_customMap.OnVisibleRegionChanged != null)
            {
                var halfheightDegrees = _mapView.Region.Span.LatitudeDelta / 2;
                var halfwidthDegrees  = _mapView.Region.Span.LongitudeDelta / 2;

                var left  = Math.Round(center.Longitude - halfwidthDegrees, 2);
                var right = Math.Round(center.Longitude + halfwidthDegrees, 2);

                var top    = Math.Round(center.Latitude + halfheightDegrees, 2);
                var bottom = Math.Round(center.Latitude - halfheightDegrees, 2);

                if (left < -180)
                {
                    left = 180 + (180 + left);
                }
                if (right > 180)
                {
                    right = (right - 180) - 180;
                }

                var topLeft     = top.ToString() + "," + left.ToString();
                var bottomRight = bottom.ToString() + "," + right.ToString();

                await _customMap.OnVisibleRegionChanged(bottomRight, topLeft);
            }
        }
コード例 #12
0
        void MapRegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            Dictionary <string, AirportAnnotation> current = new Dictionary <string, AirportAnnotation> ();
            List <AirportAnnotation> added = new List <AirportAnnotation> ();

            // Query for the list of airports in the new region
            foreach (var airport in Airports.GetAirports(mapView.Region))
            {
                AirportAnnotation aa;

                if (annotations.ContainsKey(airport.FAA))
                {
                    // This airport is already in view...
                    aa = annotations[airport.FAA];
                    annotations.Remove(airport.FAA);
                }
                else
                {
                    // This is a new annotation, keep track of it in 'added'
                    aa = new AirportAnnotation(airport);
                    added.Add(aa);
                }

                current.Add(aa.Airport.FAA, aa);
            }

            if (annotations.Count > 0)
            {
                // Remove annotations that are no longer in view
                mapView.RemoveAnnotations(annotations.Values.ToArray());
                annotations.Clear();
            }

            if (added.Count > 0)
            {
                mapView.AddAnnotation(added.ToArray());
                added.Clear();
            }

            annotations = current;
        }
コード例 #13
0
        private void MapViewOnRegionChanged(Object sender, MKMapViewChangeEventArgs e)
        {
            CenterLocation = map.Region.Center;

            //var latitude = CenterLocation.Latitude;
            //var longitude = CenterLocation.Longitude;

            //Console.WriteLine(String.Format("{0}, {1}", latitude, longitude));


            Double scale = map.Bounds.Size.Width / map.VisibleMapRect.Size.Width;
            List <IMKAnnotation> annotationsToDisplay = AnnotationsClusteringManager.ClusteredAnnotationsWithinMapRect(map.VisibleMapRect, scale);

            AnnotationsClusteringManager.DisplayAnnotations(annotationsToDisplay, map);

            DocumentList = DocumentList.OrderBy(doc => doc.GetDistance(CenterLocation.Latitude, CenterLocation.Longitude)).ToList();

            source.UpdateData(DocumentList);

            CollectionView.ReloadData();
        }
コード例 #14
0
        async void MyMap_RegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            string tempData = await _weatherApi.GetWeather(MyMap.CenterCoordinate.Latitude, MyMap.CenterCoordinate.Latitude);

            Description.Text = tempData;
        }
コード例 #15
0
 /// <summary>
 /// Cambio region mapa.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Mapa_RegionChanged(object sender, MKMapViewChangeEventArgs e)
 {
     // Actualizo tarea
     controller.t.Cliente.Direccion.Coords = new Coordenadas(mapa.CenterCoordinate.Latitude, mapa.CenterCoordinate.Longitude);
 }
コード例 #16
0
ファイル: MapRenderer.cs プロジェクト: ytn3rd/Xamarin.Forms
		void MkMapViewOnRegionChanged(object sender, MKMapViewChangeEventArgs mkMapViewChangeEventArgs)
		{
			if (Element == null)
				return;

			var mapModel = (Map)Element;
			var mkMapView = (MKMapView)Control;

			mapModel.VisibleRegion = new MapSpan(new Position(mkMapView.Region.Center.Latitude, mkMapView.Region.Center.Longitude), mkMapView.Region.Span.LatitudeDelta, mkMapView.Region.Span.LongitudeDelta);
		}
コード例 #17
0
        void MapRegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            Dictionary<string, AirportAnnotation> current = new Dictionary<string, AirportAnnotation> ();
            List<AirportAnnotation> added = new List<AirportAnnotation> ();

            // Query for the list of airports in the new region
            foreach (var airport in Airports.GetAirports (mapView.Region)) {
                AirportAnnotation aa;

                if (annotations.ContainsKey (airport.FAA)) {
                    // This airport is already in view...
                    aa = annotations[airport.FAA];
                    annotations.Remove (airport.FAA);
                } else {
                    // This is a new annotation, keep track of it in 'added'
                    aa = new AirportAnnotation (airport);
                    added.Add (aa);
                }

                current.Add (aa.Airport.FAA, aa);
            }

            if (annotations.Count > 0) {
                // Remove annotations that are no longer in view
                mapView.RemoveAnnotations (annotations.Values.ToArray ());
                annotations.Clear ();
            }

            if (added.Count > 0) {
                mapView.AddAnnotation (added.ToArray ());
                added.Clear ();
            }

            annotations = current;
        }
コード例 #18
0
        void MapRegionChanged(object sender, MKMapViewChangeEventArgs e)
        {
            var current = new Dictionary<string, AirportAnnotation> ();
            var added = new List<AirportAnnotation> ();

            // Query for the list of airports in the new region
            foreach (var airport in GetAirports (mapView.Region)) {
                AirportAnnotation annotation;

                if (annotations.ContainsKey (airport.FAA)) {
                    // This airport is already in view...
                    annotation = annotations[airport.FAA];
                    annotation.UserCoordinates = coordinates;
                    annotations.Remove (airport.FAA);
                } else {
                    // This is a new annotation, keep track of it in 'added'
                    annotation = new AirportAnnotation (airport, coordinates);
                    added.Add (annotation);
                }

                current.Add (annotation.Airport.FAA, annotation);
            }

            if (annotations.Count > 0) {
                // Remove annotations that are no longer in view
                mapView.RemoveAnnotations (annotations.Values.ToArray ());
                foreach (var annotation in annotations.Values)
                    annotation.Dispose ();
                annotations.Clear ();
            }

            if (added.Count > 0) {
                mapView.AddAnnotations (added.ToArray ());
                foreach (var annotation in added)
                    annotation.Dispose ();
            }

            annotations = current;
        }
コード例 #19
0
 private void OnMapRegionChanged(object sender, MKMapViewChangeEventArgs e)
 {
     Render();
 }
コード例 #20
0
 /// <summary>
 /// When the camera region changed
 /// </summary>
 /// <param name="sender">Event sender</param>
 /// <param name="e">Event Arguments</param>
 private void OnMapRegionChanged(object sender, MKMapViewChangeEventArgs e)
 {
     this.FormsMap.MapCenter = this.Map.CenterCoordinate.ToPosition();
 }
コード例 #21
0
 void _mapView_RegionChanged(object sender, MKMapViewChangeEventArgs e)
 {
     UpdateHeatMap();
 }