public void DrawFeatures(bool clear) { if (clear) { ClearOverlays(); } MapControl.AddOverlays(featurePolylines); }
public void HighlightFeature(Feature feature) { MapControl.RemoveOverlays(highlightFeatures); highlightFeatures.Clear(); MapPolyline newLine = new MapPolyline(feature.record.GPSPoints, feature.routeWidth, Color.FromArgb(255, feature.lineColor)); highlightFeatures.Add(newLine); MapControl.AddOverlays(highlightFeatures); }
private void RefreshOverlays(bool clear) { if (clear || MapControlChanged) { ClearOverlays(); ResetMapControl(); } if (!m_showPage) { return; } IGPSBounds windowBounds = MapControlBounds; IList <IMapOverlay> addedOverlays = new List <IMapOverlay>(); //RouteOverlay //Only add a route exactly once, prefer marked routes IDictionary <IList <IGPSPoint>, MapPolyline> allRoutes = new Dictionary <IList <IGPSPoint>, MapPolyline>(); IDictionary <IList <IGPSPoint>, MapPolyline> dupRoutes = new Dictionary <IList <IGPSPoint>, MapPolyline>(); foreach (KeyValuePair <string, MapPolyline> pair in m_MarkedTrailRoutes) { if (!allRoutes.ContainsKey(pair.Value.Locations)) { allRoutes.Add(new KeyValuePair <IList <IGPSPoint>, MapPolyline>(pair.Value.Locations, pair.Value)); } } foreach (KeyValuePair <string, MapPolyline> pair in m_TrailRoutes) { if (!allRoutes.ContainsKey(pair.Value.Locations)) { allRoutes.Add(new KeyValuePair <IList <IGPSPoint>, MapPolyline>(pair.Value.Locations, pair.Value)); } else if (!dupRoutes.ContainsKey(pair.Value.Locations)) { dupRoutes.Add(new KeyValuePair <IList <IGPSPoint>, MapPolyline>(pair.Value.Locations, pair.Value)); } } IDictionary <IList <IGPSPoint>, MapPolyline> visibleRoutes = new Dictionary <IList <IGPSPoint>, MapPolyline>(); foreach (KeyValuePair <IList <IGPSPoint>, MapPolyline> pair in allRoutes) { IList <IGPSPoint> r = new List <IGPSPoint>(); foreach (IGPSPoint point in pair.Value.Locations) { if (windowBounds.Contains(point)) { visibleRoutes.Add(pair); break; } } //check for route in bounds only - the following does not seem to speed up //foreach (IGPSPoint point in pair.Value.Locations) //{ // if (windowBounds.Contains(point)) // { // r.Add(point); // } //} //if (r.Count > 0) //{ // MapPolyline m = new MapPolyline(r, pair.Value.LineWidth, pair.Value.LineColor); // visibleRoutes.Add(pair.Key, m); //} } IDictionary <IList <IGPSPoint>, IMapOverlay> newRouteOverlays = new Dictionary <IList <IGPSPoint>, IMapOverlay>(); foreach (KeyValuePair <IList <IGPSPoint>, MapPolyline> pair in visibleRoutes) { MapPolyline m = pair.Value; newRouteOverlays.Add(m.Locations, m); if ((!m_scalingChanged) && m_routeOverlays.ContainsKey(m.Locations) && !dupRoutes.ContainsKey(m.Locations)) { //No need to refresh this point m_routeOverlays.Remove(m.Locations); } else { addedOverlays.Add(m); } } //TrailPoints IDictionary <IGPSPoint, IMapOverlay> newPointOverlays = new Dictionary <IGPSPoint, IMapOverlay>(); foreach (TrailGPSLocation location in m_TrailPoints) { PointMapMarker pointOverlay = new PointMapMarker(location, getCircleIcon(this.MapControl, location.Radius), MouseEvents && (this.m_editTrail != null)); if (this.MouseEvents && location.Name != "DebugNotClickableDebug") { pointOverlay.MouseDown += new MouseEventHandler(pointOverlay_MouseDown); pointOverlay.MouseUp += new MouseEventHandler(pointOverlay_MouseUp); } if (!newPointOverlays.ContainsKey(location)) { newPointOverlays.Add(location, pointOverlay); } addedOverlays.Add(pointOverlay); } //SplitPoints foreach (SplitGPSLocation location in m_SplitPoints) { PointMapMarker pointOverlay = new PointMapMarker(location, getRhombusIcon(location.PointColor), false); if (!newPointOverlays.ContainsKey(location)) { newPointOverlays.Add(location, pointOverlay); } addedOverlays.Add(pointOverlay); } // Draw overlay if (0 == newPointOverlays.Count && 0 == visibleRoutes.Count) { return; } m_scalingChanged = false; if (!clear && !MapControlChanged) { ClearOverlays(); } MapControl.AddOverlays(addedOverlays); m_pointOverlays = newPointOverlays; m_routeOverlays = newRouteOverlays; if (m_extraMapLayer != null) { try { //Remove overlays are not working properly, the Map is not very usable m_extraMapLayer.MapControl.AddOverlays(addedOverlays); } catch (Exception) {} m_extraMapLayer.m_pointOverlays = newPointOverlays; m_extraMapLayer.m_routeOverlays = newRouteOverlays; } }