Get attributes from polygon featureLayer with transparent fill using onClick event

583
2
Jump to solution
07-31-2012 09:48 AM
AnthonyThomas1
New Contributor
I've added a polygon featureLayer from a published map service (created from a .mxd) to my map.  In my .mxd, the polygon is symbolized with a solid outline and transparent (no color) fill.  Unlike other featureLayers (points and lines), the polygon layer does not return attributes or trigger an onClick event that would open an infoWindow when clicking inside the polygon.  I can trigger the onClick event when clicking on the polygon outline.  Is there a way to configure the symbology in my .mxd so that the onClick event can be fired when clicking inside the polygon?  Is this something i have to configure when adding the layer to my web map?

Thanks!
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Frequent Contributor
You can handle this client side by setting your polygon fill symbols to be completely transparent. Assuming you're using a simple renderer, the code is as simple as:
dojo.connect(featureLayer, "onLoad", function() {   featureLayer.renderer.symbol.setColor(new dojo.Color([0, 0, 0, 0]));   map.addLayer(featureLayer); });


If you're using a class breaks or unique value renderer, each symbol would need to be modified.

Here's a working example:  http://jsfiddle.net/PB4Yc/

If you comment out line 35 you end up with only click-able outlines, like you've described.

View solution in original post

0 Kudos
2 Replies
derekswingley1
Frequent Contributor
You can handle this client side by setting your polygon fill symbols to be completely transparent. Assuming you're using a simple renderer, the code is as simple as:
dojo.connect(featureLayer, "onLoad", function() {   featureLayer.renderer.symbol.setColor(new dojo.Color([0, 0, 0, 0]));   map.addLayer(featureLayer); });


If you're using a class breaks or unique value renderer, each symbol would need to be modified.

Here's a working example:  http://jsfiddle.net/PB4Yc/

If you comment out line 35 you end up with only click-able outlines, like you've described.
0 Kudos
AnthonyThomas1
New Contributor
Thanks Derek, this is what i was looking for!  Is this the only method, by design?  Is there no way to configure this from the .mxd side?  Also, do you have any guidance as to how to render this correctly in the legend?  I send layer info to the legend by connecting the onLayersAddResult method.  The symbol for the polygon layer is filled with black (not transparent).
0 Kudos