I create my own path / polyline on the map using MapLayer and MapOverlay, all the points captured by GPS are stored in the structure, so I can access them. Anytime.
Now I want the path to be transformed simultaneously with the manipulation of the Map by the user (scaling and changing the map), so the path is still connected to the same points. So far, my method is very hungry and looks awful.
GeocoordinateList _coordinates; MapLayer pointsLayer; private void MyMap_ZoomLevelChanged(object sender, MapZoomLevelChangedEventArgs e) { repositionPoints(); // This is done other way but for the sake of brevity } private void repositionPathPoints() { try { Polyline path = (Polyline)pointsLayer.First(TrackPath).Content; // retrieves MapOverlay corresponding to line path.Points.Clear(); path.Points = new PointCollection(); foreach (Geocoordinate coord in _coordinates) { path.Points.Add(MyMap.ConvertGeoCoordinateToViewportPoint(coord)); } } catch (Exception exc) { Debug.WriteLine(exc.Message); } }
Is there a more efficient way to do this using XAML methods? I found this old thread on how to scale a map, but in my case the zoom level stored on the map is a numerical value from 1 to 20 without specifying the% scale per zoom move.
MLProgrammer-CiM
source share