private void SearchLineSelectionChanged(MessageTypes.SearchLineSelectionChanged _) { GeoboundingBox lineBox = PageMap.GetAllMapElementsBoundingBox(); var mapMargin = AdaptiveVisualStateGroup.CurrentState == _narrowVisualState ? new Thickness(0, 0, 0, (this.NarrowSearchPanel.ExpandedHeight) + 0) : new Thickness(410, 10, 10, 10); PageMap.TrySetViewBoundsAsync(lineBox, mapMargin, MapAnimationKind.Linear).DoNotAwait(); }
private async Task TrySetMapViewWithMargin(BasicGeoposition pos, double boundingBoxZoomAdjustment, MapAnimationKind mapAnimation = MapAnimationKind.None) { double narrowZoomAdjustment = boundingBoxZoomAdjustment / 2; // Creators update changed maps a bit, so we need to zoom in closer on any device running it. // MapStyle is a decent proxy for "are we on Creators or not" if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone && !ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Maps.MapStyle")) { narrowZoomAdjustment = boundingBoxZoomAdjustment / 1.35; } // Create a box surrounding the specified point to emulate a zoom level on the map. // We're using a simulated bounding box, because we need to be able to specify a margin, // to accommodate either of the the floating content panels. BasicGeoposition northwest = BasicGeopositionExtensions.Create ( 0.0, pos.Longitude - boundingBoxZoomAdjustment, pos.Latitude + boundingBoxZoomAdjustment ); BasicGeoposition southeast = BasicGeopositionExtensions.Create ( 0.0, pos.Longitude + boundingBoxZoomAdjustment, pos.Latitude - boundingBoxZoomAdjustment ); if (AdaptiveVisualStateGroup.CurrentState == _narrowVisualState) { // Zoom in a little further when in the narrow view, otherwise we're a little // too far out for the narrow field of view northwest.Longitude += narrowZoomAdjustment; northwest.Latitude -= narrowZoomAdjustment; southeast.Longitude -= narrowZoomAdjustment; southeast.Latitude += narrowZoomAdjustment; GeoboundingBox box = new GeoboundingBox(northwest, southeast); if (NarrowSearchPanel.IsOpen) { double bottomMargin = NarrowSearchPanel.ExpandedHeight; await PageMap.TrySetViewBoundsAsync(box, new Thickness(0, 0, 0, bottomMargin), mapAnimation); } else { await PageMap.TrySetViewBoundsAsync(box, new Thickness(0, 0, 0, 0), mapAnimation); } } else { GeoboundingBox box = new GeoboundingBox(northwest, southeast); await PageMap.TrySetViewBoundsAsync(box, new Thickness(410, 0, 0, 0), mapAnimation); } }