I have a map that has a neighborhoods layer. When I mouse-over, the neighborhood outline lights up and data is displayed in a side-window popup. I would like to add a census tracts layer to the map. Would it be possible to display the outlines of both layers simultaneously on mouse-over, and show data from the census layer in a second div in the side-window?
The top layer is going to be the only layer that will interact with mouse events so the easy answer is no. But you could do some Query to get the census layer attributes that intersect with the neighborhood polygon when the neighborhood polygon changes.
Hi Robert, I'm working with Randy on this project. We definitely don't want to intersect the data. We just want to show visually where they overlap, and display attributes from both layers. Would it be possible to merge them into a multi-part polygon and retain both boundaries?
This is definitely possible, though you may not be able to use layer events, I'm not sure.
The approach I would take is to make sure both of your layers have a fullExtent set on them. This property is part of the feature service. If this is set, you can set this up manually pretty easily, ie: on mouse move, check for intersection with neither, both, or one of the fullExtents on your data sets and then highlight them accordingly and fill in information in the side popup.
In terms of merging two extents, you can do this using the geometry engine union function in order to merge two polygons or two extents however you like (I would guess two extents should normally be merged into a polygon, unless one totally contains the other).
It should be pretty simple to extend this so it works on however many layers you need and it merges the extents of all layers being intersected using geometryEngine.union. In terms of how you handle the side popup, I don't really know what that would involve, whether there's a pre-existing tool you're using or if it's something you've built yourselves.
The mouse over event also gives you a map point object so you could query your census layer while inside the neighborhood mouse over event for the pertinent information and then add it to your side panel along with the neighborhood information.