private byte[] getLayerCountByType(System.Collections.Specialized.NameValueCollection boundVariables, ESRI.ArcGIS.SOESupport.JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { IMapImage mapImage = null; bool? shouldAdd = null; operationInput.TryGetAsBoolean("addlayer", out shouldAdd); if (shouldAdd.HasValue) { if ((bool)shouldAdd) { if (((IMapServerInfo4)mapServerInfo).SupportsDynamicLayers) { IRgbColor color = new RgbColor(){ Blue = 255}; ISimpleLineSymbol outline = new SimpleLineSymbol(){ Color = color, Width = 1, Style = esriSimpleLineStyle.esriSLSSolid }; ISimpleFillSymbol sfs = new SimpleFillSymbol(){ Color = color, Outline = outline, Style = esriSimpleFillStyle.esriSFSSolid }; ISimpleRenderer sr = new SimpleRenderer(){ Symbol = (ISymbol)sfs }; IFeatureLayerDrawingDescription featureLayerDrawingDesc = new FeatureLayerDrawingDescription(){ FeatureRenderer = (IFeatureRenderer)sr }; IMapServerSourceDescription mapServerSourceDesc = new TableDataSourceDescriptionClass(); ((IDataSourceDescription)mapServerSourceDesc).WorkspaceID = "MyFGDB"; ((ITableDataSourceDescription)mapServerSourceDesc).TableName = "B"; IDynamicLayerDescription dynamicLayerDesc = new LayerDescriptionClass(){ ID = 3, Visible = true, DrawingDescription = (ILayerDrawingDescription)featureLayerDrawingDesc, Source = mapServerSourceDesc }; mapDesc.HonorLayerReordering = true; mapDesc.LayerDescriptions.Insert(0, (ILayerDescription)dynamicLayerDesc); mapImage = exportMap(); } } else { mapImage = exportMap(); } } responseProperties = null; JSONObject json = new JSONObject(); json.AddString("URL", mapImage.URL); return Encoding.UTF8.GetBytes(json.ToJSONString(null)); }
private IMapImage exportMap() { //export the map using the current map description IImageType imageType = new ImageType() { Format = esriImageFormat.esriImagePNG32, ReturnType = esriImageReturnType.esriImageReturnURL }; ImageDisplay id = new ImageDisplay() { Height = 400, Width = 400, DeviceResolution = 150 }; //sample has this from ImageDisplay also IImageDescription idesc = new ImageDescriptionClass(); idesc.Display = id; idesc.Type = imageType; return ((IMapServer4)ms).ExportMapImage((IMapDescription)mapDesc, idesc); }
How to draw a dynamic layer to a map server如何在map server中添加一个动态图层呢?
This is a C# sample shows how to draw a dynamic layer in a .NET SOE. It shows how to create and use the JSONObject CoClass and IJSONObject interface.
这是一个C#例子,向你展示如何在一个.NET SOE中绘制一个动态图层。它展示了如何创建并且使用JSONObject CoClass和IJSONObject接口。
[Documentation on LayerDescription CoClass] (http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//001200000rzt000000)
关于LayerDescription CoCloass请参照
Features
- Uses IDynamicLayerDescription使用IDynamicLayerDescription
- Uses JSONObject CoClass使用JSONObject CoClass
- Uses IMapServerDataAccess使用IMapServerDataAccess
- Uses IMapServerInfo使用IMapServerInfo
file:///C:/Users/RATE_YU/Documents/Visual%20Studio%202010/Projects/ServerSimpleRESTSOE/ReadMe.htm
不要过程,只要结果
参考:https://www.cnblogs.com/giser-whu/p/3707061.html (ArcEngine下动态数据的实现显示——GIS经常需要以高频率显示信息并能够清晰的传递地理信息。包括:以动画的方式移动物体,更新位置方位,大小,状态以及属性信息等,这些信息需要迅速更新。)
要用IE浏览器部署。。否则会出现token验证问题,不知道为什么。