private void InitializeMap()
        {
            mapControl.MapTools.Logo.IsEnabled                      = true;
            mapControl.MapTools.Logo.Margin                         = new Thickness(0, 0, 10, 5);
            mapControl.MapTools.MouseCoordinate.IsEnabled           = true;
            mapControl.MapTools.MouseCoordinate.Visibility          = Visibility.Hidden;
            mapControl.MapTools.MouseCoordinate.Margin              = new Thickness(0, 0, 100, 5);
            mapControl.MapTools.MouseCoordinate.MouseCoordinateType = MouseCoordinateType.Custom;

            mapControl.Overlays.Add(new WorldMapKitWmsWpfOverlay());

            censusStateFeatureLayer = new ShapeFileFeatureLayer(MapSuiteSampleHelper.GetValueFromConfiguration("UsShapefilePath"));
            censusStateFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            demographicLayerOverlay          = new LayerOverlay();
            demographicLayerOverlay.TileType = TileType.SingleTile;
            mapControl.Overlays.Add(demographicLayerOverlay);

            highlightOverlay = new HighlightOverlay();
            mapControl.Overlays.Add(highlightOverlay);

            legendAdornmentLayer          = new LegendAdornmentLayer();
            legendAdornmentLayer.Location = AdornmentLocation.LowerLeft;
            legendAdornmentLayer.Title    = new LegendItem();
            legendAdornmentLayer.Title.ImageJustificationMode = LegendImageJustificationMode.JustifyImageRight;
            legendAdornmentLayer.Title.TopPadding             = 10;
            legendAdornmentLayer.Title.BottomPadding          = 10;
            legendAdornmentLayer.Title.TextStyle = new TextStyle("Population", new GeoFont("Segoe UI", 12), new GeoSolidBrush(GeoColor.SimpleColors.Black));
            mapControl.AdornmentOverlay.Layers.Add(legendAdornmentLayer);

            DefaultFeatureLayer = censusStateFeatureLayer;

            MapControl.CurrentExtent = globeExtent;
        }
        private void MainForm_Load(object sender, EventArgs e)
        {
            map.MapUnit       = GeographyUnit.Meter;
            map.ZoomLevelSet  = new ThinkGeoCloudMapsZoomLevelSet();
            map.CurrentExtent = new RectangleShape(-13059527, 6484023, -8632838, 2982361);

            // Please input your ThinkGeo Cloud Client ID / Client Secret to enable the background map.
            ThinkGeoCloudRasterMapsOverlay thinkGeoCloudMapsOverlay = new ThinkGeoCloudRasterMapsOverlay("ThinkGeo Cloud Client ID", "ThinkGeo Cloud Client Secret");

            map.Overlays.Add(thinkGeoCloudMapsOverlay);

            // Add Demographic Layer
            customFeatureLayer      = new ShapeFileFeatureLayer();
            censusStateFeatureLayer = new ShapeFileFeatureLayer(@"../../App_Data/usStatesCensus2010.shp");
            censusStateFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            currentFeatureLayer = censusStateFeatureLayer;

            LayerOverlay demographicLayerOverlay = new LayerOverlay();

            demographicLayerOverlay.Layers.Add(currentFeatureLayer);
            map.Overlays.Add("DemographicLayerOverlayKey", demographicLayerOverlay);

            // Add Highlight Overlay
            HighlightOverlay USDemographicOverlay = new HighlightOverlay();

            map.Overlays.Add("HighlightOverlayKey", USDemographicOverlay);

            // Initialize style builder to Thematic
            currentStyleBuilder = new ThematicDemographicStyleBuilder();
            currentStyleBuilder.SelectedColumns.Add("Population");

            // Initialize the Legend
            LegendAdornmentLayer legendAdornmentLayer = new LegendAdornmentLayer();

            legendAdornmentLayer.Location = AdornmentLocation.LowerLeft;
            legendAdornmentLayer.Title    = new LegendItem();
            legendAdornmentLayer.Title.ImageJustificationMode = LegendImageJustificationMode.JustifyImageRight;
            legendAdornmentLayer.Title.TopPadding             = 10;
            legendAdornmentLayer.Title.BottomPadding          = 10;
            legendAdornmentLayer.Title.TextStyle = new TextStyle("Population", new GeoFont("Segoe UI", 12), new GeoSolidBrush(GeoColor.SimpleColors.Black));
            map.AdornmentOverlay.Layers.Add(legendAdornmentLayer);
            //map.ZoomToScale(map.ZoomLevelSet.ZoomLevel14.Scale);
            // Update the controls and map.
            UpdateUIControls(currentStyleBuilder);
            UpdateMap(currentStyleBuilder);

            LoadDataSelectorUserControls();
        }
        private void Map_MouseMove(object sender, MouseEventArgs e)
        {
            PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(map.CurrentExtent, new ScreenPointF(e.X, e.Y), map.Width, map.Height);

            lblLocationX.Text = string.Format(CultureInfo.InvariantCulture, "X:{0:N6}", mouseLocation.X);
            lblLocationY.Text = string.Format(CultureInfo.InvariantCulture, "Y:{0:N6}", mouseLocation.Y);
            stpFooter.Refresh();

            if (!currentFeatureLayer.IsOpen)
            {
                return;
            }
            HighlightOverlay USDemographicOverlay = (HighlightOverlay)map.Overlays["HighlightOverlayKey"];

            USDemographicOverlay.UpdateHighlightFeature(currentFeatureLayer, mouseLocation);

            // Here we get tootip for the highlighted feature.
            bool mapNeedsUpdate = USDemographicOverlay.HighlightFeature != null &&
                                  (PreviousHighlightFeature == null || (PreviousHighlightFeature != null && PreviousHighlightFeature.Id != USDemographicOverlay.HighlightFeature.Id));

            if (mapNeedsUpdate)
            {
                toolTip1.Hide(map);
                toolTip1.Dispose();

                string resultText = string.Empty;
                foreach (string item in currentStyleBuilder.SelectedColumns)
                {
                    string columnName = TextFormatter.GetFormatedString(item, double.Parse(USDemographicOverlay.HighlightFeature.ColumnValues[item]));
                    resultText = string.Format("{0}{1}\n", resultText, columnName);
                }

                toolTip1 = new ToolTip();
                toolTip1.InitialDelay = 1000;
                toolTip1.SetToolTip(map, resultText);
                map.Refresh(USDemographicOverlay);
            }
            else if (USDemographicOverlay.HighlightFeature == null)
            {
                toolTip1.Hide(map);
                toolTip1.Dispose();
            }

            PreviousHighlightFeature = USDemographicOverlay.HighlightFeature;
        }
