Route FeatureLayer MODE_ONDEMAND: how to set the query return m-data in geometry?

708
2
Jump to solution
03-05-2013 11:11 AM
SimonLeo
New Contributor III
In my application, there is a m-aware route layer from a feature service. This layer is for reference use, but the front-end does need its mile information along with each vertex's X/Y coordinates. By default, the layer's mode is MODE_ONDEMAND, which is ideal for my app, because am trying to reduce unnecessary remote data request. However, this mode only returns X&Y coordinates in geometry info, how should I do to configure it return M?

I know this is doable in MODE_SELECTION via selectFeatures(), but that requires me write extra query functions in several scenarios to make it work similar to MODE_ONDEMAND, for example, need to listen to events, including map_pan, map_zoom, or extentchange. Which I wish I don't have to do this.

thanks for all advice!
0 Kudos
1 Solution

Accepted Solutions
SimonLeo
New Contributor III
I realize just using onExtentChange will do it.

View solution in original post

0 Kudos
2 Replies
SimonLeo
New Contributor III
I realize just using onExtentChange will do it.
0 Kudos
SimonLeo
New Contributor III
followup:

1. current JS API doesn't support automatically render m-aware geometry/features on UI. so if you either using MODE_ONDEMAND or writing a query function to load data from ArcGIS Server then add the result features into a feature layer, you won't get any route measure data in feature geometry. even if you set query.returnM = true.  (simply because the query class only support those customized request parameters, even if returnM is defined in REST API.)

2. you can get all X,Y,M geometry data via esri.request function by providing all request parameters including returnM; however, you'll have a difficult time adding features into feature layer and render them. the error will be related to geometry, doesn't have getExtent() method etc.., which turns out the geometry of response feature is not valid. what you can do is: for each feature, re-create a brand new geometry object based on its geometry type, then copy the data from returned feature geometry to this newly created geometry object. then, create a new graphic, set its geometry/attributes etc., and add it to the layer. this shall work.


I realize just using onExtentChange will do it.
0 Kudos