动态更改地图图层符号系统 (ArcGIS Server)

发布于 2024-08-11 09:45:40 字数 93 浏览 4 评论 0原文

动态更改图层符号系统的首选方法是什么?我的 Web 应用程序通过 REST API 使用地图服务,但我不介意使用 SOAP API 或 ArcObjects (.NET)。

What is the preferred method of altering a layer's symbology dynamically? My web app consumes a map service via the REST API, but I don't mind using the SOAP API or ArcObjects (.NET).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧城烟雨 2024-08-18 09:45:40

从版本 2.0 开始,ESRI JS API 中就存在功能层。

ESRI API 示例展示了如何使用渲染器通过要素图层通过指定的唯一值和属性来更改动态地图服务的默认符号系统。类中断渲染器。由于要素图层源自图形图层对象,因此它们的渲染方式不同(客户端与服务的即时 img/tile 导出)。尽管如此,它们确实允许根据开发人员定义的字段/值更改图层外观。

请注意在动态地图服务上使用唯一值渲染:

示例(代码) http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/renderer_unique_value.html

实时示例
http://developers.arcgis.com/en/javascript/samples/renderer_unique_value/

var defaultSymbol = new esri.symbol.SimpleFillSymbol().setStyle(                                                                                                        
esri.symbol.SimpleFillSymbol.STYLE_NULL);
defaultSymbol.outline.setStyle(esri.symbol.SimpleLineSymbol.STYLE_NULL);

    //create renderer
    var renderer = new esri.renderer.UniqueValueRenderer(defaultSymbol, "SUB_REGION");

    //add symbol for each possible value
    renderer.addValue("Pacific", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0, 0.5])));
    renderer.addValue("Mtn", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 255, 0, 0.5])));
    renderer.addValue("N Eng", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 0, 255, 0.5])));
    renderer.addValue("S Atl", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 255, 0.5])));
    renderer.addValue("Mid Atl", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 255, 255, 0.75])));
    renderer.addValue("E N Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 255, 255, 0.5])));
    renderer.addValue("W N Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 255, 0, 0.5])));
    renderer.addValue("E S Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([127, 127, 127, 0.5])));
    renderer.addValue("W S Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 0, 0, 0.5])));

    var featureLayer = new esri.layers.FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/1", {
      mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
      outFields: ["SUB_REGION"]
    });

    featureLayer.setRenderer(renderer);
    map.addLayer(featureLayer);

As of version 2.0, feature layers existed in the ESRI JS API.

ESRI API samples show the use of renderers being used to change the default symbology for dynamic map services via feature layers through assigned unique value & class breaks renderers. As feature layers are derived from the graphics layer object, they render differently (client side vs. services' on the fly img/tile export). Nevertheless, they do allow the alteration of a layers appearance based on developer defined fields/values.

Note the use of a unique value render on a dynamic map service in this:

example (code) http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/renderer_unique_value.html

live sample
http://developers.arcgis.com/en/javascript/samples/renderer_unique_value/

var defaultSymbol = new esri.symbol.SimpleFillSymbol().setStyle(                                                                                                        
esri.symbol.SimpleFillSymbol.STYLE_NULL);
defaultSymbol.outline.setStyle(esri.symbol.SimpleLineSymbol.STYLE_NULL);

    //create renderer
    var renderer = new esri.renderer.UniqueValueRenderer(defaultSymbol, "SUB_REGION");

    //add symbol for each possible value
    renderer.addValue("Pacific", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0, 0.5])));
    renderer.addValue("Mtn", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 255, 0, 0.5])));
    renderer.addValue("N Eng", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 0, 255, 0.5])));
    renderer.addValue("S Atl", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 255, 0.5])));
    renderer.addValue("Mid Atl", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 255, 255, 0.75])));
    renderer.addValue("E N Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 255, 255, 0.5])));
    renderer.addValue("W N Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 255, 0, 0.5])));
    renderer.addValue("E S Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([127, 127, 127, 0.5])));
    renderer.addValue("W S Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 0, 0, 0.5])));

    var featureLayer = new esri.layers.FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/1", {
      mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
      outFields: ["SUB_REGION"]
    });

    featureLayer.setRenderer(renderer);
    map.addLayer(featureLayer);
烧了回忆取暖 2024-08-18 09:45:40

REST API 是无状态的,因此您无法通过连接到 RESTful 服务来更改符号系统(尽管您可以使用图形层来动态提取要以不同方式显示的功能)。

使用 SOAP API(通过 Web ADF 或简单地通过 SOAP 手动连接到服务)并更改其中的符号系统,您会获得更好的运气。有关此内容的更多信息,请访问:http:// forums.esri.com/Thread.asp?c=158&f=2421&t=266974

The REST API is stateless, so you can't change the symbology via a connection to a RESTful service (although you could use a graphics layer to dynamically extract the features you want to display differently).

You'll have better luck using the SOAP API (via the Web ADF or simply connecting to the service via SOAP manually) and altering the symbology there. More information about this is available here: http://forums.esri.com/Thread.asp?c=158&f=2421&t=266974

孤君无依 2024-08-18 09:45:40

如果您想要更改地图服务中符号的外观,则需要使用 WebADF 或创建您自己的使用 SOAP API 的服务。更改符号然后生成图像的实际操作非常简单,困难的部分是获得开放层来使用它。我要么不打扰,要么按照迈克尔的建议,将图形带回客户端并使用 OpenLayers 根据需要绘制它们,也许将图层设置为在地图服务中不可见,以便它们不会显示在图形下方。

If you want to change the appearance of the symbol in the map service its self then you need to either use the WebADF or create your own service that uses the SOAP API. The actual bit to change the symbol and then produce an image is quite easy, the hard part will be to then get open layers to consume it. I would either not bother or do as Michael suggests and bring back graphics to the client and draw them as you wish using OpenLayers, maybe have the layer set to invisible in the map service, so that they don't show up under the graphics.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文