GetMapImage() public method

根据地图参数、图片输出设置获取地图图片。
public GetMapImage ( string mapName, MapParameter mapParameter, ImageOutputOption imageOutputOption ) : MapImage
mapName string 地图名称。
mapParameter SuperMap.Connector.Utility.MapParameter 地图参数。
imageOutputOption SuperMap.Connector.Utility.ImageOutputOption 图片输出设置。
return SuperMap.Connector.Utility.MapImage
コード例 #1
0
        public void GetMapImage_CreateThemeGraph()
        {
            ThemeGraph themeGraph = new ThemeGraph();
            themeGraph.Type = ThemeType.GRAPH;
            themeGraph.GraphType = ThemeGraphType.BAR3D;
            themeGraph.GraduatedMode = GraduatedMode.SQUAREROOT;
            themeGraph.AxesDisplayed = true;
            themeGraph.MaxGraphSize = 1;
            themeGraph.MinGraphSize = 0.35;
            themeGraph.GraphTextDisplayed = true;
            themeGraph.GraphTextFormat = GraphTextFormat.VALUE;
            themeGraph.BarWidth = 0.03;

            var item1 = new ThemeGraphItem();
            item1.Caption = "1";
            item1.GraphExpression = "Pop_Rate95";
            var style1 = new SuperMap.Connector.Utility.Style();
            style1.FillForeColor = new SuperMap.Connector.Utility.Color(211, 111, 240);
            item1.UniformStyle = style1;

            var item2 = new ThemeGraphItem();
            item2.Caption = "人口";
            item2.GraphExpression = "Pop_Rate99";
            var style2 = new SuperMap.Connector.Utility.Style();
            style2.FillForeColor = new SuperMap.Connector.Utility.Color(92, 73, 234);
            item2.UniformStyle = style2;

            themeGraph.Items = new ThemeGraphItem[] { item1, item2 };

            UGCThemeLayer themeLayer = new UGCThemeLayer();
            themeLayer.DatasetInfo = new DatasetInfo();
            themeLayer.DatasetInfo.DataSourceName = "Jingjin";
            themeLayer.DatasetInfo.Name = "BaseMap_R";
            themeLayer.DatasetInfo.Type = DatasetType.REGION;
            themeLayer.Description = "动态统计专题图";

            themeLayer.UgcLayerType = UGCLayerType.THEME;
            themeLayer.Type = LayerType.UGC;
            themeLayer.Visible = true;
            themeLayer.Theme = themeGraph;

            MapParameter mapParameter = new MapParameter();
            mapParameter.CacheEnabled = false;
            mapParameter.Center = new Point2D(116.755063, 39.803942);
            mapParameter.Scale = 1.0 / 1589406.44119042;
            mapParameter.RectifyType = RectifyType.BYCENTERANDMAPSCALE;
            mapParameter.Name = "动态统计专题图";
            mapParameter.ColorMode = MapColorMode.DEFAULT;

            mapParameter.Layers = new List<Layer>();
            mapParameter.Layers.Add(themeLayer);
            mapParameter.Viewer = new SuperMap.Connector.Utility.Rectangle(0, 0, 500, 400);

            Map map = new Map("http://" + ip + ":8090/iserver/services/map-jingjin/rest");
            ImageOutputOption imgageOutputOption = new ImageOutputOption();

            MapImage imageResult = map.GetMapImage("京津地区人口分布图_专题图", mapParameter, imgageOutputOption);
            using (MemoryStream memoryStream = new MemoryStream(imageResult.ImageData))
            {
                Bitmap bmp = new Bitmap(memoryStream);
                Assert.IsTrue(bmp.Width == 500);
                Assert.IsTrue(bmp.Height == 400);
                Assert.IsTrue(bmp.GetPixel(309, 293).R == 211);
                Assert.IsTrue(bmp.GetPixel(309, 293).G == 111);
                Assert.IsTrue(bmp.GetPixel(309, 293).B == 240);
            }
        }
コード例 #2
0
        public void GetMapImage()
        {
            Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
            MapParameter mapParameter = map.GetDefaultMapParameter("世界地图");
            List<Layer> tempLayer = new List<Layer>();
            tempLayer.Add(mapParameter.Layers[12]);
            tempLayer.Add(mapParameter.Layers[13]);
            mapParameter.Layers = tempLayer;

            SuperMap.Connector.Utility.Rectangle rect = new SuperMap.Connector.Utility.Rectangle();
            rect.LeftTop = new SuperMap.Connector.Utility.Point();
            rect.RightBottom = new SuperMap.Connector.Utility.Point();
            rect.LeftTop.X = 0;
            rect.LeftTop.Y = 0;
            rect.RightBottom.X = 600;
            rect.RightBottom.Y = 480;
            mapParameter.Viewer = rect;

            mapParameter.Center = new Point2D();
            mapParameter.Center.X = 0;
            mapParameter.Center.Y = 0;

            MapImage mapImage = map.GetMapImage("世界地图", mapParameter, null);
            using (MemoryStream memoryStream = new MemoryStream(mapImage.ImageData))
            {
                Bitmap bmp = new Bitmap(memoryStream);
                Assert.IsTrue(bmp.Width == 600);
                Assert.IsTrue(bmp.Height == 480);
            }
        }
コード例 #3
0
 public void GetMapImage_ReturnUrl()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     MapParameter mapParameter = new MapParameter()
     {
         Center = new Point2D(0, 0),
         Scale = 0.0000000013138464,
         Viewer = new Utility.Rectangle(0, 0, 256, 256)
     };
     ImageOutputOption option = new ImageOutputOption()
     {
         ImageOutputFormat = ImageOutputFormat.GIF,
         ImageReturnType = ImageReturnType.URL
     };
     MapImage mapImage = map.GetMapImage("世界地图", mapParameter, option);
     Assert.IsNotNull(mapImage);
     Assert.IsTrue(!string.IsNullOrWhiteSpace(mapImage.ImageUrl));
     HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(mapImage.ImageUrl);
     HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
     Stream stream = response.GetResponseStream();
     Assert.IsNotNull(stream);
 }
コード例 #4
0
 public void DynicProject()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     MapParameter mapParameter = new MapParameter();
     mapParameter.PrjCoordSys = new PrjCoordSys();
     mapParameter.PrjCoordSys.EpsgCode = 3857;
     mapParameter.Center = new Point2D(0, 0);
     mapParameter.Scale = 0.0000000013138464;
     mapParameter.Viewer = new Utility.Rectangle(0, 0, 256, 256);
     mapParameter.RectifyType = RectifyType.BYCENTERANDMAPSCALE;
     mapParameter.CacheEnabled = false;
     ImageOutputOption option = new ImageOutputOption();
     option.ImageOutputFormat = ImageOutputFormat.PNG;
     option.ImageReturnType = ImageReturnType.BINARY;
     MapImage image = map.GetMapImage("世界地图", mapParameter, option);
     Assert.IsTrue(image != null);
     using (MemoryStream stream = new MemoryStream(image.ImageData))
     {
         Bitmap bmp = (Bitmap)Image.FromStream(stream);
         System.Drawing.Color t = bmp.GetPixel(200, 230);
         Assert.IsTrue(t.A == 255);
         Assert.IsTrue(t.R == 196);
         Assert.IsTrue(t.G == 193);
         Assert.IsTrue(t.B == 225);
     }
 }