protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); // Get a reference to the sensor manager sensor_manager = (SensorManager) GetSystemService (Context.SensorService); // Create our view var map_view = new MapView (this, "MapViewCompassDemo_DummyAPIKey"); rotate_view = new RotateView (this); rotate_view.AddView (map_view); SetContentView (rotate_view); // Create the location overlay location_overlay = new MyLocationOverlay (this, map_view); location_overlay.RunOnFirstFix (delegate { map_view.Controller.AnimateTo (location_overlay.MyLocation); }); map_view.Overlays.Add (location_overlay); map_view.Controller.SetZoom(18); map_view.Clickable = true; map_view.Enabled = true; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.MapFragmentLayout); mapView = FindViewById<MapView> (Resource.Id.fragmentMapView); myLocation = new MyLocationOverlay (this, mapView); myLocation.RunOnFirstFix (() => { //mapView.Controller.AnimateTo (myLocation.MyLocation); var maxLat = Math.Max (myLocation.MyLocation.LatitudeE6, assignment.Latitude.ToIntE6 ()); var minLat = Math.Min (myLocation.MyLocation.LatitudeE6, assignment.Latitude.ToIntE6 ()); var maxLong = Math.Max (myLocation.MyLocation.LongitudeE6, assignment.Longitude.ToIntE6 ()); var minLong = Math.Min (myLocation.MyLocation.LongitudeE6, assignment.Longitude.ToIntE6 ()); mapView.Controller.ZoomToSpan (Math.Abs (maxLat - minLat), Math.Abs (maxLong - minLong)); mapView.Controller.AnimateTo (new GeoPoint ((maxLat + minLat) / 2, (maxLong + minLong) / 2)); }); mapView.Overlays.Add (myLocation); mapView.Controller.SetZoom (5); mapView.Clickable = true; mapView.Enabled = true; mapView.SetBuiltInZoomControls (true); }
void AddMyLocationOverlay (MapView map) { _myLocationOverlay = new MyLocationOverlay (this, map); map.Overlays.Add (_myLocationOverlay); _myLocationOverlay.RunOnFirstFix (() => { map.Controller.AnimateTo (_myLocationOverlay.MyLocation); RunOnUiThread (() => { var toast = Toast.MakeText (this, "Located", ToastLength.Short); toast.Show (); }); }); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); locationManager = GetSystemService (Context.LocationService) as LocationManager; RequestWindowFeature (WindowFeatures.NoTitle); SetContentView (Resource.Layout.Map); var map = FindViewById<MapView>(Resource.Id.map); map.Clickable = true; map.Traffic = true; map.SetBuiltInZoomControls (true); myLocationOverlay = new MyLocationOverlay (this, map); map.Overlays.Add (myLocationOverlay); myLocationOverlay.RunOnFirstFix (() => { map.Controller.SetZoom (15); map.Controller.AnimateTo (myLocationOverlay.MyLocation); }); }
private void AddMyLocationOverlay() { _myLocationOverlay = new MyLocationOverlay(Activity, _map); _myLocationOverlay.RunOnFirstFix(() => _map.Controller.AnimateTo(_myLocationOverlay.MyLocation)); _map.Overlays.Add(_myLocationOverlay); }