/// <summary> /// regenerates shape of route /// </summary> public virtual void RegenerateShape(MiniGMapControl map) { if (map != null) { this.Map = map; if (Points.Count > 1) { Position = Points[0]; var localPath = new List <System.Windows.Point>(Points.Count); var offset = Map.FromLatLngToLocal(Points[0]); foreach (var i in Points) { var p = Map.FromLatLngToLocal(i); localPath.Add(new System.Windows.Point(p.X - offset.X, p.Y - offset.Y)); } //var shape = map.CreateRoutePath(localPath); //if (this.Shape is Path) //{ // (this.Shape as Path).Data = shape.Data; //} //else //{ // this.Shape = shape; //} } else { this.Shape = null; } } }
/// <summary> /// forces to update local marker position /// dot not call it if you don't really need to ;} /// </summary> /// <param name="m"></param> internal void ForceUpdateLocalPosition(MiniGMapControl m) { if (m != null) { map = m; } UpdateLocalPosition(); }
private static void MapProviderPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MiniGMapControl map = (MiniGMapControl)d; if (map != null && e.NewValue != null) { RectLatLng viewarea = map.SelectedArea; if (viewarea != RectLatLng.Empty) { map.Position = new PointLatLng(viewarea.Lat - viewarea.HeightLat / 2, viewarea.Lng + viewarea.WidthLng / 2); } else { viewarea = map.ViewArea; } map.Core.Provider = e.NewValue as GMapProvider; map.Copyright = null; if (!string.IsNullOrEmpty(map.Core.Provider.Copyright)) { map.Copyright = new FormattedText(map.Core.Provider.Copyright, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface("GenericSansSerif"), 9, Brushes.Navy); } if (map.Core.IsStarted && map.Core.zoomToArea) { // restore zoomrect as close as possible if (viewarea != RectLatLng.Empty && viewarea != map.ViewArea) { int bestZoom = map.Core.GetMaxZoomToFitRect(viewarea); if (bestZoom > 0 && map.Zoom != bestZoom) { map.Zoom = bestZoom; } } } } }
private static void ZoomPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MiniGMapControl map = (MiniGMapControl)d; if (map != null && map.MapProvider.Projection != null) { double value = (double)e.NewValue; Debug.WriteLine("Zoom: " + e.OldValue + " -> " + value); double remainder = value % 1; if (map.ScaleMode != ScaleModes.Integer && remainder != 0 && map.ActualWidth > 0) { bool scaleDown; switch (map.ScaleMode) { case ScaleModes.ScaleDown: scaleDown = true; break; case ScaleModes.Dynamic: scaleDown = remainder > 0.25; break; default: scaleDown = false; break; } if (scaleDown) { remainder--; } double scaleValue = Math.Pow(2d, remainder); { if (map.MapScaleTransform == null) { map.MapScaleTransform = map.lastScaleTransform; } map.MapScaleTransform.ScaleX = scaleValue; map.MapScaleTransform.ScaleY = scaleValue; map.Core.scaleX = 1 / scaleValue; map.Core.scaleY = 1 / scaleValue; map.MapScaleTransform.CenterX = map.ActualWidth / 2; map.MapScaleTransform.CenterY = map.ActualHeight / 2; } map.Core.Zoom = Convert.ToInt32(scaleDown ? Math.Ceiling(value) : value - remainder); } else { map.MapScaleTransform = null; map.Core.scaleX = 1; map.Core.scaleY = 1; map.Core.Zoom = (int)Math.Floor(value); } if (map.IsLoaded) { map.ForceUpdateOverlays(); map.InvalidateVisual(true); } } }