Exemplo n.º 4
0
        private void InitializeMap()
        {
            mapControl.MapTools.Logo.IsEnabled = true;
            mapControl.MapTools.Logo.Margin = new Thickness(0, 0, 10, 5);
            mapControl.MapTools.MouseCoordinate.IsEnabled = true;
            mapControl.MapTools.MouseCoordinate.Visibility = Visibility.Hidden;
            mapControl.MapTools.MouseCoordinate.Margin = new Thickness(0, 0, 100, 5);
            mapControl.MapTools.MouseCoordinate.MouseCoordinateType = MouseCoordinateType.Custom;

            mapControl.Overlays.Add(new WorldMapKitWmsWpfOverlay());

            censusStateFeatureLayer = new ShapeFileFeatureLayer(MapSuiteSampleHelper.GetValueFromConfiguration("UsShapefilePath"));
            censusStateFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            censusStateFeatureLayer.DrawingMarginPercentage = 100;

            demographicLayerOverlay = new LayerOverlay();
            demographicLayerOverlay.TileType = TileType.SingleTile;
            mapControl.Overlays.Add(demographicLayerOverlay);

            highlightOverlay = new HighlightOverlay();
            mapControl.Overlays.Add(highlightOverlay);

            legendAdornmentLayer = new LegendAdornmentLayer();
            legendAdornmentLayer.Location = AdornmentLocation.LowerLeft;
            legendAdornmentLayer.Title = new LegendItem();
            legendAdornmentLayer.Title.ImageJustificationMode = LegendImageJustificationMode.JustifyImageRight;
            legendAdornmentLayer.Title.TopPadding = 10;
            legendAdornmentLayer.Title.BottomPadding = 10;
            legendAdornmentLayer.Title.TextStyle = new TextStyle("Population", new GeoFont("Segoe UI", 12), new GeoSolidBrush(GeoColor.SimpleColors.Black));
            mapControl.AdornmentOverlay.Layers.Add(legendAdornmentLayer);

            DefaultFeatureLayer = censusStateFeatureLayer;

            MapControl.CurrentExtent = globeExtent;
        }