Lots of map queries when using the SnappingManager with a FeatureLayer with MODE_ONDEMAND

918
2
05-08-2017 09:42 AM
YohanBienvenue
Occasional Contributor II

I enabled snapping on the Map and I'm using a couple of FeatureLayers with MODE_ONDEMAND with it so that it can fetch all the required geometry from the MapServer required for snapping to lines in the map.

It works fine, but I noticed that for each pan or zoom operation in the map, the API triggers a total of 3 to 6 identical queries to the map server to get the FeatureLayer geometry. A zoom operation always triggers 12 queries (6 per FeatureLayer). They are all identical queries except a small difference in the xmin and xmax of the geometry used for the spatial intersection in the query.

I'm assuming the map generates a bunch of extent-change events when zooming and that the SnappingManager accepts them all and makes a query to get the FeatureLayer geometries for each of them. (We have over 215 clients/map services so this is pretty wasteful. Especially since we plan to throttle the map services using a resource-proxy in the near future. All these queries will make it harder to configure the proxy properly.)

Is there a way to maybe throttle the extent-change events the map generates?

Thanks for the help, I attached a screenshot of all the queries it generates for a single zoom in the map.

EDIT: I'm not using MODE_SNAPSHOT with the FeatureLayer because it would then be limited to 1000 features as set by the map service config and 1000 is not enough is some situations.

Yohan

0 Kudos
2 Replies
KellyHutchins
Esri Frequent Contributor

The behavior you are seeing is due to vector tiling. You can read up on what it is and how it works here: 

Feature Layer Best Practices | Guide | ArcGIS API for JavaScript 3.20 

Why is this making it difficult to configure your proxy? 

0 Kudos
YohanBienvenue
Occasional Contributor II

Oh I see, ok so the whole map is already subdivided in tiles, and after a zoom/pan event there instead of making 1 request to get all the features in the extent, the api makes 1 request for each tile visible in the current extent, and each request specifies the row/column for this tile. Thanks for the info, I thought they were all the same requests but clearly they are not.

Long story short, 2 months ago our map services were "attacked" severely by script bots to try and get our data in bulk (which we do not allow). To prevent this we put in place the resource-proxy and disabled direct access through the previous URLs. One of the parameters of the proxy is "rate limiting", meaning if the user makes more then X requests in Y time, then the proxy rejects the request with a 429 Too Many requests response. So, if Snapping is enabled and the API suddenly makes all those requests, I had difficulty figuring out a good value for this "rate limiting" parameter. When snapping was enabled we reached the limit very quickly. In the end we decided to just disable Snapping for our public access mode, so we worked around the issue this way.

Thanks

0 Kudos