public async Task TrySetViewAsync(Geopoint point, double?zoomLevel, MapAnimationKind animation) { if (zoomLevel <= DigiTransitMapControl.ZoomLevel) { zoomLevel = DigiTransitMapControl.ZoomLevel; } await DigiTransitMapControl.TrySetViewAsync(point, zoomLevel, null, null, animation); }
public GeoboundingBox GetMapViewBoundingBox() { //Only available in AU and later if (ApiInformation.IsMethodPresent("Windows.UI.Xaml.Controls.Maps.MapControl", "GetVisibleRegion")) { Geopath geopath = DigiTransitMapControl.GetVisibleRegion(MapVisibleRegionKind.Full); if (geopath == null) { return(null); } return(GetCoordinateGeoboundingBox(geopath.Positions)); } else //pre-AU { return(GetBounds()); } }
public async Task TrySetViewBoundsAsync(GeoboundingBox bounds, Thickness?margin, MapAnimationKind animation, bool retryOnFailure = false) { if (DigiTransitMapControl == null) { return; } // We're checking for the MapStyle type as a proxy for "are we running on Creators or higher?". // We don't need to run the following code if we are. if (margin != null && !ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Maps.MapStyle") && DeviceTypeHelper.GetDeviceFormFactorType() != DeviceFormFactorType.Phone) { //Margins are a little smaller on desktop for some reason. investigate this a little further, may just be a DPI thing? const int desktopPlusCoeff = 40; margin = new Thickness(margin.Value.Left + desktopPlusCoeff, margin.Value.Top + desktopPlusCoeff, margin.Value.Right + desktopPlusCoeff, margin.Value.Bottom + desktopPlusCoeff); } //If map movement fails, keep retrying until we get it right bool moved = false; do { moved = await DigiTransitMapControl.TrySetViewBoundsAsync(bounds, margin, animation); if (moved) { break; } else { await Task.Delay(2000); //looong delay to acommodate slow mobile rendering } } while (!moved && retryOnFailure); }