void MoveToRegion(MapSpan span, MapAnimationKind animation = MapAnimationKind.Parabolic) { // FIXME var center = new GeoCoordinate(span.Center.Latitude, span.Center.Longitude); var location = new LocationRectangle(center, span.LongitudeDegrees, span.LatitudeDegrees); Control.SetView(location, animation); }
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); }
private void RefreshBounds(MapAnimationKind animation) { if (Model == null || Model.Core == null || Model.Core.Cartridge == null) { return; } // Gets the current location data out of the engine. CoordBounds bounds = Model.Core.Bounds; GeoCoordinate deviceLoc = Model.Core.DeviceLocation; // Are the bounds valid? // YES -> Computes a view around them. // NO -> Computes a default view around the starting location // of the cartridge or the current location of the player. MapViewRequestedEventArgs e = null; if (bounds != null && bounds.IsValid) { // Inflates the bounds to include the player. if (deviceLoc != null && !deviceLoc.IsUnknown) { bounds.Inflate(deviceLoc.ToZonePoint()); } e = new MapViewRequestedEventArgs(bounds.ToLocationRectangle(), animation); } else { // Is the cartridge play anywhere? // YES -> Try to get the player's location as center. // NO -> Sets the starting location of the cartridge as center. if (Model.Core.Cartridge.IsPlayAnywhere) { // If there is a current location of the player, use it as center. // If not, do nothing more. if (deviceLoc != null && !deviceLoc.IsUnknown) { e = new MapViewRequestedEventArgs(deviceLoc, DEFAULT_ZOOM_LEVEL, animation); } else { return; } } else { // Makes the event. e = new MapViewRequestedEventArgs(Model.Core.Cartridge.StartingLocation.ToGeoCoordinate(), DEFAULT_ZOOM_LEVEL, animation); } } // If an event was prepared, send it. if (MapViewRequested != null) { MapViewRequested(this, e); } }
async Task MoveToRegion(MapSpan span, MapAnimationKind animation = MapAnimationKind.Bow) { var nw = new BasicGeoposition { Latitude = span.Center.Latitude + span.LatitudeDegrees / 2, Longitude = span.Center.Longitude - span.LongitudeDegrees / 2 }; var se = new BasicGeoposition { Latitude = span.Center.Latitude - span.LatitudeDegrees / 2, Longitude = span.Center.Longitude + span.LongitudeDegrees / 2 }; var boundingBox = new GeoboundingBox(nw, se); await Control.TrySetViewBoundsAsync(boundingBox, null, animation); }
public async override void OnMoveToRegionRequest(MoveToRegionMessage m) { MapSpan span = m.Span; MapAnimationKind animation = m.Animate ? MapAnimationKind.Bow : MapAnimationKind.None; var nw = new BasicGeoposition { Latitude = span.Center.Latitude + span.LatitudeDegrees / 2, Longitude = span.Center.Longitude - span.LongitudeDegrees / 2 }; var se = new BasicGeoposition { Latitude = span.Center.Latitude - span.LatitudeDegrees / 2, Longitude = span.Center.Longitude + span.LongitudeDegrees / 2 }; var boundingBox = new GeoboundingBox(nw, se); await _nativeMap.TrySetViewBoundsAsync(boundingBox, null, animation); }
private void Button_Click_3(object sender, RoutedEventArgs e) { if (sender == Lands) { if (map1.LandmarksEnabled == true) { map1.LandmarksEnabled = false; } else { map1.LandmarksEnabled = true; } } else if (sender == pedsFF) { if (map1.PedestrianFeaturesEnabled == true) { map1.PedestrianFeaturesEnabled = false; } else { map1.PedestrianFeaturesEnabled = true; } } else if (sender == AniS) { if (useAnim == MapAnimationKind.Parabolic) { useAnim = MapAnimationKind.Linear; } else if (useAnim == MapAnimationKind.Linear) { useAnim = MapAnimationKind.None; } else { useAnim = MapAnimationKind.Parabolic; } AniS.Content = useAnim; Debug.WriteLine("Animation style set to: " + useAnim); } }
/// <summary> /// <see cref="windows.UI.Xaml.Controls.Maps.MapControl"/> /// </summary> /// <returns>IAsyncOperation</returns> public Task <bool> TrySetViewAsync(Geopoint center, double?zoomLevel, double?heading, double?desiredPitch, MapAnimationKind animation) => UwpControl.TrySetViewAsync(center.UwpInstance, zoomLevel, heading, desiredPitch, (windows.UI.Xaml.Controls.Maps.MapAnimationKind)(int) animation).AsTask();
/// <summary> /// <see cref="windows.UI.Xaml.Controls.Maps.MapControl"/> /// </summary> /// <returns>IAsyncOperation</returns> public Task <bool> TrySetSceneAsync(MapScene scene, MapAnimationKind animationKind) => UwpControl.TrySetSceneAsync(scene.UwpInstance, (windows.UI.Xaml.Controls.Maps.MapAnimationKind)animationKind).AsTask();
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); } }
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); }
internal async void SetView(Geopoint center, double? zoomLevel, double? heading, double? desiredPitch, MapAnimationKind animation) { if (center != null) prevCenter = center; if (zoomLevel.HasValue) prevZoomLevel = zoomLevel; if (heading.HasValue) prevHeading = heading; if (desiredPitch.HasValue) prevDesiredPitch = desiredPitch; if (compassMode) prevZoomLevel = null; if (prevCenter != null) await MapCtrl.TrySetViewAsync(prevCenter, prevZoomLevel, prevHeading, prevDesiredPitch, animation); }
public MapViewRequestedEventArgs(GeoCoordinate center, double zoomLevel, MapAnimationKind anim = MapAnimationKind.None) { TargetCenter = center; TargetZoomLevel = zoomLevel; Animation = anim; }
public MapViewRequestedEventArgs(LocationRectangle locRect, MapAnimationKind anim = MapAnimationKind.None) { TargetBounds = locRect; Animation = anim; }
private void Button_Click_3(object sender, RoutedEventArgs e) { if (sender == Lands) { if (map1.LandmarksEnabled == true) { map1.LandmarksEnabled = false; } else { map1.LandmarksEnabled = true; } } else if (sender == pedsFF) { if (map1.PedestrianFeaturesEnabled == true) { map1.PedestrianFeaturesEnabled = false; } else { map1.PedestrianFeaturesEnabled = true; } }else if (sender == AniS) { if (useAnim == MapAnimationKind.Parabolic){ useAnim = MapAnimationKind.Linear; }else if (useAnim == MapAnimationKind.Linear){ useAnim = MapAnimationKind.None; }else{ useAnim = MapAnimationKind.Parabolic; } AniS.Content = useAnim; Debug.WriteLine("Animation style set to: " + useAnim); } }