/**************************************************************/
//
//Version 2.0
//Inside The API
//FeatrueLayer
/**************************************************************/
The ArcGIS API for Flex version 2.0 offers a feature layerfor working with client-side graphic features. You may be familiar with the graphics layer from previous releases. The feature layer inherits from the graphics layer and offers additional capabilities such as the ability to perform queries and selections. Feature layers are also used for Web editing.
ArcGIS API for Flex 2.0版本,提供来一个FeturrLayer与客户端的图形一起工作。从前面的章节中,你可能已经熟悉了Graphics图层了。 FeatrueLayer继承于GaraphicsLayer,并且提供了额外的功能比如:展示查询结果和选中的元素。 FeatureLayer当然也用于web 编辑。
Feature layers differ from tiled and dynamic map service layers because they bring geometry information across to the client computer to be drawn by the client. Feature layers potentially cut down on round trips to the server. A client can request the features it needs, then perform selections and queries on those features without having to request more information from the server. Feature layers are especially appropriate for layers that respond to user interaction, such as a mouse click or hover.
FeatureLayer不同于Titled和danamic 地图服务图层,因为他们把Geometry信息带到客户端计算机并在客户端绘制。 FeatureLayer潜在的消减往返服务器端的进程。一个客户端可以请求他需要的Features,然后再这些features中进行选择和查询而不用从服务器端获取请求更多个信息。FeatureLayer有一个特殊的属性,它能够响应与用户的交互,比如鼠标的单击和悬停。
A feature layer honors(光荣;敬意;荣幸 vt.给…以荣誉;尊敬) any definition queries, scale dependencies(依存, 依赖), and other properties configured on the layer in the map service. Using a feature layer, you can access related tables, perform queries, display time slices, and work with feature attachments.
一个FeatureLayer尊重每一个查询定义,依赖的比例,和在地图服务中的图层上配置的其他的属性。使用一个featurelayer,你可以访问一个相关的表格,执行查询,显示事件片段,与featureLayer的附属物一起工作。
How do I create a feature layer?
A feature layer references a single layer from either a map service or a feature service. The feature service is required for editing, but both will honor any feature templates configured in the source map document as long as you connect to a 10.0 or above ArcGIS Server. For earlier versions of server, no symbology can be retrieved from the server, but you can still use if with a feature layer.
我如何创建一个FeatureLayer?
一个FeatureLayer就是一个单独的图层,这个图层不是一个地图服务,就是一个Feture服务。 Feature 服务是需要编辑的,但是前面的两者都会hornor任何 在源图文件中陪配置的要素模板,只要你连接到一个10.0或者一个更高版本的ArcGIS 服务。 对于的Server版本,没有任何符号系统可以从server中重新获取,但是如何是它任何任然可以用于一个featureLayer。
Choosing the display mode
When you create a feature service, you also need to specify one of these modes for retrieving features:
On demand(n.要求;需要 vt.要求;需要;询问,查问)mode (the default) retrieves features as they are needed, requesting only the features within your current view extent. On demand mode potentially requires more round trips between the client and server. However, it protects you from retrieving more features than you need.
Snapshot mode retrieves all the features from the layer immediately after the layer is added to the map. This reduces subsequent traffic to the server, but can become cumbersome(笨重的) if the layer contains many features. The browser may be overwhelmed(vt.使受不了,使不知所措;征服,制服) by the number of features it needs to draw, or the service may reach its limit of how many features it can return at once. The default is 500 for ArcGIS Server
选择展示的模型
当你创建一个Feature 服务,你仍然需要指定这些modes中的一个用于重新获取features:
在需求模型中,根据他们的需要重新获取features,仅仅对当前视图范围内的的要素发送请求。On demand模型潜在的要求更多的客户端和服务器端之间的往返。尽管如此,他也保护你重新获取比你需要的更过的Features。
Snapshot模型:当地图图层添加到地图的时候,Snapshot模型将立刻从图层上面获取所有的Features。这就减少了随后的前往服务器的交通,但是如果图层包含很多的features,那么他将会变得非常繁重。 浏览器可能会以因为它需要绘制的features的数目太多而受不了崩溃,或者服务已经达到了每次他能返回的feature数目的极限。 ArcGIS Server
对于一些小的数据集或者临时的数据我们可以使用Snapshot模型。
Selection mode does not initially request any features. Features are added only when a selection is made. This mode is useful when you cannot or do not want to bring all features into the client, but you want to highlight one or more features for a certain reason, e.g. editing, querying, or accessing related tables. Selections are drawn using a client-side selection color that you specify on the feature layer.
Selection模型:selection模型在初始化的时候没有请求人和的features. Features只有当生成一个selection的时候才会被添加。当你不能或者不想把所有的feature回到的客户端的时候是非常有用的,但是为了某一些原因你想高亮显示一个或者更多的features,比如:编辑,查询,或者访问相关的表格。使用你在feature layer上指定的客户端selection颜色绘制selections。
Query example: you can use a dynamic service for your general map representation(表示法, 表现, 陈述, 答辩), but when doing an identify or query you want to highlight the selected features.
Editing example: only the selected feature will be highlighted on the map with in the FeatureLayer. Once editing is complete, the selection is removed from the feature layer and user can update the dynamic map service layer to see the updated feature.
查询例子:你可以使用dynamic(动态)服务作为你的普通地图描述,但是当执行查询或者鉴定你会想点亮那些被选中的feature。
编辑例子:只有featureLayer中被选中的要素才能在地图中被高亮显示。一旦完成编辑,被选中的部分将会从features上转移出来,用户可以更新dynamic地图服务来查看更新后feature。
Note: No matter which of the display modes you choose for your feature layer, selected features are always held on(继续,抓住不放) the client. For example, if you are using the on demand display mode and you've selected some features, panning away from those selected features will still result in the features being available on the client. Your application will not have to re-select the features or make any other request to the server if you pan back to the original area. For this reason, it is a good practice to clear your selected features once they are no longer needed.
Choosing the attributes you need
注意:不管你为你的feature layer选择哪种显示模型,被选中的要素都在客户端被抓住不放。 比如:如果你正在使用on demand 显示模型,你已经选中了一些Features,从这些被选中的features上面平移走,仍然会导致这些features在客户端是可用的。当你回到原始的显示区域的时候,你的应用程序就不用重新选择要素或者生成服务器端的请求。基于这个原因,一旦这些Select feature不在使用,那么清除这些你选中的features就是一个很好的做法
Feature layers retrieve both feature geometries and attribute information. When you create the feature layer, you can set the outFields property to specify which attributes will be retrieved for your features. It is possible to use "*" to get all the fields, but to reduce the amount of information sent between the client and server, you should request only the fields you need in your application. If you later perform a query using the feature layer, the query will honor the out fields you set.
What can I do with a FeatureLayer?
Feature layers重新获取feature的geometries和属性信息。 当你创建feature layer,你可以设置outFieldsw属性来指定那些属性可以从你的feature中重新获取。也可以使用*获取所有的fields,但是为了减少客户端和服务器之间发送信息的数量,你应该仅仅去请求那些你在你的应用程序中使用的fields。如果你使用feature layer来执行一个查询,查询将会使用(兑现)你设置的输入fields。
Feature layers make it possible for you to do all of the following:
Editing
Feature layers are the key to editing features with the Web APIs. The editing components included in the APIs are designed to work with feature layers. You can only perform editing on feature layers that reference an editable layer within a feature service. See Editing to learn more about this requirement and how to create a feature service.
Feature layser 能够让你去做下面所有的事情:
编辑:
Feature layer 是你使用WEB APIs编辑features的关键。 包含在APIs中的编辑组件被设计为同feature一同工作。你只能在一个feature layer中执行编辑功能,这个feature layer在一个feature服务中表示一个可以编辑的layer。 查看Editing 获取更多的关乎于这个操作的要求和如何创建一个Feature service。
Definition expressions
There may be times(有些时候) where you want to work with features that satisfy certain attribute criteria and disregard the rest. In this type of situation, you can set a definition expression on the feature layer to retrieve just the features you need. Every feature layer has a default definition expression, which comes from the definition query set in the source map document.
定义表达式:
有些时候你可能使用那些和特定属性想匹配的features并忽视其他的不匹配的。 在这种情况下,你可以在feature layer上面设置一个定义表达式来仅仅获取那些你需要的。没有一个featureLayer都有一个默认的定义表达式,她来自于在源地图文件中设置的查询定义。
Time definitions
When using a feature layer in snapshot mode, you can retrieve features that meet a certain temporal criteria(标准、准则) using the timeDefinition on the feature layer. For example, you might want to only load houses that were built before 1930.
时间定义:
当在snapshot模型中使用一个featurelayer,你能使用在featureLaye上面的timeDefinition来重新获取那些满足某些临时准则的features。 比如:你仅仅想要加载在1930年以前建造的的房屋。
Selection and display
The feature layer supports a selection, which represents a subset of features that the user has chosen to isolate for viewing, editing, or analytical purposes. Users can add or remove features from the selection based on spatial or attribute criteria. The feature layer makes it easy to draw the selection set with a different type of symbol than the other features. If you don't specify the symbol, a default symbol will be applied. This was previously challenging to do without using two graphics layers.
A selection set can be used as input for statistical(统计的、统计学的) calculations, geoprocessing tools, and graphing, opening the possibility for interactive GIS analysis and exploration. For example, users can draw a polygon to select a set of buildings, then push a button to calculate the solar potential of those buildings. Selections also play an important role in some editing workflows where the feature currently undergoing edits is highlighted.
选择并展示
Feature layer支持选择,他代表着用户选择的的一个feature子集,这个子集是用户单独选择的,主要用于:查看、编辑、和分析等目的。 用户可以基于控件或者属性准则来添加feature或者从selection中删除features。可以绘制selections的显示样式和其他的features样式不同,并且Feature layer是这些更加容易。如果你不指定symbol,一个默认的symbol将会使用,
在以前,如果不使用两个Graphics layers 来实现这个功能将是一个挑战 。
一个selection可以作为统计学计算、地理处理工具和图形的输入数据。是之与GIS的交互分析 和研究成为可能。比如:用户可以绘制一个polygon来选择一个大楼的集合,然后单击按钮计算这些大楼潜在的太阳能。 Selection还在一些编辑工作流中起着重要的作用,比如:处于编辑状态的的features高亮显示。
To make your selection, use the selectFeatures() method on FeatureLayer which takes a Query object as an argument. If you are interested in querying your feature layer without adding the results to the selection set, you can use either queryFeatures() or queryRelatedRecords() instead. With any of these methods, you cannot request features outside of any definition expressions set in the map document or on the feature layer.
Related Samples
The ArcGIS API for Flex has several samples that show how to work with feature layers. Here are a few you may find useful:
为来生成selection,在FeatruesLayer中使用selectFeatures(),它将一个查询的对象作为一个参数。 如果你有兴趣查询你的features layers而不用添加selections到这个selection set,你可以使用queryFeatures()或者queryRelatedRecords()。使用给上面的任何一种方法,你都不能请求在地图文档或者feature layer中的定义表达式之外的features。
相关的例子
Based on MapServer layer - using default mode (on demand).
FeatureLayer tooltips - using snapshot mode.
Search with FeatureLayer - using definitionExpression and snapshot mode.
InfoWindows for FeatureLayer - using definitionExpression and default mode (on demand).
InfoWindow on Click - using on demand mode.
InfoWindow on MouseOver - using snapshot mode, definitionExpression and graphicAdd.
Related records - using selectFeatures() and selection mode.
Multiple related records - using queryRelatedFeatures() and selection mode.
Clustering - using clusterer, definitionExpression and graphicAdd.
Time rendered 5K run - using FeatureCollection.