Beispiel #1
0
        private void AddMapLayer()
        {
            // Create the MapPrinterLayer and set the position
            MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();

            mapPrinterLayer.MapUnit        = GeographyUnit.Meter;
            mapPrinterLayer.MapExtent      = new RectangleShape(-20026376.39, 20048966.10, 20026376.39, -20048966.10);
            mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1));
            mapPrinterLayer.Open();

            // Set the maps position slightly below the pages center and 8 inches wide and 7 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch);

            // Setup the intial extent and ensure they snap to the default ZoomLevel
            ZoomLevelSet zoomLevelSet = new ZoomLevelSet();

            mapPrinterLayer.MapExtent = MapUtil.ZoomToScale(zoomLevelSet.ZoomLevel03.Scale, new RectangleShape(-20026376.39, 20048966.10, 20026376.39, -20048966.10), mapPrinterLayer.MapUnit, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height);

            // This ThinkGeo Cloud test key is exclusively for demonstration purposes and is limited to requesting base map
            // tiles only. Do not use it in your own applications, as it may be restricted or disabled without prior notice.
            // Please visit https://cloud.thinkgeo.com to create a free key for your own use.
            //ThinkGeoCloudRasterMapsLayer worldMapKitLayer = new ThinkGeoCloudRasterMapsLayer("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~");
            //worldMapKitLayer.TileCache = null;
            //mapPrinterLayer.Layers.Add(worldMapKitLayer);
            ShapeFileFeatureLayer backgroundLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read);

            backgroundLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            backgroundLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyle.CreateSimpleAreaStyle(GeoColors.White, GeoColors.Black);
            mapPrinterLayer.Layers.Add(backgroundLayer);

            // Setup the Countries mapping layer
            ShapeFileFeatureLayer shapefileFeatureLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read);

            shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            //Create the class break style for countries less than 70 million
            ClassBreakStyle classBreakStyle = new ClassBreakStyle("POP_CNTRY");

            // Create the style and class break for countries with greater and 70 million
            AreaStyle hatchAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColors.Green)));

            classBreakStyle.ClassBreaks.Add(new ClassBreak(70000000, hatchAreaStyle));

            // Add the class break style to the layer
            shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);

            // Add the new country layer to the MapPrinterLayer
            mapPrinterLayer.Layers.Add(shapefileFeatureLayer);

            // Add the MapPrinterLayer to the PrinterInteractiveOverlay
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"];

            printerInteractiveOverlay.PrinterLayers.Add("MapLayer", mapPrinterLayer);
        }
        private void AddMapLayer()
        {
            // Create the MapPrinterLayer and set the position
            MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();

            //Map Printer Layer is in feet (State Plane Texas North Central Feet NAD83)
            mapPrinterLayer.MapUnit = GeographyUnit.Feet;
            //Set the extent of the MapPrinterLayer with world coordinates.
            RectangleShape currentExtent = new RectangleShape(2276456, 6897886, 2280391, 6895437);

            mapPrinterLayer.MapExtent      = currentExtent;
            mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1));
            mapPrinterLayer.Open();

            // Set the maps position slightly above the page center and 8 inches wide and 7 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch);

            //Setup the styles for the parcels layer.
            ShapeFileFeatureLayer parcelsLayer = new ShapeFileFeatureLayer(@"..\..\..\Data\Shapefile\parcels.shp", FileAccess.Read);
            //Creates a value style for the parcel type (residential 1, commercial 2, industrial 3).
            ValueStyle typeValueStyle = new ValueStyle();

            typeValueStyle.ColumnName = "PARCELTYPE";
            typeValueStyle.ValueItems.Add(new ValueItem("1", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelGreen))));
            typeValueStyle.ValueItems.Add(new ValueItem("2", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelOrange))));
            typeValueStyle.ValueItems.Add(new ValueItem("3", new AreaStyle(new GeoPen(GeoColors.Black), new GeoSolidBrush(GeoColors.PastelBlue))));
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(typeValueStyle);

            //Creates a value style for affected parcels by new proposal
            ValueStyle affectedValueStyle = new ValueStyle();

            affectedValueStyle.ColumnName = "AFFECTED";
            affectedValueStyle.ValueItems.Add(new ValueItem("YES", new AreaStyle(new GeoPen(GeoColors.DarkGreen, 4), new GeoSolidBrush(GeoColors.Transparent))));
            affectedValueStyle.ValueItems.Add(new ValueItem("D", new AreaStyle(new GeoPen(GeoColors.DarkRed, 4), new GeoSolidBrush(GeoColors.Transparent))));
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(affectedValueStyle);

            //Creates a text style to display tax id of parcels
            TextStyle textStyle = new TextStyle("TAXPIN", new GeoFont("Arial", 12, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColors.Black));

            textStyle.HaloPen = new GeoPen(GeoColors.White, 2);
            parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle);
            parcelsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Add the new parcels layer to the MapPrinterLayer
            mapPrinterLayer.Layers.Add(parcelsLayer);

            // Add the MapPrinterLayer to the PrinterInteractiveOverlay
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)mapView.InteractiveOverlays["PrintPreviewOverlay"];

            printerInteractiveOverlay.PrinterLayers.Add("MapLayer", mapPrinterLayer);
        }
Beispiel #3
0
        private void ScaleLineElementEntity_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Preview" || (MapPrinterLayer.MapUnit == GeographyUnit.DecimalDegree && !PrinterLayerHelper.CheckDecimalDegreeIsInRange(MapPrinterLayer.MapExtent)))
            {
                return;
            }
            if (!MapPrinterLayer.IsOpen)
            {
                MapPrinterLayer.Open();
            }
            try
            {
                ScaleLinePrinterLayer scaleLinePrinterLayer = new ScaleLinePrinterLayer(MapPrinterLayer);
                scaleLinePrinterLayer.BackgroundMask = BackgroundStyle as AreaStyle;
                scaleLinePrinterLayer.MapUnit        = MapPrinterLayer.MapUnit;
                scaleLinePrinterLayer.UnitSystem     = SelectedUnitSystem;
                var boundingBox = MapPrinterLayer.GetBoundingBox();
                var pageCenter  = boundingBox.GetCenterPoint();
                scaleLinePrinterLayer.SetPosition(1.25, .25, -3.25, -2.25, PrintingUnit.Inch);
                using (Bitmap bitmap = new Bitmap(220, 60))
                {
                    PlatformGeoCanvas canvas = new PlatformGeoCanvas();
                    scaleLinePrinterLayer.SafeProcess(() =>
                    {
                        var scaleLineBoundingBox = scaleLinePrinterLayer.GetBoundingBox();
                        canvas.BeginDrawing(bitmap, scaleLineBoundingBox, GeographyUnit.Meter);
                        scaleLinePrinterLayer.Draw(canvas, new Collection <SimpleCandidate>());
                    });

                    //scaleLinePrinterLayer.Open();
                    //var scaleLineBoundingBox = scaleLinePrinterLayer.GetBoundingBox();
                    //canvas.BeginDrawing(bitmap, scaleLineBoundingBox, GeographyUnit.Meter);
                    //scaleLinePrinterLayer.Draw(canvas, new Collection<SimpleCandidate>());
                    //scaleLinePrinterLayer.Close();
                    canvas.EndDrawing();
                    MemoryStream ms = new MemoryStream();
                    bitmap.Save(ms, ImageFormat.Png);

                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = ms;
                    bitmapImage.EndInit();
                    Preview = bitmapImage;
                }
            }
            catch (Exception ex)
            {
                GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
            }
        }