public GetTile ( string mapName, |
||
mapName | string | 地图名称。 |
tileInfo | 地图分块信息。 | |
imageOutputOption | 图片输出设置。 | |
return |
public void GetTileTest_ByTempLayer() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); TileInfo tileInfo = new TileInfo(); tileInfo.Scale = 0.00000002; tileInfo.Height = 512; tileInfo.Width = 512; TileIndex tileIndex = new TileIndex() { RowIndex = 2, ColIndex = 1 }; tileInfo.TileIndex = tileIndex; MapParameter mapParameter = map.GetDefaultMapParameter("世界地图"); List<Layer> tempLayer = new List<Layer>(); tempLayer.Add(mapParameter.Layers[12]); mapParameter.Layers = tempLayer; ImageOutputOption imageOutputOption = new ImageOutputOption(); imageOutputOption.ImageReturnType = ImageReturnType.BINARY; imageOutputOption.Transparent = false; imageOutputOption.ImageOutputFormat = ImageOutputFormat.PNG; MapImage mapImage = map.GetTile("世界地图", tileInfo, imageOutputOption, mapParameter); using (MemoryStream memoryStream = new MemoryStream(mapImage.ImageData)) { Bitmap bmp = new Bitmap(memoryStream); Assert.IsTrue(bmp.Width == 512); Assert.IsTrue(bmp.Height == 512); System.Drawing.Color color = bmp.GetPixel(240, 389); Assert.IsTrue(color.R == 242); Assert.IsTrue(color.G == 239); Assert.IsTrue(color.B == 233); } Assert.IsNull(null); }
public byte[] GetTile(TileInfo tileInfo) { int iLevel = 0; if (!int.TryParse(tileInfo.Index.LevelId, out iLevel)) return null; double scale = _scales[iLevel]; SuperMap.Connector.Utility.TileInfo iserverTileInfo = new SuperMap.Connector.Utility.TileInfo(); iserverTileInfo.Height = this._tileSize; iserverTileInfo.Width = this._tileSize; iserverTileInfo.TileIndex = new SuperMap.Connector.Utility.TileIndex(); iserverTileInfo.TileIndex.ColIndex = tileInfo.Index.Col; iserverTileInfo.TileIndex.RowIndex = tileInfo.Index.Row; iserverTileInfo.Scale = scale; SuperMap.Connector.Utility.ImageOutputOption option = new Utility.ImageOutputOption(); option.Transparent = false; if (mapParameter != null) { option.Transparent = true; } Map map = new Map(this._serviceUrl); return map.GetTile(this._mapName, iserverTileInfo, option, this.mapParameter).ImageData; }
public void GetTileTest_Normal() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); TileInfo tileInfo = new TileInfo(); tileInfo.TileIndex = new TileIndex() { ColIndex = 2, RowIndex = 1 }; tileInfo.Height = 256; tileInfo.Width = 256; tileInfo.Scale = 0.0000002; MapImage mapImage = map.GetTile("世界地图", tileInfo, null); using (MemoryStream memoryStream = new MemoryStream(mapImage.ImageData)) { Bitmap bmp = new Bitmap(memoryStream); System.Drawing.Color systemColor = bmp.GetPixel(136, 48); Assert.IsTrue(systemColor.R == 153); Assert.IsTrue(systemColor.G == 179); Assert.IsTrue(systemColor.B == 204); } }