Adf中的渲染学习

    技术2022-05-19  23

    代码块一

    FeatureLayer fl = new FeatureLayer(); ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer gLayer = ESRI.ArcGIS.ADF.Web.Converter.ToGraphicsLayer(dt, System.Drawing.Color.Black, System.Drawing.Color.Red, System.Drawing.Color.Blue, true); ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer eLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer(); MapFunctionality mapFunctionality = Map1.GetFunctionality("cmService") as MapFunctionality; //Map1.GetFunctionalities() // mapFunctionality.d ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer fLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer(ESRI.ArcGIS.ADF.Web.FeatureType.Point); // fLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer)dt; // fLayer ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource gResource = new ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource(); // gResource.Graphics.Tables.Add(dt);

     

    代码块二

    ESRI.ArcGIS.ADF.Web.Geometry.Point adfStarPoint = new ESRI.ArcGIS.ADF.Web.Geometry.Point(121.56275200, 31.65820800); ESRI.ArcGIS.ADF.Web.Geometry.Point adfEndPoint = new ESRI.ArcGIS.ADF.Web.Geometry.Point(121.56273300, 31.65814300); //构造一个线型 ESRI.ArcGIS.ADF.Web.Geometry.Polyline adfPolyline = new ESRI.ArcGIS.ADF.Web.Geometry.Polyline(); ESRI.ArcGIS.ADF.Web.Geometry.Path adfPath = new ESRI.ArcGIS.ADF.Web.Geometry.Path(); adfPath.Points.Add(adfStarPoint); adfPath.Points.Add(adfEndPoint); adfPolyline.Paths.Add(adfPath); //地图定位到该点 Map1.CenterAt(adfStarPoint); //获得临时图层的数据源 ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource Resource1; ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality mf = Map1.GetFunctionality("Graphics"); Resource1 = mf.Resource as ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource; //创建或获得已经有的临时高亮图层ElementGraphicsLayer,这种图层可以同时容纳点、线、面多种类型 ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer layer = null; if (Resource1.Graphics.Tables.Count == 0) { layer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer(); layer.TableName = "Graphics"; Resource1.Graphics.Tables.Add(layer); } else { layer = Resource1.Graphics.Tables[0] as ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer; } //将临时图元“点”加入ElementGraphicsLayer ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement elementPoint = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(adfStarPoint, System.Drawing.Color.Red); elementPoint.Symbol.Transparency = 0.5; layer.Add(elementPoint); //将临时图元“线”加入ElementGraphicsLayer ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement elementPolyline = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(adfPolyline, System.Drawing.Color.Red); elementPolyline.Symbol.Transparency = 0.5; layer.Add(elementPolyline); //加入用户自定义JS反馈 ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult callbackResult; callbackResult = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript("alert('定位成功!')"); Map1.CallbackResults.Add(callbackResult); //刷新TOC控件 Toc1.Refresh(); Map1.CallbackResults.CopyFrom(Toc1.CallbackResults); //因为数据源发生了变化,必须刷新MAP对象 Map1.Refresh(); //返回前台 response = Map1.CallbackResults.ToString();

     

    代码块三

    / //获得临时图层的数据源 ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource Resource1; ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality mf = Map1.GetFunctionality("Graphics"); Resource1 = mf.Resource as ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource; for (int i = 0; i < dt.Rows.Count; i++) { ESRI.ArcGIS.ADF.Web.Geometry.Point adfStarPoint = new ESRI.ArcGIS.ADF.Web.Geometry.Point(Convert.ToDouble(dt.Rows[i]["x"]), Convert.ToDouble(dt.Rows[i]["y"])); //创建或获得已经有的临时高亮图层ElementGraphicsLayer,这种图层可以同时容纳点、线、面多种类型 ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer layer = null; if (Resource1.Graphics.Tables.Count == 0) { layer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer(); layer.TableName = "Graphics"; Resource1.Graphics.Tables.Add(layer); } else { layer = Resource1.Graphics.Tables[0] as ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer; } //将临时图元“点”加入ElementGraphicsLayer ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement elementPoint = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(adfStarPoint, System.Drawing.Color.Red); elementPoint.Symbol.Transparency = 0.5; layer.Add(elementPoint); }


    最新回复(0)