public void SetSelectedPoint(double lat, double lng) { if (selectionMarker == null) { selectionMarker = AddMarker(new Markers.SelectionMarker(), lat, lng); } else { selectionMarker.Location = new Point(lat, lng); selectionMarker.SetVisualLocation(zoomLevel); } }
public MapMarker ReplaceMarker(MapMarker oldMarker, UserControl newMarker, double lat, double lng) { MapMarker m = new MapMarker(new Point(lat, lng), newMarker); m.SetVisualLocation(zoomLevel); int i = 0; for (; i<Markers.Count; i++) { if (Markers[i] == oldMarker) { Markers[i]=m; break; } } if (i==Markers.Count) return null; for (i = 0; i < MarkerLayer.Children.Count; i++) { if (MarkerLayer.Children[i] == oldMarker.MarkerControl) { MarkerLayer.Children.RemoveAt(i); MarkerLayer.Children.Insert(i, newMarker); break; } } return m; }
public MapMarker AddMarker(UserControl marker, double lat, double lng) { if (!MapLayer.Children.Contains(marker)) { MapMarker m = new MapMarker(new Point(lat, lng), marker); m.SetVisualLocation(zoomLevel); Markers.Add(m); MarkerLayer.Children.Add(marker); return m; } return null; }
public bool RemoveMarker(MapMarker marker) { if (!MapLayer.Children.Contains(marker.MarkerControl)) { foreach (MapMarker mapMarker in Markers) { if (mapMarker == marker) { Markers.Remove(mapMarker); break; } } MarkerLayer.Children.Remove(marker.MarkerControl); return true; } return false; }
public MapControl(double lat, double lng) { InitializeComponent(); MapLayer.RenderTransformOrigin = new Point(0.5, 0.5); MapLayer.RenderTransform = translateTransform; MarkerLayer.RenderTransformOrigin = new Point(0.5, 0.5); MarkerLayer.RenderTransform = translateTransform; MapCenter = new Point(lat, lng); MapLayer.SetValue(Canvas.ZIndexProperty, 100); MarkerLayer.SetValue(Canvas.ZIndexProperty, 200); selectionMarker = AddMarker(new Markers.SelectionMarker(),lat, lng); }