protected void AgregoMapa() { map.MapType = MKMapType.Standard; map.Bounds = UIScreen.MainScreen.Bounds; //full screen baby map.ShowsUserLocation = false; MKReverseGeocoder geo = new MKReverseGeocoder(locationManager.Location.Coordinate); CLGeocoder geocoder = new CLGeocoder(); Task.Factory.StartNew(async() => { var res = await geocoder.ReverseGeocodeLocationAsync(locationManager.Location); Console.WriteLine(res[0].AdministrativeArea); pais = res[0].Country; ciudad = res[0].Locality; }); // centro el mapa y pongo el zoom en la region mapCenter = new CLLocationCoordinate2D(locationManager.Location.Coordinate.Latitude, locationManager.Location.Coordinate.Longitude); var mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 2000, 2000); map.CenterCoordinate = mapCenter; map.Region = mapRegion; }
/// <summary> /// Exposed by MonoTouch, just override to make it work /// </summary> public override void FailedWithError (MKReverseGeocoder gc, NSError error) { if (OnFailedWithError == null) { Util.Log("Reverse Geocoder failed"); } else OnFailedWithError(gc, error); }
/// <summary> /// When the reverse geocode finds a location, it calls this method /// which puts the placemark on the map as an Annotation /// </summary> public override void FoundWithPlacemark (MKReverseGeocoder geocoder, MKPlacemark placemark) { if (OnFoundWithPlacemark == null) { try { _MapPresenter.MapView.AddAnnotationObject (placemark); } catch (Exception ex) { Console.WriteLine ("FoundWithPlacemark" + ex.Message); } } else OnFoundWithPlacemark(geocoder, placemark); }
void IReverseGeo.HandleGeoCoderDelOnFoundWithPlacemark (MKReverseGeocoder arg1, MKPlacemark placemark) { }
/// <summary> /// MKReverseGeocoderDelegate calls this method when it finds a match /// for the latitude,longitude passed to MKReverseGeocoder() constructor /// </summary> public override void FoundWithPlacemark(MKReverseGeocoder reverseGeoCoder, MKPlacemark placeMark) { #if DEBUG SystemLogger.Log (SystemLogger.Module.PLATFORM, "Inside FoundWithPlacemark "); #endif geoDecoderAttributes.AdditionalStreetLevelInfo = placeMark.SubThoroughfare; geoDecoderAttributes.StreetAddress = placeMark.Thoroughfare; geoDecoderAttributes.Locality = placeMark.Locality; geoDecoderAttributes.AdditionalCityLevelInfo = placeMark.SubLocality; geoDecoderAttributes.Country = placeMark.Country; geoDecoderAttributes.CountryCode = placeMark.CountryCode; geoDecoderAttributes.PostalCode = placeMark.PostalCode; geoDecoderAttributes.AdministrativeArea = placeMark.AdministrativeArea; geoDecoderAttributes.SubAdministrativeArea = placeMark.SubAdministrativeArea; }
/// <summary> /// Show a message if the MKReverseGeocoder says so /// </summary> public override void FailedWithError(MKReverseGeocoder gc, NSError e) { SystemLogger.Log (SystemLogger.Module.PLATFORM, e.ToString ()); SystemLogger.Log (SystemLogger.Module.PLATFORM, e.LocalizedDescription); // PBRequesterErrorDomain error 6001 occurs when too many requests have been sent }
public void HandleGeoCoderDelOnFoundWithPlacemark (MKReverseGeocoder arg1, MKPlacemark placemark) { SetPlacemark(placemark); }
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { var vc = new MapKitViewController(this) { Autorotate = dvc.Autorotate }; if (MapView == null) { MapView = new MKMapView() { BackgroundColor = UIColor.White, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight }; } MapView.Frame = new CGRect(UIScreen.MainScreen.ApplicationFrame.Left, UIScreen.MainScreen.ApplicationFrame.Top - 20, UIScreen.MainScreen.ApplicationFrame.Right, UIScreen.MainScreen.ApplicationFrame.Bottom - 20); if (mkHandleGetViewForAnnotation != null) { MapView.GetViewForAnnotation = delegate(MKMapView mapView, IMKAnnotation annotation) { return(mkHandleGetViewForAnnotation(mapView, annotation)); }; } if (mkHandleMapViewCalloutAccessoryControlTapped != null) { MapView.CalloutAccessoryControlTapped += mkHandleMapViewCalloutAccessoryControlTapped; } if (mkHandleMapViewDidSelectAnnotationView != null) { MapView.DidSelectAnnotationView += mkHandleMapViewDidSelectAnnotationView; } if (mkAnnotationObjects != null) { MapView.AddAnnotations(mkAnnotationObjects); } MapView.WillStartLoadingMap += delegate(object sender, EventArgs e) { NetworkActivity = true; }; MapView.MapLoaded += delegate(object sender, EventArgs e) { NetworkActivity = false; }; MapView.LoadingMapFailed += delegate(object sender, NSErrorEventArgs e) { // Display an error of sorts }; if (ReverseGeocoderDelegate != null) { if (MapView != null) { MapView.DidUpdateUserLocation += delegate(object sender, MKUserLocationEventArgs e) { if (MapView != null) { var ul = MapView.UserLocation.Location; if (ul != null) // May be null if user has not given permission { var gc = new MKReverseGeocoder(ul.Coordinate); gc.Delegate = ReverseGeocoderDelegate; gc.Start(); } } }; } } MapView.ShowsUserLocation = true; vc.NavigationItem.Title = Caption; vc.View.AddSubview(MapView); dvc.ActivateController(vc); }
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path) { var vc = new MapKitViewController (this) { Autorotate = dvc.Autorotate }; if ( MapView == null ) { MapView = new MKMapView(){ BackgroundColor = UIColor.White, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight }; } MapView.Frame = new CGRect(UIScreen.MainScreen.ApplicationFrame.Left, UIScreen.MainScreen.ApplicationFrame.Top - 20, UIScreen.MainScreen.ApplicationFrame.Right, UIScreen.MainScreen.ApplicationFrame.Bottom - 20); if (mkHandleGetViewForAnnotation != null ) { MapView.GetViewForAnnotation = delegate(MKMapView mapView, IMKAnnotation annotation) { return mkHandleGetViewForAnnotation(mapView, annotation); }; } if ( mkHandleMapViewCalloutAccessoryControlTapped != null ) { MapView.CalloutAccessoryControlTapped += mkHandleMapViewCalloutAccessoryControlTapped; } if (mkHandleMapViewDidSelectAnnotationView != null) { MapView.DidSelectAnnotationView += mkHandleMapViewDidSelectAnnotationView; } if ( mkAnnotationObjects != null ) { MapView.AddAnnotations(mkAnnotationObjects); } MapView.WillStartLoadingMap += delegate(object sender, EventArgs e) { NetworkActivity = true; }; MapView.MapLoaded += delegate(object sender, EventArgs e) { NetworkActivity = false; }; MapView.LoadingMapFailed += delegate(object sender, NSErrorEventArgs e) { // Display an error of sorts }; if ( ReverseGeocoderDelegate != null ) { if ( MapView != null ) { MapView.DidUpdateUserLocation += delegate(object sender, MKUserLocationEventArgs e) { if ( MapView != null ) { var ul = MapView.UserLocation.Location; if ( ul != null ) // May be null if user has not given permission { var gc = new MKReverseGeocoder(ul.Coordinate); gc.Delegate = ReverseGeocoderDelegate; gc.Start(); } } }; } } MapView.ShowsUserLocation = true; vc.NavigationItem.Title = Caption; vc.View.AddSubview(MapView); dvc.ActivateController (vc); }