コード例 #1
0
        private void TestForm_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-110.136, 23.0523, -109.6883, 22.7859);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));

            //Displays the World Map Kit as a background.
            ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay();
            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            //Display the countries02 shapefile.
            ShapeFileFeatureLayer Layer1 = new ShapeFileFeatureLayer(@"../../data/countries02.shp");

            Layer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.StandardColors.Black, 2);
            Layer1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(Layer1);
            winformsMap1.Overlays.Add(layerOverlay);

            //Gets the feature for Mexico for the EditInteractiveOverlay.
            Layer1.Open();
            Collection <Feature> features = Layer1.QueryTools.GetFeaturesByColumnValue("ISO_3DIGIT", "MEX");

            Layer1.Close();

            //EditInteractiveOverlay for doing editing such as resizing, rotating, dragging, adding vertex and moving vertex.
            EditInteractiveOverlay editOverlay = winformsMap1.EditOverlay;

            editOverlay.EditShapesLayer.Open();
            editOverlay.EditShapesLayer.EditTools.BeginTransaction();
            //Clears and add the Mexico feature to EditInteractiveOverlay
            editOverlay.EditShapesLayer.InternalFeatures.Clear();
            editOverlay.EditShapesLayer.EditTools.Add(features[0]);
            TransactionResult result = editOverlay.EditShapesLayer.EditTools.CommitTransaction();

            editOverlay.EditShapesLayer.BuildIndex();
            editOverlay.EditShapesLayer.Close();

            //Shows the control points for dragging, resizing and rotating the polygon feature as a whole.
            //Also shows the vertices to be dragged and add new vertex.
            editOverlay.CalculateAllControlPoints();
            //Builds the spatial index for better performance while doing any of those operations.
            editOverlay.ExistingControlPointsLayer.BuildIndex();

            winformsMap1.Refresh();
        }
コード例 #2
0
        private void TestForm_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-95.3094, 38.9749, -95.2528, 38.9406);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));

            //Displays the World Map Kit as a background.
            ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay();
            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            //EditInteractiveOverlay used because it already has the logic for dragging.
            EditInteractiveOverlay editInteractiveOverlay = new EditInteractiveOverlay();

            //Sets the property IsActive for DragControlPointsLayer to false so that the control point (as four arrows) is not visible.
            editInteractiveOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = false;
            editInteractiveOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel        = ApplyUntilZoomLevel.Level20;

            //Sets the property IsActive for all the Styles of EditShapesLayer because we are using a ValueStyle instead.
            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = false;
            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive  = false;
            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive  = false;

            //ValueStyle used for displaying the feature according to the value of the column "Type" for displaying with a flag or unknown icon.
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "Type";

            PointStyle carPointStyle = new PointStyle(new GeoImage(@"..\..\Data\locale.png"));

            carPointStyle.PointType = PointType.Bitmap;
            PointStyle busPointStyle = new PointStyle(new GeoImage(@"..\..\Data\unknown.png"));

            busPointStyle.PointType = PointType.Bitmap;

            valueStyle.ValueItems.Add(new ValueItem("Flag", carPointStyle));
            valueStyle.ValueItems.Add(new ValueItem("Unknown", busPointStyle));

            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            editInteractiveOverlay.EditShapesLayer.Open();
            editInteractiveOverlay.EditShapesLayer.Columns.Add(new FeatureSourceColumn("Type"));
            editInteractiveOverlay.EditShapesLayer.Close();

            Feature carFeature = new Feature(new PointShape(-95.2809, 38.9544));

            carFeature.ColumnValues["Type"] = "Flag";

            Feature busFeature = new Feature(new PointShape(-95.3019, 38.9578));

            busFeature.ColumnValues["Type"] = "Unknown";

            editInteractiveOverlay.EditShapesLayer.InternalFeatures.Add("Flag", carFeature);
            editInteractiveOverlay.EditShapesLayer.InternalFeatures.Add("Unknown", busFeature);

            //Sets the properties of EditInteractiveOverlay to have the appropriate behavior.
            //Make sure CanDrag is set to true.
            editInteractiveOverlay.CanAddVertex    = false;
            editInteractiveOverlay.CanDrag         = true;
            editInteractiveOverlay.CanRemoveVertex = false;
            editInteractiveOverlay.CanResize       = false;
            editInteractiveOverlay.CanRotate       = false;
            editInteractiveOverlay.CalculateAllControlPoints();

            winformsMap1.EditOverlay = editInteractiveOverlay;

            winformsMap1.Refresh();

            //We disable the double click modes in order to not have second effect behavior
            //of the map when adding or removing an icon by double clicking
            winformsMap1.ExtentOverlay.DoubleLeftClickMode  = MapDoubleLeftClickMode.Disabled;
            winformsMap1.ExtentOverlay.DoubleRightClickMode = MapDoubleRightClickMode.Disabled;
        }
コード例 #3
0
        private void TestForm_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-97.7591, 30.3126, -97.7317, 30.2964);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));

            //Displays the World Map Kit as a background.
            ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay();
            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            //EditInteractiveOverlay used because it already have the logic for dragging.
            EditInteractiveOverlay editInteractiveOverlay = new EditInteractiveOverlay();

            //Sets the property IsActive for DragControlPointsLayer to false so that the control point (as four arrows) is not visible.
            editInteractiveOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = false;
            editInteractiveOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel        = ApplyUntilZoomLevel.Level20;

            //Sets the property IsActive for all the Styles of EditShapesLayer because we are using a ValueStyle instead.
            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = false;
            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive  = false;
            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive  = false;

            //ValueStyle used for displaying the feature according to the value of the column "Type" for displaying with a bus or car icon.
            ValueStyle valueStyle = new ValueStyle();

            valueStyle.ColumnName = "Type";

            PointStyle carPointStyle = new PointStyle(new GeoImage(@"..\..\Data\car_normal.png"));

            carPointStyle.PointType = PointType.Bitmap;
            PointStyle busPointStyle = new PointStyle(new GeoImage(@"..\..\Data\bus_normal.png"));

            busPointStyle.PointType = PointType.Bitmap;

            valueStyle.ValueItems.Add(new ValueItem("Car", carPointStyle));
            valueStyle.ValueItems.Add(new ValueItem("Bus", busPointStyle));

            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            editInteractiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            editInteractiveOverlay.EditShapesLayer.Open();
            editInteractiveOverlay.EditShapesLayer.Columns.Add(new FeatureSourceColumn("Type"));
            editInteractiveOverlay.EditShapesLayer.Close();

            Feature carFeature = new Feature(new PointShape(-97.7507, 30.3092));

            carFeature.ColumnValues["Type"] = "Car";

            Feature busFeature = new Feature(new PointShape(-97.7428, 30.3053));

            busFeature.ColumnValues["Type"] = "Bus";

            editInteractiveOverlay.EditShapesLayer.InternalFeatures.Add("Car", carFeature);
            editInteractiveOverlay.EditShapesLayer.InternalFeatures.Add("Bus", busFeature);

            //Sets the properties of EditInteractiveOverlay to have the appropriate behavior.
            //Make sure CanDrag is set to true.
            editInteractiveOverlay.CanAddVertex    = false;
            editInteractiveOverlay.CanDrag         = true;
            editInteractiveOverlay.CanRemoveVertex = false;
            editInteractiveOverlay.CanResize       = false;
            editInteractiveOverlay.CanRotate       = false;
            editInteractiveOverlay.CalculateAllControlPoints();

            winformsMap1.EditOverlay = editInteractiveOverlay;

            winformsMap1.Refresh();
        }