public override void ViewDidLoad() { base.ViewDidLoad(); //Your Google Dev. Console API Key (with iOS Google Maps SDK enabled!) var success = MapServices.ProvideAPIKey(Your API Key Here); mapServices = MapServices.SharedServices; var button = new UIButton(UIButtonType.System); button.Frame = new CGRect(40, 40, 200, 40); button.SetTitle("Track My Movement", UIControlState.Normal); Add(button); button.TouchUpInside += (object sender, EventArgs e) => { mapView = new MapView(UIScreen.MainScreen.Bounds); mapView.MapType = MapViewType.Hybrid; Add(mapView); mapView.AddObserver(this, new NSString("myLocation"), NSKeyValueObservingOptions.New, IntPtr.Zero); mapView.MyLocationEnabled = true; locationManager = new CLLocationManager(); locationManager.DesiredAccuracy = CLLocation.AccuracyBest; locationManager.DistanceFilter = 0; locationManager.RequestWhenInUseAuthorization(); locationManager.LocationsUpdated += (object sender2, CLLocationsUpdatedEventArgs e2) => { Console.WriteLine(e2.Locations[e2.Locations.Length - 1]); }; locationManager.StartUpdatingLocation(); }; }
public void initMap() { mapView = MapView.FromCamera(new CGRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), CameraPosition.FromCamera(latitude: 37.79, longitude: -122.40, zoom: 6)); InvokeOnMainThread(() => { mapView.MyLocationEnabled = true; mapView.AddObserver(this, new NSString("myLocation"), NSKeyValueObservingOptions.New, IntPtr.Zero); }); View.AddSubview(mapView); }
public override void ViewDidLoad() { base.ViewDidLoad(); var camera = CameraPosition.FromCamera(-33.868, 151.2086, 12); mapView = MapView.FromCamera(RectangleF.Empty, camera); mapView.Settings.CompassButton = true; mapView.Settings.MyLocationButton = true; // Listen to the myLocation property of GMSMapView. mapView.AddObserver(this, new NSString("myLocation"), NSKeyValueObservingOptions.New, IntPtr.Zero); View = mapView; // Ask for My Location data after the map has already been added to the UI. InvokeOnMainThread(() => mapView.MyLocationEnabled = true); }