private void RenderMap() { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.CurrentExtent = new RectangleShape(-96.905564, 32.926216, -96.651506, 32.744942); //WorldMapKitWmsDesktopOverlay worldMapKitsOverlay = new WorldMapKitWmsDesktopOverlay(); //winformsMap1.Overlays.Add(worldMapKitsOverlay); ShapeFileFeatureLayer featureLayer = new ShapeFileFeatureLayer(Path.Combine(rootPath, "DallasCounty-4326.shp")); featureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColors.LightGray, 1)); featureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-4326.shp")); featureSource.Open(); RoutingLayer routingLayer = new RoutingLayer(); routingLayer.StartPoint = featureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint(); routingLayer.EndPoint = featureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint(); LayerOverlay routingOverlay = new LayerOverlay(); routingOverlay.Layers.Add("afda", featureLayer); routingOverlay.Layers.Add("RoutingLayer", routingLayer); winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay); InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer(); routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green)); routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-97.080185, 33.013491, -96.465213, 32.490127))); routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer); winformsMap1.Refresh(); }
private void RenderMap() { winformsMap1.MapUnit = GeographyUnit.Meter; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1")); winformsMap1.CurrentExtent = new RectangleShape(-10787478.039515, 3885514.4616168, -10759196.432323, 3861498.009642); GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay(); googleMapsOverlay.TileCache = new FileBitmapTileCache("C:\\ImageCache"); winformsMap1.Overlays.Add(googleMapsOverlay); ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-3857.shp")); featureSource.Open(); RoutingLayer routingLayer = new RoutingLayer(); routingLayer.StartPoint = featureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint(); routingLayer.EndPoint = featureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint(); LayerOverlay routingOverlay = new LayerOverlay(); routingOverlay.Layers.Add("RoutingLayer", routingLayer); winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay); InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer(); routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green)); routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-10806916.7603168, 3897094.80494128, -10738458.3904247, 3827820.76830281))); routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer); winformsMap1.Refresh(); }
private void EditRoutingData(PointShape clickedPosition, LayerOverlay roadOverlay) { InMemoryFeatureLayer currentRoadLayer = (InMemoryFeatureLayer)roadOverlay.Layers["currentRoadLayer"]; InMemoryFeatureLayer adjacentRoadsLayer = (InMemoryFeatureLayer)roadOverlay.Layers["adjacentRoadsLayer"]; if (currentRoadLayer.InternalFeatures.Count <= 0) { return; } // Select the editing feature routingSource.Open(); Collection <RouteSegment> routeSegments = routingSource.GetRouteSegmentsNearestTo(clickedPosition, featureSource, winformsMap1.MapUnit, 1); if (routeSegments.Count > 0) { string featureId = routeSegments[0].FeatureId; featureSource.Open(); Feature feature = featureSource.GetFeatureById(featureId, ReturningColumnsType.NoColumns); // Highlight the selected feature InMemoryFeatureLayer currentEditLayer = (InMemoryFeatureLayer)roadOverlay.Layers["currentEditLayer"]; currentEditLayer.InternalFeatures.Clear(); currentEditLayer.InternalFeatures.Add(feature); winformsMap1.Refresh(roadOverlay); UpdateRouteSegmentInformation(currentRoadLayer, adjacentRoadsLayer, routeSegments, feature); currentEditLayer.InternalFeatures.Remove(feature); winformsMap1.Refresh(roadOverlay); } }
public void ForEachFeatures(ShapeFileFeatureSource featureSource, Func <Feature, int, int, int, bool> process) { if (!featureSource.IsOpen) { featureSource.Open(); } int currentProgress = 0; int currentFeatureCount = featureSource.GetCount(); for (int i = 0; i < currentFeatureCount; i++) { var currentFeature = featureSource.GetFeatureById((i + 1).ToString(), featureSource.GetDistinctColumnNames()); if (process != null) { currentProgress++; var currentPercentage = currentProgress * 100 / currentFeatureCount; var canceled = process(currentFeature, currentProgress, currentFeatureCount, currentPercentage); if (canceled) { break; } } } }
private void RenderMap() { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1")); winformsMap1.CurrentExtent = new RectangleShape(-96.905564, 32.926216, -96.651506, 32.744942); WorldStreetsAndImageryOverlay worldStreetsAndImageryOverlay = new WorldStreetsAndImageryOverlay(); winformsMap1.Overlays.Add(worldStreetsAndImageryOverlay); ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-4326.shp")); featureSource.Open(); RoutingLayer routingLayer = new RoutingLayer(); routingLayer.StartPoint = featureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint(); routingLayer.EndPoint = featureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint(); LayerOverlay routingOverlay = new LayerOverlay(); routingOverlay.Layers.Add("RoutingLayer", routingLayer); winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay); ShapeFileFeatureLayer poiLayer = new ShapeFileFeatureLayer(Path.Combine(rootPath, "poi.shp")); MemoryStream stream = new MemoryStream(); Properties.Resources.Station.Save(stream, ImageFormat.Png); poiLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(stream)); poiLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay poiOverlay = new LayerOverlay(); poiOverlay.Layers.Add("POIlayer", poiLayer); winformsMap1.Overlays.Add("POIoverlay", poiOverlay); InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer(); routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green)); routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-97.080185, 33.013491, -96.465213, 32.490127))); routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer); winformsMap1.Refresh(); }