Select to view content in your preferred language

How can I get each point of polyline from featurelayer

2416
4
Jump to solution
10-16-2012 05:08 AM
MarcinDruzgala
Frequent Contributor
So here is the question. I have a map service with feature layer that contains polylines. What I need to do programatically is to get all the map points for each polyline in my mapservice - i need x,y,z values. Can I do this?
I tried already few things but nothing works. I can't get geometry property from feature layer because it returns a String value and that doesn't help.
      Creating new polylines with an Array of MapPoints would take too much time(and it's not the way it should be done i think) and since new MapPoint takes only x,y and spatialReference parameters how can I assign a z value? Anyone got idea?

MDruzgala
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DasaPaddock
Esri Regular Contributor
hasZ should be true on your layer if it supports z values. Check for this on the REST page for the layer. e.g.,
http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer/1

If your FeatureLayer is not in a Map, it won't have any features loaded into it, but you can call queryFeatures() to get the features and their geometries:
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/FeatureLayer.html#queryFeatu...

View solution in original post

0 Kudos
4 Replies
BjornSvensson
Esri Regular Contributor
Assuming you are using version 3.0 or later (as "z/m value support in map and feature services" was added at 3.0 [whats new]).

...for each polyline in my mapservice - i need x,y,z values. Can I do this?

Yes, the map points of the arrays in the polylines should have a "z" property if your feature layer supports "z".
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/geometry/MapPoint.html#z
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/geometry/Polyline.html#hasZ

I can't get geometry property from feature layer because it returns a String value

Not sure how you are doing this, but you should be able to get the x/y/z from each feature in your feature layer.

...since new MapPoint takes only x,y...

This isn't true (if you are using the 3.0 API), see the http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/geometry/MapPoint.html
0 Kudos
DasaPaddock
Esri Regular Contributor
0 Kudos
MarcinDruzgala
Frequent Contributor
Assuming you are using version 3.0 or later
. Yes I'm using 3.0 Flex Viewer(and ofc 3.0 API).


Yes, the map points of the arrays in the polylines should have a "z" property if your feature layer supports "z".
Well I have my feature service with a layer, let's say named "road" - its a polyline layer that supports 'z' values(and 'm' but thats not the case right now).


Not sure how you are doing this, but you should be able to get the x/y/z from each feature in your feature layer.
Ok so here is what i did:
<fx:Declarations>
 <esri:FeatureLayer id="road_layer" url="http://xxxxxxx/ArcGIS/rest/services/xxxxxxx/FeatureServer/0" returnZ="true"/>
</fx:Declarations>

//And now in Script tag I tried to read this layer details so:
var layerDet:LayerDetails = road_layer.layerDetails;

this is what i get: hasZ = false, hasM = false, geometryType = "esriGeometryPolyline" ( so it's fine - but as i said it's a String only), I can't see any table with mappoints or polyline geometry at all - maybe I'm blind or something..Should I use a outFields with some query to get all the features from FeatureService? And then get arrays of map points of each polyline?

This isn't true (if you are using the 3.0 API), see the http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/geometry/MapPoint.html
Ok you are right - i did read all the API reference for mappoint and polyline. The "new MapPoint()" takes 3 parameters - x,y and spatial reference(as it's written in API reference) so what I have to do is write something like this:
var mPoint:MapPoint = new MapPoint( 100, 100, new SpatialReference(102100));
mPoint.z = {some_value};
mPoint.m = {some_value};

correct?

Since i've got your attention can you answer my second question which is in here? -> Reload-all-operational-layers-is-it-possible

Thanks guys for answering. I know it's obvious for you but I'm still learning a lot about Flex(and programming as well).

Regards,
MDruzgala
0 Kudos
DasaPaddock
Esri Regular Contributor
hasZ should be true on your layer if it supports z values. Check for this on the REST page for the layer. e.g.,
http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer/1

If your FeatureLayer is not in a Map, it won't have any features loaded into it, but you can call queryFeatures() to get the features and their geometries:
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/FeatureLayer.html#queryFeatu...
0 Kudos