/// <summary> /// Load the map data from the properties retreived /// </summary> private void LoadMapData() { // value to determin where to zoom in var topLeft = new CLLocationCoordinate2D(-90, 180); var bottomRight = new CLLocationCoordinate2D(90, -180); // loop through all the properties and add them to the list foreach (var item in Properties) { // create the pin and add the annoation var pin = new HeritagePropertyAnnotation(item); _mapView.AddAnnotation(pin); // determin the topleft and right topLeft.Longitude = Math.Min(topLeft.Longitude, pin.Coordinate.Longitude); topLeft.Latitude = Math.Max(topLeft.Latitude, pin.Coordinate.Latitude); bottomRight.Longitude = Math.Max(bottomRight.Longitude, pin.Coordinate.Longitude); bottomRight.Latitude = Math.Min(bottomRight.Latitude, pin.Coordinate.Latitude); } // zoom in on the annotations var region = new MKCoordinateRegion(); region.Center = new CLLocationCoordinate2D( topLeft.Latitude - (topLeft.Latitude - bottomRight.Latitude) * 0.5, topLeft.Longitude + (bottomRight.Longitude - topLeft.Longitude) * 0.5); region.Span.LatitudeDelta = Math.Abs(topLeft.Latitude - bottomRight.Latitude) * 1.1; region.Span.LongitudeDelta = Math.Abs(bottomRight.Longitude - topLeft.Longitude) * 1.1; // set the region region = _mapView.RegionThatFits(region); _mapView.SetRegion(region, true); }
public void ZoomToCurrentLocation(MKMapView map, CLLocationManager LM) { var target = new CLLocationCoordinate2D(LM.Location.Coordinate.Latitude, LM.Location.Coordinate.Longitude); var currentregion = MKCoordinateRegion.FromDistance(target, 15000, 15000); map.SetRegion(currentregion, animated: true); }
public override void ViewDidLoad() { var mapView = new MKMapView(); mapView.Delegate = new MyDelegate(); View = mapView; base.ViewDidLoad(); var firstViewModel = (FirstViewModel) ViewModel; var helenAnnotation = new ZombieAnnotation(firstViewModel.Helen); var keithAnnotation = new ZombieAnnotation(firstViewModel.Keith); mapView.AddAnnotation(helenAnnotation); mapView.AddAnnotation(keithAnnotation); mapView.SetRegion(MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D(firstViewModel.Helen.Location.Lat, firstViewModel.Helen.Location.Lng), 20000, 20000), true); var button = new UIButton(UIButtonType.RoundedRect); button.Frame = new RectangleF(10, 10, 300, 40); button.SetTitle("move", UIControlState.Normal); Add(button); var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>(); set.Bind(button).To(vm => vm.MoveCommand); set.Bind(helenAnnotation).For(a => a.Location).To(vm => vm.Helen.Location); set.Bind(keithAnnotation).For(a => a.Location).To(vm => vm.Keith.Location); set.Apply(); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow(UIScreen.MainScreen.Bounds); // Create the 'Shows' tab. dvc1 = new DialogViewController(null) { Root = new RootElement("") { new Section(), new Section(), new Section(), new Section() { new StringElement("House of Cards"), new StringElement("Game of Thrones"), new StringElement("Person of Interest") } } }; // Create the 'Games' tab. dvc2 = new DialogViewController(null) { Root = new RootElement("") { new Section(), new Section(), new Section(), new Section() { new StringElement("Braid"), new StringElement("Super Meat Boy"), new StringElement("Fez") } } }; // Create the 'Atlanta' tab. var mapView = new MKMapView(UIScreen.MainScreen.Bounds); var atlanta = new MKCoordinateRegion(new CLLocationCoordinate2D(33.748893, -84.388046), new MKCoordinateSpan(0.35, 0.35)); mapView.SetRegion(atlanta, false); mapViewController = new UIViewController(); mapViewController.View.Bounds = UIScreen.MainScreen.Bounds; mapViewController.View.AddSubview(mapView); // Create and display the floating tab bar controller. ftbc = new FloatingTabBarController() { TabTitles = new List <string> () { "Shows", "Games", "Atlanta" }, ViewControllers = new List <UIViewController> () { dvc1, dvc2, mapViewController } }; window.RootViewController = ftbc; window.MakeKeyAndVisible(); return(true); }
public void CenterToCurrentLocation(MKMapView map, Event currentEvent) { var target = new CLLocationCoordinate2D(currentEvent.Lat, currentEvent.Long); var currentregion = MKCoordinateRegion.FromDistance(target, 9000, 9000); map.SetRegion(currentregion, animated: false); }
private void UserLocationSubscription(Location location) { if (location == lastLocation) { return; } lastLocation = location; Position position = new Position(location.Latitude, location.Longitude); if (formsMap.Pins.Any()) { formsMap.Pins[0].Position = position; } else { formsMap.Pins.Add(new Pin { Position = position, Label = "UserLocation", Type = PinType.Generic }); } if (userAnnotationView != null) { userAnnotationView.Transform = CGAffineTransform.MakeRotation((float)UnitConverters.DegreesToRadians(lastLocation?.Course ?? 0)); } //formsMap.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromKilometers(1))); nativeMap.SetRegion(MKCoordinateRegion.FromDistance(new CLLocationCoordinate2D(position.Latitude, position.Longitude), 1000, 1000), false); }
public LocationPrivacyViewController() { CheckAccess = LocationAccessStatus; RequestAccess = RequestLocationServicesAuthorization; locationManager = new CLLocationManager(); //If previously allowed, start location manager if (CLLocationManager.Status == CLAuthorizationStatus.AuthorizedWhenInUse) { locationManager.StartUpdatingLocation(); } locationManager.Failed += delegate { locationManager.StopUpdatingLocation(); }; locationManager.LocationsUpdated += delegate { var loc = locationManager.Location.ToString(); locationMessage.Text = loc; //MapView MKCoordinateRegion region = new MKCoordinateRegion(locationManager.Location.Coordinate, new MKCoordinateSpan(0.1, 0.1)); mapView.SetRegion(region, true); }; locationManager.AuthorizationChanged += delegate(object sender, CLAuthorizationChangedEventArgs e) { accessStatus.Text = e.Status.ToString(); if (e.Status == CLAuthorizationStatus.AuthorizedWhenInUse) { mapView.ShowsUserLocation = true; locationManager.StartUpdatingLocation(); } }; }
public override void ViewDidLoad() { var mapView = new MKMapView(); mapView.Delegate = new MyDelegate(); View = mapView; base.ViewDidLoad(); // ios7 layout if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; var secondViewModel = (SecondViewModel)ViewModel; var hanAnnotation = new ZombieAnnotation(secondViewModel.Han); mapView.AddAnnotation(hanAnnotation); mapView.SetRegion(MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D(secondViewModel.Han.Location.Lat, secondViewModel.Han.Location.Lng), 20000, 20000), true); var button = new UIButton(UIButtonType.RoundedRect); button.Frame = new RectangleF(10, 10, 300, 40); button.SetTitle("move", UIControlState.Normal); Add(button); var set = this.CreateBindingSet<SecondView, Core.ViewModels.SecondViewModel>(); set.Bind(hanAnnotation).For(a => a.Location).To(vm => vm.Han.Location); set.Bind(button).For("Title").To(vm => vm.Han.Location); set.Apply(); }
public override void ViewDidLoad() { var mapView = new MKMapView(); mapView.Delegate = new MyDelegate(); View = mapView; base.ViewDidLoad(); // ios7 layout if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) { EdgesForExtendedLayout = UIRectEdge.None; } var thirdViewModel = (ThirdViewModel)ViewModel; _zombieManager = new ZombieManager(mapView); mapView.SetRegion(MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D(51.4, 0.4), 50000, 50000), true); var set = this.CreateBindingSet <ThirdView, Core.ViewModels.ThirdViewModel>(); set.Bind(_zombieManager).For(z => z.ItemsSource).To(vm => vm.Yarp); set.Apply(); }
private void SetMapRegion(CLLocationCoordinate2D centerCoordinate) { var span = new MKCoordinateSpan(spanDelta, spanDelta); var region = new MKCoordinateRegion(centerCoordinate, span); map.SetRegion(region, false); }
public GeocoderViewControllerAdapter(MvxViewController viewController, MKMapView mapView, Action <string> addressChanged) : base(viewController) { _geocoder = new CLGeocoder(); _addressChanged = addressChanged; mapView.RegionChanged += MapView_RegionChanged; mapView.SetRegion(new MapKit.MKCoordinateRegion(new CoreLocation.CLLocationCoordinate2D(45.5316085, -73.6227476), new MapKit.MKCoordinateSpan(0.01, 0.01)), animated: true); }
public GeocoderViewControllerAdapter(MvxViewController viewController, MKMapView mapView, Action<string> addressChanged) : base(viewController) { _geocoder = new CLGeocoder (); _addressChanged = addressChanged; mapView.RegionChanged += MapView_RegionChanged; mapView.SetRegion (new MapKit.MKCoordinateRegion (new CoreLocation.CLLocationCoordinate2D (45.5316085, -73.6227476), new MapKit.MKCoordinateSpan (0.01, 0.01)), animated: true); }
void OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e) { locationMessage.Text = locationManager.Location.ToString(); //MapView MKCoordinateRegion region = new MKCoordinateRegion(locationManager.Location.Coordinate, new MKCoordinateSpan(0.1, 0.1)); mapView.SetRegion(region, true); }
public void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation) { if (!isZoomedIn) { var mapRegion = new MKCoordinateRegion(mapView.UserLocation.Coordinate, new MKCoordinateSpan(0.001, 0.001)); mapView.SetRegion(mapRegion, true); isZoomedIn = true; } }
/// <summary> /// Center the map when the user is located /// </summary> public override void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation) { if (userLocation != null) { var span = new MKCoordinateSpan(15, 15); var region = new MKCoordinateRegion(userLocation.Coordinate, span); mapView.SetRegion(region, true); } }
public void SetRegion(MapCoordinate centerCoord, double visibleMeters, bool animated = false) { setRegionCoord = centerCoord; setRegionDistance = visibleMeters; if (map == null) { return; } map.SetRegion(MKCoordinateRegion.FromDistance(GetCoord(centerCoord), visibleMeters, visibleMeters), animated); }
public void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation) { Console.WriteLine("Weak Lat: {0}, Long: {1}, Alt: {2}", userLocation.Coordinate.Latitude, userLocation.Coordinate.Longitude, userLocation.Location.Altitude); currLocation = userLocation.Coordinate; if (firstLaunch) { mapView.SetRegion(MKCoordinateRegion.FromDistance(currLocation, 250, 250), true); firstLaunch = false; } else mapView.SetCenterCoordinate(currLocation, true); }
void CreateMapView() { if (_mapView != null) return; _mapView = new MKMapView {ShowsUserLocation = true, GetViewForAnnotation = GetViewForAnnotation}; View = _mapView; var visibleRegion = BuildVisibleRegion(_centerCoordinate); _mapView.SetRegion(visibleRegion, animated: true); }
public MapOverlay() : base(new RectangleF(0, 0, 144, 144)) { map = new MKMapView(Bounds) { AutoresizingMask = UIViewAutoresizing.FlexibleDimensions, ShowsUserLocation = true, MapType = MKMapType.Satellite, }; map.SetRegion(MKCoordinateRegion.FromDistance(new CLLocationCoordinate2D(47, -122), 1, 1), false); map.UserTrackingMode = MKUserTrackingMode.FollowWithHeading; Alpha = 0.5f; AddSubview(map); }
public static void SetCenterCoordinate(MKMapView MapToCenter, CLLocationCoordinate2D centerCoordinate, int zoomLevel, bool animated) { // clamp large numbers to 28 zoomLevel = Math.Min(zoomLevel, 28); //zoomLevel = 80; // use the zoom level to compute the region MKCoordinateSpan span = CoordinateSpanWithMapView(MapToCenter, centerCoordinate, zoomLevel); MKCoordinateRegion region = new MKCoordinateRegion(centerCoordinate, span); // set the region like normal MapToCenter.SetRegion(region, animated); }
public MapOverlay() : base(new RectangleF (0, 0, 144, 144)) { map = new MKMapView (Bounds) { AutoresizingMask = UIViewAutoresizing.FlexibleDimensions, ShowsUserLocation = true, MapType = MKMapType.Satellite, }; map.SetRegion (MKCoordinateRegion.FromDistance (new CLLocationCoordinate2D (47,-122), 1, 1), false); map.UserTrackingMode = MKUserTrackingMode.FollowWithHeading; Alpha = 0.5f; AddSubview (map); }
public void UpdateLocation(CLLocationCoordinate2D newLocation, bool animated) { var span = new MKCoordinateSpan(0.1, 0.1); var region = new MKCoordinateRegion(newLocation, span); _mapView.SetRegion(region, animated); if (_geocodeAnnotation != null) { _mapView.RemoveAnnotation(_geocodeAnnotation); } _geocodeAnnotation = new MapViewAnnotation(newLocation); _mapView.AddAnnotationObject(_geocodeAnnotation); }
public override void ViewDidLoad() { base.ViewDidLoad(); RouteViews = new Dictionary <string, CSRouteView>(); // load the points from local resource (file) var filePath = NSBundle.MainBundle.PathForResource("route", "csv", "MapLineSharp", ""); var fileContents = System.IO.File.ReadAllText(filePath); var pointStrings = fileContents.Split('\n'); var points = new List <CLLocation>(); foreach (var ps in pointStrings) { // break the string down into latitude and longitude fields var latLonArr = ps.Split(','); double latitude = Convert.ToDouble(latLonArr[0]); double longitude = Convert.ToDouble(latLonArr[1]); CLLocation currentLocation = new CLLocation(latitude, longitude); points.Add(currentLocation); } // // Create our map view and add it as as subview. // _mapView = new MKMapView(); _mapView.Frame = new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height); View.AddSubview(_mapView); _mapView.Delegate = new MapViewDelegate(this); // CREATE THE ANNOTATIONS AND ADD THEM TO THE MAP // first create the route annotation CSRouteAnnotation routeAnnotation = new CSRouteAnnotation(points); _mapView.AddAnnotation(routeAnnotation); CSMapAnnotation annotation = null; annotation = new CSMapAnnotation(points[0].Coordinate, CSMapAnnotationType.Start, "Start Point"); _mapView.AddAnnotation(annotation); annotation = new CSMapAnnotation(points[points.Count - 1].Coordinate, CSMapAnnotationType.End, "End Point"); _mapView.AddAnnotation(annotation); //TODO:create the image annotation _mapView.SetRegion(routeAnnotation.Region, false); }
public void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation) { Console.WriteLine("Weak Lat: {0}, Long: {1}, Alt: {2}", userLocation.Coordinate.Latitude, userLocation.Coordinate.Longitude, userLocation.Location.Altitude); currLocation = userLocation.Coordinate; if (firstLaunch) { mapView.SetRegion(MKCoordinateRegion.FromDistance(currLocation, 250, 250), true); firstLaunch = false; } else { mapView.SetCenterCoordinate(currLocation, true); } }
void ZoomToUserLocation(MKMapView mapView, MKUserLocation l) { var span = new MKCoordinateSpan { LatitudeDelta = 0.1, LongitudeDelta = 0.1, }; var region = new MKCoordinateRegion { Center = l.Coordinate, Span = span, }; mapView.SetRegion (region, true); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); // Create the 'Shows' tab. dvc1 = new DialogViewController (null) { Root = new RootElement ("") { new Section (), new Section (), new Section (), new Section () { new StringElement ("House of Cards"), new StringElement ("Game of Thrones"), new StringElement ("Person of Interest") } } }; // Create the 'Games' tab. dvc2 = new DialogViewController (null) { Root = new RootElement ("") { new Section (), new Section (), new Section (), new Section () { new StringElement ("Braid"), new StringElement ("Super Meat Boy"), new StringElement ("Fez") } } }; // Create the 'Atlanta' tab. var mapView = new MKMapView (UIScreen.MainScreen.Bounds); var atlanta = new MKCoordinateRegion (new CLLocationCoordinate2D (33.748893, -84.388046), new MKCoordinateSpan (0.35, 0.35)); mapView.SetRegion (atlanta, false); mapViewController = new UIViewController (); mapViewController.View.Bounds = UIScreen.MainScreen.Bounds; mapViewController.View.AddSubview (mapView); // Create and display the floating tab bar controller. ftbc = new FloatingTabBarController () { TabTitles = new List<string> () { "Shows", "Games", "Atlanta" }, ViewControllers = new List<UIViewController> () { dvc1, dvc2, mapViewController } }; window.RootViewController = ftbc; window.MakeKeyAndVisible (); return true; }
public override void ViewDidLoad() { base.ViewDidLoad(); var map = new MKMapView(new RectangleF(20, 166, 280, 192)); this.View.Add(map); map.ShowsUserLocation = true; map.MapType = MKMapType.Standard; map.Delegate = new MapViewDelegate(); var location = new CLLocationCoordinate2D(ViewModel.Latitude, ViewModel.Longitude); //map.SetCenterCoordinate(location, true); map.SetRegion(new MKCoordinateRegion(location, new MKCoordinateSpan(0.1, 0.1)), true); var annotation = new MyAnnotation( location , ViewModel.SharedTextSource.GetText("AppTitle") , ViewModel.Name); map.AddAnnotationObject(annotation); Button1.SetImage(UIImage.FromFile("ConfResources/Images/appbar.link.png"), UIControlState.Normal); Button2.SetImage(UIImage.FromFile("ConfResources/Images/appbar.phone.png"), UIControlState.Normal); Button3.SetImage(UIImage.FromFile("ConfResources/Images/appbar.feature.email.rest.png"), UIControlState.Normal); this.AddBindings(new Dictionary <object, string>() { { Label1, "{'Text':{'Path':'Name'}}" }, { Button1, "{'Title':{'Path':'Address'}}" }, { Button2, "{'Title':{'Path':'Phone'}}" }, { Button3, "{'Title':{'Path':'Email'}}" }, }); this.AddBindings(new Dictionary <object, string>() { { Button1, "{'TouchDown':{'Path':'WebPageCommand'}}" }, { Button2, "{'TouchDown':{'Path':'PhoneCommand'}}" }, { Button3, "{'TouchDown':{'Path':'EmailCommand'}}" }, }); NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Tweet", UIBarButtonItemStyle.Bordered, (sender, e) => ViewModel.ShareGeneralCommand.Execute()), false); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. map = new MKMapView(UIScreen.MainScreen.Bounds); var coordinate = new CLLocationCoordinate2D(23.674764, 120.92); var span = new MKCoordinateSpan(3, 3); var region = new MKCoordinateRegion(coordinate, span); map.SetRegion(region, true); map.ZoomEnabled = false; map.ScrollEnabled = false; map.Delegate = new MyMapDelegate(this); View = map; GetMyMarkers(); }
//zoom public void ZoomIn() { //Zoom in // user location var userCoord = new CLLocationCoordinate2D { Latitude = _userLocation.Latitude, Longitude = _userLocation.Longitude }; // tracking location var trackCoord = new CLLocationCoordinate2D { Latitude = _trackCoordinate.Latitude, Longitude = _trackCoordinate.Longitude }; List <CLLocationCoordinate2D> annotations = new List <CLLocationCoordinate2D> (); annotations.Add(userCoord); annotations.Add(trackCoord); var tl = new CLLocationCoordinate2D(-90, 180); //top left var br = new CLLocationCoordinate2D(90, -180); //bottom right foreach (var anno in annotations) { tl.Longitude = Math.Min(tl.Longitude, anno.Longitude); tl.Latitude = Math.Max(tl.Latitude, anno.Latitude); br.Longitude = Math.Max(br.Longitude, anno.Longitude); br.Latitude = Math.Min(br.Latitude, anno.Latitude); } var center = new CLLocationCoordinate2D { Latitude = tl.Latitude - (tl.Latitude - br.Latitude) * 0.5, Longitude = tl.Longitude + (br.Longitude - tl.Longitude) * 0.5 }; var span = new MKCoordinateSpan { LatitudeDelta = Math.Abs(tl.Latitude - br.Latitude) * 1.6, LongitudeDelta = Math.Abs(br.Longitude - tl.Longitude) * 1.6 }; var region = new MKCoordinateRegion { Center = center, Span = span }; region = _mapView.RegionThatFits(region); _mapView.SetRegion(region, true); }
public void ShowUserAndDestinationOnMap() { var maxLat = Math.Max(_userLocation.Latitude, _destination.Latitude); var maxLon = Math.Max(_userLocation.Longitude, _destination.Longitude); var minLat = Math.Min(_userLocation.Latitude, _destination.Latitude); var minLon = Math.Min(_userLocation.Longitude, _destination.Longitude); var mapMargin = 1.5; var leastCoordspan = 0.005; var span_x = Math.Max(leastCoordspan, Math.Abs(maxLat - minLat) * mapMargin); var span_y = Math.Max(leastCoordspan, Math.Abs(maxLon - minLon) * mapMargin); var span = new MKCoordinateSpan(span_x, span_y); var center = new CLLocationCoordinate2D((maxLat + minLat) / 2, (maxLon + minLon) / 2); var region = new MKCoordinateRegion(center, span); _mapView.SetRegion(_mapView.RegionThatFits(region), true); }
public override void ViewDidLoad() { base.ViewDidLoad(); var map = new MKMapView(new RectangleF(20, 166, 280, 192)); this.View.Add(map); map.ShowsUserLocation = true; map.MapType = MKMapType.Standard; map.Delegate = new MapViewDelegate(); var location = new CLLocationCoordinate2D(ViewModel.Latitude, ViewModel.Longitude); //map.SetCenterCoordinate(location, true); map.SetRegion(new MKCoordinateRegion(location, new MKCoordinateSpan(0.1, 0.1)), true); var annotation = new MyAnnotation( location , ViewModel.SharedTextSource.GetText("AppTitle") , ViewModel.Name); map.AddAnnotationObject(annotation); Button1.SetImage(UIImage.FromFile("ConfResources/Images/appbar.link.png"), UIControlState.Normal); Button2.SetImage(UIImage.FromFile("ConfResources/Images/appbar.phone.png"), UIControlState.Normal); Button3.SetImage(UIImage.FromFile("ConfResources/Images/appbar.feature.email.rest.png"), UIControlState.Normal); this.AddBindings(new Dictionary<object, string>() { {Label1,"Text Name"}, {Button1,"Title Address"}, {Button2,"Title Phone"}, {Button3,"Title Email"}, }); this.AddBindings(new Dictionary<object, string>() { {Button1,"TouchUpInside WebPageCommand"}, {Button2,"TouchUpInside PhoneCommand"}, {Button3,"TouchUpInside EmailCommand"}, }); NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Tweet", UIBarButtonItemStyle.Bordered, (sender, e) => ViewModel.DoShareGeneral()), false); }
public override void ViewDidLoad() { var mapView = new MKMapView(); mapView.Delegate = new MyDelegate(); View = mapView; base.ViewDidLoad(); var mapViewModel = (MapViewModel)ViewModel; var keithAnnotation = new ItemAnnotation(mapViewModel); mapView.AddAnnotation(keithAnnotation); mapView.SetRegion(MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D(mapViewModel.Latitude, mapViewModel.Longitude), 200, 200), true); }
/// <summary> /// Callback for when the user's location is found, we want to zoom in when this happens /// </summary> public override void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation) { var placemark = mapView.Annotations.OfType <MKPlacemark>().FirstOrDefault(); if (placemark != null && userLocation.Location != null) { //Calculate the mid point between 2 locations double latitude = Math.Min(userLocation.Coordinate.Latitude, placemark.Coordinate.Latitude) + Math.Abs(userLocation.Coordinate.Latitude - placemark.Coordinate.Latitude) / 2; double longitude = Math.Min(userLocation.Coordinate.Longitude, placemark.Coordinate.Longitude) + Math.Abs(userLocation.Coordinate.Longitude - placemark.Coordinate.Longitude) / 2; var midPoint = new CLLocationCoordinate2D(latitude, longitude); //Display the distance between the points (and multiple by 1.05 to get space on the edges) var distance = userLocation.Location.DistanceFrom(placemark.Location) * 1.05; var region = MKCoordinateRegion.FromDistance(midPoint, distance, distance); mapView.SetRegion(region, true); } }
public void BindToNative(object native, BindOptions options = BindOptions.None) { UnbindFromNative(); map = ViewHelpers.GetView <MKMapView> (native); singleTap = new UITapGestureRecognizer(HandleTap) { NumberOfTapsRequired = 1, }; map.AddGestureRecognizer(singleTap); doubleTap = new UITapGestureRecognizer { NumberOfTapsRequired = 2, }; map.AddGestureRecognizer(doubleTap); singleTap.RequireGestureRecognizerToFail(doubleTap); map.SetRegion(MKCoordinateRegion.FromDistance( GetCoord(setRegionCoord), setRegionDistance, setRegionDistance), false); }
public override void ViewDidLoad() { var mapView = new MKMapView(); mapView.Delegate = new MyDelegate(); View = mapView; base.ViewDidLoad(); var thirdViewModel = (ThirdViewModel)ViewModel; _zombieManager = new ZombieManager(mapView); mapView.SetRegion(MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D(51.4, 0.4), 50000, 50000), true); var set = this.CreateBindingSet<ThirdView, Core.ViewModels.ThirdViewModel>(); set.Bind(_zombieManager).For(z => z.ItemsSource).To(vm => vm.Yarp); set.Apply(); }
public override void ViewDidLoad() { var mapView = new MKMapView(); mapView.Delegate = new MyDelegate(); View = mapView; base.ViewDidLoad(); // ios7 layout if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) { EdgesForExtendedLayout = UIRectEdge.None; } var firstViewModel = (FirstViewModel)ViewModel; var helenAnnotation = new ZombieAnnotation(firstViewModel.Helen); var keithAnnotation = new ZombieAnnotation(firstViewModel.Keith); mapView.AddAnnotation(helenAnnotation); mapView.AddAnnotation(keithAnnotation); mapView.SetRegion(MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D(firstViewModel.Helen.Location.Lat, firstViewModel.Helen.Location.Lng), 20000, 20000), true); var button = new UIButton(UIButtonType.RoundedRect); button.Frame = new RectangleF(10, 10, 300, 40); button.SetTitle("move", UIControlState.Normal); Add(button); var set = this.CreateBindingSet <FirstView, Core.ViewModels.FirstViewModel>(); set.Bind(button).To(vm => vm.MoveCommand); set.Bind(helenAnnotation).For(a => a.Location).To(vm => vm.Helen.Location); set.Bind(keithAnnotation).For(a => a.Location).To(vm => vm.Keith.Location); set.Apply(); }
public UIMapView(ElementChangedEventArgs <MapView> e) { MKMapView mapView1; MKCoordinateRegion region; CLLocationCoordinate2D center; MKCoordinateSpan span; WMSTileOverlay overlay1; span = new MKCoordinateSpan(0.2, 0.2); center = new CLLocationCoordinate2D(44.837789, -0.58918); region = new MKCoordinateRegion(center, span); mapView1 = new MKMapView(); mapView1.MapType = MKMapType.Standard; mapView1.SetRegion(region, false); //mapView1.Frame = this.Bounds; this.AddSubview(mapView1); overlay1 = new WMSTileOverlay("https://data.bordeaux-metropole.fr/wms?key=QHUHHRI7HD&LAYERS=CI_TRAFI_L&FORMAT=image%2Fpng&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&WIDTH=256&HEIGHT=256"); mapView1.OverlayRenderer = (MKMapView mapView, IMKOverlay overlay) => { var _tileOverlay = overlay as MKTileOverlay; if (_tileOverlay != null) { return(new MKTileOverlayRenderer(_tileOverlay)); } return(new MKOverlayRenderer(overlay)); }; mapView1.AddOverlay(overlay1); e.NewElement.SizeChanged += (object sender, EventArgs ev) => { MapView mapview2 = sender as MapView; mapView1.Frame = new CoreGraphics.CGRect(0, 0, mapview2.Width, mapview2.Height); }; }
public override void ViewDidLoad() { var mapView = new MKMapView(); mapView.Delegate = new MyDelegate(); View = mapView; base.ViewDidLoad(); // ios7 layout if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; var thirdViewModel = (ThirdViewModel)ViewModel; _zombieManager = new ZombieManager(mapView); mapView.SetRegion(MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D(51.4, 0.4), 50000, 50000), true); var set = this.CreateBindingSet<ThirdView, Core.ViewModels.ThirdViewModel>(); set.Bind(_zombieManager).For(z => z.ItemsSource).To(vm => vm.Yarp); set.Apply(); }
public override void ViewDidLoad() { base.ViewDidLoad(); navBar = new UINavigationBar(new RectangleF(0, 0, 320, 44)); var bbi = new UIBarButtonItem(UIImage.FromBundle("Images/slideout"), UIBarButtonItemStyle.Plain, (sender, e) => { AppDelegate.Current.FlyoutNavigation.ToggleMenu(); }); var rbi = new UIBarButtonItem(UIImage.FromBundle("Images/113-navigation"), UIBarButtonItemStyle.Plain, (sender, e) => { mapFlipViewController.Flip(); }); var item = new UINavigationItem("Location Map"); item.LeftBarButtonItem = bbi; item.RightBarButtonItem = rbi; var items = new UINavigationItem[] { item }; navBar.SetItems(items, false); mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF(0, 44, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); var topOfSegement = View.Frame.Height - 60; segmentedControl.Frame = new RectangleF(20, topOfSegement, 282, 30); segmentedControl.InsertSegment("Map", 0, false); segmentedControl.InsertSegment("Satellite", 1, false); segmentedControl.InsertSegment("Hybrid", 2, false); segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Bar; segmentedControl.TintColor = UIColor.DarkGray; segmentedControl.ValueChanged += delegate { if (segmentedControl.SelectedSegment == 0) { mapView.MapType = MonoTouch.MapKit.MKMapType.Standard; } else if (segmentedControl.SelectedSegment == 1) { mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite; } else if (segmentedControl.SelectedSegment == 2) { mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid; } }; mapView.Delegate = new MapViewDelegate(this); // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF(0, 44 + 50, View.Frame.Width, View.Frame.Height - 93); MKCoordinateSpan span = new MKCoordinateSpan(0.01, 0.01); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation.Location.To2D(), span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation.Location.To2D() , ConferenceLocation.Title , ConferenceLocation.Subtitle ); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.Purpose = "Show distance on map"; // also Info.plist locationManager.StartUpdatingLocation(); // Add the table view as a subview View.AddSubview(mapView); View.AddSubview(labelDistance); View.AddSubview(segmentedControl); // Add the 'info' button to flip var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290, 17, 20, 20); flipButton.Title(UIControlState.Normal); flipButton.TouchDown += delegate { mapFlipViewController.Flip(); }; View.AddSubview(flipButton); View.Add(navBar); }
public override void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation) { mapView.SetRegion(new MKCoordinateRegion(userLocation.Coordinate, new MKCoordinateSpan(0.1, 0.1)), true); }
static void MoveMapToLocation(MKMapView mapView, CLLocationCoordinate2D coordinates) { var mapSpan = new MKCoordinateSpan(MilesToLatitudeDegrees(2), MilesToLongitudeDegrees(2, coordinates.Latitude)); mapView.SetRegion(new MKCoordinateRegion(coordinates, mapSpan), true); }
/// <summary> /// Center the map when the user is located /// </summary> public override void DidUpdateUserLocation (MKMapView mapView, MKUserLocation userLocation) { if (userLocation != null) { var span = new MKCoordinateSpan (15, 15); var region = new MKCoordinateRegion (userLocation.Coordinate, span); mapView.SetRegion (region, true); } }
public static void SetZoom(this MKMapView mapView, int zoomLevel, bool animated = false) { var span = new MKCoordinateSpan(0, 360 / Math.Pow(2, zoomLevel) * mapView.Frame.Size.Width / 256); mapView.SetRegion(new MKCoordinateRegion(mapView.CenterCoordinate, span), animated); }
public override void ViewDidLoad() { base.ViewDidLoad (); RouteViews = new Dictionary<string,CSRouteView>(); // load the points from local resource (file) var filePath = NSBundle.MainBundle.PathForResource("route", "csv", "MapLineSharp",""); var fileContents = System.IO.File.ReadAllText(filePath); var pointStrings = fileContents.Split('\n'); var points = new List<CLLocation>(); foreach (var ps in pointStrings) { // break the string down into latitude and longitude fields var latLonArr = ps.Split(','); double latitude = Convert.ToDouble(latLonArr[0]); double longitude = Convert.ToDouble(latLonArr[1]); CLLocation currentLocation = new CLLocation(latitude, longitude); points.Add(currentLocation); } // // Create our map view and add it as as subview. // _mapView = new MKMapView(); _mapView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height); View.AddSubview(_mapView); _mapView.Delegate = new MapViewDelegate(this); // CREATE THE ANNOTATIONS AND ADD THEM TO THE MAP // first create the route annotation CSRouteAnnotation routeAnnotation = new CSRouteAnnotation(points); _mapView.AddAnnotation(routeAnnotation); CSMapAnnotation annotation = null; annotation = new CSMapAnnotation (points[0].Coordinate, CSMapAnnotationType.Start, "Start Point"); _mapView.AddAnnotation (annotation); annotation = new CSMapAnnotation (points[points.Count - 1].Coordinate, CSMapAnnotationType.End, "End Point"); _mapView.AddAnnotation (annotation); //TODO:create the image annotation _mapView.SetRegion (routeAnnotation.Region, false); }
public override void ViewDidLoad() { base.ViewDidLoad (); // no XIB ! mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF (10, 5, 292, 44), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; // Black looks good! this.View.BackgroundColor = UIColor.Black; var segmentedControl = new UISegmentedControl(); segmentedControl.Frame = new RectangleF(20, 360, 282,30); segmentedControl.InsertSegment("Map", 0, false); segmentedControl.InsertSegment("Satellite", 1, false); segmentedControl.InsertSegment("Hybrid", 2, false); segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Bar; segmentedControl.TintColor = UIColor.DarkGray; segmentedControl.ValueChanged += delegate { if (segmentedControl.SelectedSegment == 0) mapView.MapType = MonoTouch.MapKit.MKMapType.Standard; else if (segmentedControl.SelectedSegment == 1) mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite; else if (segmentedControl.SelectedSegment == 2) mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid; }; mapView.Delegate = new MapViewDelegate(this); // RegionChanged, GetViewForAnnotation // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF (0, 50, this.View.Frame.Width, this.View.Frame.Height - 50); //mapView.SetCenterCoordinate(confLoc, true); MKCoordinateSpan span = new MKCoordinateSpan(0.2,0.2); MKCoordinateRegion region = new MKCoordinateRegion(MyLocation,span); mapView.SetRegion(region, true); MyAnnotation a = new MyAnnotation(MyLocation , "Hero's Sports Bar" , "2855 N Power Rd, Mesa, Arizona" ); Console.WriteLine("This adds a custom placemark for the Conference Venue"); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.StartUpdatingLocation(); // Add the table view as a subview this.View.AddSubview(mapView); this.View.AddSubview(labelDistance); this.View.AddSubview(segmentedControl); // Add the 'info' button to flip Console.WriteLine("make flip button"); var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290,17,20,20); flipButton.Title (UIControlState.Normal); flipButton.TouchDown += delegate { _mfvc.Flip(); }; Console.WriteLine("flipbutton ready to add"); this.View.AddSubview(flipButton); }
public void BuildView() { if (mapView == null) { mapView = new MKMapView(); RectangleF frame = new RectangleF(0,0,320,367); mapView.Frame = frame; DV = new DistanceView(); frame = DV.View.Frame; //frame.Y = mapView.Frame.Bottom; frame.Y = -DV.View.Frame.Height; DV.View.Frame = frame; DV.TouchUpInside += delegate(object sender, EventArgs e) { RemoveRouteAnnotation(); HideDistanceView(); }; mapView.RegionWillChange += delegate(object sender, MKMapViewChangeEventArgs e) { if (routeView != null) { routeView.Hidden = true; } }; mapView.RegionChanged += delegate(object sender, MKMapViewChangeEventArgs e) { if (routeView != null) { routeView.Hidden = false; routeView.RegionChanged(); } }; mapView.GetViewForAnnotation = delegate(MKMapView mapViewForAnnotation, NSObject annotation) { if (annotation is MKUserLocation) return null; if (annotation is CycleAnnotation) { var mapAnnotation = annotation as CycleAnnotation; if (mapAnnotation == null) return null; MKPinAnnotationView pinView = (MKPinAnnotationView)mapViewForAnnotation.DequeueReusableAnnotation(MapPin); if (pinView == null) { pinView = new MKPinAnnotationView(mapAnnotation, MapPin); } else { pinView.Annotation = annotation; } int valueToCheck = 0; if (CurrentDisplayMode == DisplayMode.Bikes) { valueToCheck = mapAnnotation.Bike.BikesAvailable; } else { valueToCheck = mapAnnotation.Bike.DocksAvailable; } if ((valueToCheck < 5 && valueToCheck != -1)) { if (valueToCheck == 0) { pinView.PinColor = MKPinAnnotationColor.Red; } else { pinView.PinColor = MKPinAnnotationColor.Purple; } } else { pinView.PinColor = MKPinAnnotationColor.Green; } mapAnnotation.PinView = pinView; pinView.CanShowCallout = true; return pinView; } if (annotation is CSRouteAnnotation) { var routeAnnotation = annotation as CSRouteAnnotation; MKAnnotationView annotationView = null; if (annotationView == null) { routeView = new CSRouteView(new RectangleF (0,0, mapView.Frame.Size.Width, mapView.Frame.Size.Height)); routeView.Annotation = routeAnnotation; routeView.MapView = mapViewForAnnotation; annotationView = routeView; } return annotationView; } return null; }; List<MKAnnotation> locations = new List<MKAnnotation>(); double minLon = 200, minLat = 200, maxLon = -200, maxLat = -200; foreach(var bike in BikeLocation.AllBikes) { if (bike.Location.Longitude < minLon) minLon = bike.Location.Longitude; if (bike.Location.Latitude < minLat) minLat = bike.Location.Latitude; if (bike.Location.Longitude < maxLon) maxLon = bike.Location.Longitude; if (bike.Location.Latitude > maxLat) maxLat = bike.Location.Latitude; locations.Add(new CycleAnnotation(bike)); } if (locations.Count > 0) { mapView.AddAnnotation(locations.ToArray()); var tl = new CLLocationCoordinate2D(-90, 180); var br = new CLLocationCoordinate2D(90, -180); foreach(MKAnnotation an in mapView.Annotations) { tl.Longitude = Math.Min(tl.Longitude, an.Coordinate.Longitude); tl.Latitude = Math.Max(tl.Latitude, an.Coordinate.Latitude); br.Longitude = Math.Max(br.Longitude, an.Coordinate.Longitude); br.Latitude = Math.Min(br.Latitude, an.Coordinate.Latitude); } var center = new CLLocationCoordinate2D { Latitude = tl.Latitude - (tl.Latitude - br.Latitude) *0.5, Longitude = tl.Longitude - (tl.Longitude - br.Longitude) *0.5 }; var span = new MKCoordinateSpan { LatitudeDelta = Math.Abs(tl.Latitude - br.Latitude) *0.5, LongitudeDelta = Math.Abs(tl.Longitude - br.Longitude) *0.5 }; MKCoordinateRegion region = new MKCoordinateRegion (center, span ); region = mapView.RegionThatFits(region); mapView.SetRegion(region, true); } mapView.ShowsUserLocation = true; View.AddSubview(mapView); } }
/// <summary> /// Callback for when the user's location is found, we want to zoom in when this happens /// </summary> public override void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation) { var placemark = mapView.Annotations.OfType<MKPlacemark>().FirstOrDefault (); if (placemark != null && userLocation.Location != null) { //Calculate the mid point between 2 locations double latitude = Math.Min (userLocation.Coordinate.Latitude, placemark.Coordinate.Latitude) + Math.Abs (userLocation.Coordinate.Latitude - placemark.Coordinate.Latitude) / 2; double longitude = Math.Min (userLocation.Coordinate.Longitude, placemark.Coordinate.Longitude) + Math.Abs (userLocation.Coordinate.Longitude - placemark.Coordinate.Longitude) / 2; var midPoint = new CLLocationCoordinate2D(latitude, longitude); //Display the distance between the points (and multiple by 1.05 to get space on the edges) var distance = userLocation.Location.DistanceFrom (placemark.Location) * 1.05; var region = MKCoordinateRegion.FromDistance (midPoint, distance, distance); mapView.SetRegion (region, true); } }
public override void ViewDidLoad() { base.ViewDidLoad (); mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF (0, 0, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); var topOfSegement = View.Frame.Height - 120; segmentedControl.Frame = new RectangleF(20, topOfSegement, 282, 30); segmentedControl.InsertSegment("Map", 0, false); segmentedControl.InsertSegment("Satellite", 1, false); segmentedControl.InsertSegment("Hybrid", 2, false); segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Bar; segmentedControl.TintColor = UIColor.DarkGray; if(UIDevice.CurrentDevice.CheckSystemVersion(6,0)) segmentedControl.InsertSegment ("Directions", 3, false); segmentedControl.ValueChanged += delegate { if (segmentedControl.SelectedSegment == 0) mapView.MapType = MonoTouch.MapKit.MKMapType.Standard; else if (segmentedControl.SelectedSegment == 1) mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite; else if (segmentedControl.SelectedSegment == 2) mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid; else if (segmentedControl.SelectedSegment == 3) { var conferenceMapItem = new MKMapItem(new MKPlacemark(ConferenceLocation, null)); conferenceMapItem.Name = "MonkeySpace"; var conferenceHotel = new MKMapItem(new MKPlacemark(new CLLocationCoordinate2D(42.36346, -71.0863), null)); conferenceHotel.Name = "MonkeySpace Hotel"; var mapItems = new MKMapItem[] { conferenceMapItem, conferenceHotel }; MKMapItem.OpenMaps(mapItems, new MKLaunchOptions() { DirectionsMode = MKDirectionsMode.Walking }); } }; mapView.Delegate = new MapViewDelegate(this); // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF (0, 50, View.Frame.Width, View.Frame.Height - 100); MKCoordinateSpan span = new MKCoordinateSpan(0.01,0.01); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation,span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation , "MonkeySpace" , "NERD Center" ); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.StartUpdatingLocation(); // Add the table view as a subview View.AddSubview(mapView); View.AddSubview(labelDistance); View.AddSubview(segmentedControl); // Add the 'info' button to flip var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290,17,20,20); flipButton.Title (UIControlState.Normal); flipButton.TouchDown += delegate { _mfvc.Flip(); }; View.AddSubview(flipButton); }
public override void ViewDidLoad() { base.ViewDidLoad (); mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF (0, 0, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); var topOfSegement = View.Frame.Height - 120; segmentedControl.Frame = new RectangleF(20, topOfSegement, 282, 30); segmentedControl.InsertSegment("Map".GetText(), 0, false); segmentedControl.InsertSegment("Satellite".GetText(), 1, false); segmentedControl.InsertSegment("Hybrid".GetText(), 2, false); segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Bar; segmentedControl.TintColor = UIColor.DarkGray; segmentedControl.ValueChanged += delegate { if (segmentedControl.SelectedSegment == 0) mapView.MapType = MonoTouch.MapKit.MKMapType.Standard; else if (segmentedControl.SelectedSegment == 1) mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite; else if (segmentedControl.SelectedSegment == 2) mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid; }; mapView.Delegate = new MapViewDelegate(this); // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF (0, 50, View.Frame.Width, View.Frame.Height - 100); MKCoordinateSpan span = new MKCoordinateSpan(0.01,0.01); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation,span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation , "CodeCampSDQ" , "INTEC" ); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.StartUpdatingLocation(); // Add the table view as a subview View.AddSubview(mapView); View.AddSubview(labelDistance); View.AddSubview(segmentedControl); // Add the 'info' button to flip var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290,17,20,20); flipButton.Title (UIControlState.Normal); flipButton.TouchDown += delegate { _mfvc.Flip(); }; View.AddSubview(flipButton); }
public override void ViewDidLoad() { base.ViewDidLoad (); navBar = new UINavigationBar (new RectangleF (0, 0, 320, 44)); var bbi = new UIBarButtonItem(UIImage.FromBundle ("Images/slideout"), UIBarButtonItemStyle.Plain, (sender, e) => { AppDelegate.Current.FlyoutNavigation.ToggleMenu(); }); var rbi = new UIBarButtonItem (UIImage.FromBundle ("Images/113-navigation"), UIBarButtonItemStyle.Plain, (sender,e) => { mapFlipViewController.Flip(); }); var item = new UINavigationItem ("Location Map"); item.LeftBarButtonItem = bbi; item.RightBarButtonItem = rbi; var items = new UINavigationItem[] { item }; navBar.SetItems (items, false); mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF (0, 44, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); var topOfSegement = View.Frame.Height - 60; segmentedControl.Frame = new RectangleF(20, topOfSegement, 282, 30); segmentedControl.InsertSegment("Map", 0, false); segmentedControl.InsertSegment("Satellite", 1, false); segmentedControl.InsertSegment("Hybrid", 2, false); segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Bar; segmentedControl.TintColor = UIColor.DarkGray; segmentedControl.ValueChanged += delegate { if (segmentedControl.SelectedSegment == 0) mapView.MapType = MonoTouch.MapKit.MKMapType.Standard; else if (segmentedControl.SelectedSegment == 1) mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite; else if (segmentedControl.SelectedSegment == 2) mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid; }; mapView.Delegate = new MapViewDelegate(this); // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF (0, 44 + 50, View.Frame.Width, View.Frame.Height - 93); MKCoordinateSpan span = new MKCoordinateSpan(0.01,0.01); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation.Location.To2D(),span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation.Location.To2D() , ConferenceLocation.Title , ConferenceLocation.Subtitle ); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.Purpose = "Show distance on map"; // also Info.plist locationManager.StartUpdatingLocation(); // Add the table view as a subview View.AddSubview(mapView); View.AddSubview(labelDistance); View.AddSubview(segmentedControl); // Add the 'info' button to flip var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290,17,20,20); flipButton.Title (UIControlState.Normal); flipButton.TouchDown += delegate { mapFlipViewController.Flip(); }; View.AddSubview(flipButton); View.Add (navBar); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( App.Shared.Config.ControlStylingConfig.BackgroundColor ); ScrollView = new UIScrollViewWrapper(); ScrollView.Layer.AnchorPoint = CGPoint.Empty; ScrollView.Parent = this; ScrollView.Bounds = View.Bounds; View.AddSubview( ScrollView ); ScrollView.ScrollEnabled = false; // setup everything except positioning, which will happen in LayoutChanged() SourceLocation = null; GroupEntries = new List<GroupFinder.GroupEntry>(); SearchAddressButton = UIButton.FromType( UIButtonType.System ); ScrollView.AddSubview( SearchAddressButton ); SearchAddressButton.Layer.AnchorPoint = CGPoint.Empty; ControlStyling.StyleButton( SearchAddressButton, ConnectStrings.GroupFinder_SearchButtonLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); SearchAddressButton.TouchUpInside += (object sender, EventArgs e ) => { SearchPage.Show( ); Task.NavToolbar.Reveal( false ); }; MapView = new MKMapView( ); ScrollView.AddSubview( MapView ); // set the default position for the map to whatever specified area. MKCoordinateRegion region = MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D( ConnectConfig.GroupFinder_DefaultLatitude, ConnectConfig.GroupFinder_DefaultLongitude ), ConnectConfig.GroupFinder_DefaultScale_iOS, ConnectConfig.GroupFinder_DefaultScale_iOS ); MapView.SetRegion( region, true ); MapView.Layer.AnchorPoint = new CGPoint( 0, 0 ); MapView.Delegate = new MapViewDelegate() { Parent = this }; SearchResultsBGLayer = new UIView(); ScrollView.AddSubview( SearchResultsBGLayer ); SearchResultsBGLayer.Layer.AnchorPoint = new CGPoint( 0, 0 ); SearchResultsBGLayer.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color ); SearchResultsPrefix = new UILabel( ); ScrollView.AddSubview( SearchResultsPrefix ); SearchResultsPrefix.Layer.AnchorPoint = new CGPoint( 0, 0 ); SearchResultsPrefix.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); SearchResultsPrefix.Text = ConnectStrings.GroupFinder_NoGroupsFound; SearchResultsPrefix.SizeToFit( ); SearchResultsPrefix.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ); SearchResultsPrefix.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color ); SearchResultsPrefix.TextAlignment = UITextAlignment.Center; SearchResultsNeighborhood = new UILabel( ); ScrollView.AddSubview( SearchResultsNeighborhood ); SearchResultsNeighborhood.Layer.AnchorPoint = new CGPoint( 0, 0 ); SearchResultsNeighborhood.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); SearchResultsNeighborhood.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ); SearchResultsNeighborhood.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color ); SearchResultsNeighborhood.TextAlignment = UITextAlignment.Center; Seperator = new UIView( ); ScrollView.AddSubview( Seperator ); Seperator.Layer.BorderWidth = 1; Seperator.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ).CGColor; GroupFinderTableView = new UITableView(); ScrollView.AddSubview( GroupFinderTableView ); GroupTableSource = new GroupFinderViewController.TableSource( this ); // add the table view and source GroupFinderTableView.BackgroundColor = UIColor.Clear;//Rock.Mobile.UI.Util.GetUIColor( App.Shared.Config.ControlStylingConfig.Table_Footer_Color ); //GroupFinderTableView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( App.Shared.Config.ControlStylingConfig.BG_Layer_Color ); GroupFinderTableView.Source = GroupTableSource; GroupFinderTableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; BlockerView = new UIBlockerView( ScrollView, ScrollView.Frame.ToRectF( ) ); SearchPage = new UIGroupFinderSearch(); SearchPage.Create( ScrollView, ScrollView.Frame.ToRectF( ), delegate { SearchPage.Hide( true ); GetGroups( SearchPage.Street.Text, SearchPage.City.Text, SearchPage.State.Text, SearchPage.ZipCode.Text ); Task.NavToolbar.Reveal( true ); } ); SearchPage.SetTitle( ConnectStrings.GroupFinder_SearchPageHeader, ConnectStrings.GroupFinder_SearchPageDetails ); SearchPage.Hide( false ); KeyboardAdjustManager = new KeyboardAdjustManager( View ); // don't allow them to tap the address button until we reveal the search page. SearchAddressButton.Enabled = false; // wait a couple seconds before revealing the search page. System.Timers.Timer timer = new System.Timers.Timer(); timer.AutoReset = false; timer.Interval = 1000; timer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e ) => { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { SearchAddressButton.Enabled = true; SearchPage.Show( ); } ); }; timer.Start( ); // hook in delegates so we can handle return ((UITextField)SearchPage.Street.PlatformNativeObject).Delegate = new AddressDelegate( ) { Parent = this }; ((UITextField)SearchPage.City.PlatformNativeObject).Delegate = new AddressDelegate( ) { Parent = this }; ((UITextField)SearchPage.State.PlatformNativeObject).Delegate = new AddressDelegate( ) { Parent = this }; ((UITextField)SearchPage.ZipCode.PlatformNativeObject).Delegate = new AddressDelegate( ) { Parent = this }; }