Map click events for larger feature layers

726
2
12-14-2016 03:02 PM
PaigeKercher
New Contributor

I have a feature layer of ~200,000 parcels that I need users to be able to click on individually and display popup information and highlight a given parcel. Because of the 4,000 feature limit imposed in the 4.x API, I have published the layer as a vector tile layer so that I can display all the parcels. Otherwise, if I try to share the feature layer as a service, only 4,000 of the 200,000 parcels are drawn. However, a popup still generates on each clicked feature, even if it's not one of the lucky 4,000. But because I need both, I have a vector tile layer drawn over the feature layer, which I have given null symbology (no fill or outline). One layer is for showing the parcels (tile), and one layer is for accessing the popup data (feature layer). This seems like a cumbersome workaround, but it's what I've come up with given my project needs and the limitations of the 4.x API. 

So here's my problem: I need to be able to highlight each parcel as it's clicked on, but the view.hitTest method only generates a result response (besides the screenPoint coordinates) when it hits a graphic. But since only 4,000 of the 200,000 parcels are drawn as graphics, the hitTest only returns a result 2% of the time. How can I make this work?

Moreover, I'll also need to be able to generate a spatial query to an overlying floodplain layer to determine if a given parcel overlaps part of the floodplain, and which flood zone it's in. How can I do this on a map click if only 4,000 features return a result?

What I would like is for the map to be able to render only the features that are present in the view at any given time, like mode ON_DEMAND from the 3.x API, but this doesn't seem like it's built into the 4.x release yet. That way I could publish a 200,000 feature service and render the parcels when zoomed in without bogging everything down.

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Paige,


  You should just use the vector tile layer and add a click event listener to the view and do a QueryTask on the map service for the parcel layer and use the returned geometry to add a graphic to the map for the parcel highlight. The is actually what a popup assigned to a ArcGISDynamicMapServiceLayer in the 3.x  API does behind the scenes.

PaigeKercher
New Contributor

Thanks Robert, that's a good idea. I will try this! 

0 Kudos