public override void AddView(AView child) { if (child is CoordinatorLayout) { base.AddView(child); return; } ((ViewGroup)child).LayoutParameters = new CoordinatorLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); MainViewGroup = (ViewGroup)child; AndroidCoordinatorLayout.FindViewById <RelativeLayout>(Resource.Id.map_holder) .AddView(child); for (var i = 0; i < MainViewGroup.ChildCount; i++) { AView foundChild = MainViewGroup.GetChildAt(i); if (!(foundChild is CyclesMapRenderer cyclesMapRenderer)) { continue; } CyclesMapView = cyclesMapRenderer; CyclesMapView.MapReady += async sender => { if (!MainActivity.IsLocationAccessGranted || !MainActivity.IsLocationEnabled) { return; } Location lastLocation = await FusedLocationProviderClient.GetLastLocationAsync(); if (lastLocation == null) { return; } var addressResultReceiver = new MapPageRendererAddressResultReceiver(new Handler(), this); StartAddressIntentService(addressResultReceiver, lastLocation); var latLng = new LatLng(lastLocation.Latitude, lastLocation.Longitude); CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(latLng); builder.Zoom(18); CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); CyclesMapView.AnimateCamera(cameraUpdate); }; } }
public void MoveToLocation(Location location) { if (location == null) { return; } var latLng = new LatLng(location.Latitude, location.Longitude); CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(latLng); builder.Zoom(18); CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); CyclesMapView.AnimateCamera(cameraUpdate); }