Is there a NULL symbol for feature layers?

869
5
08-30-2012 05:50 AM
RexBradford
New Contributor II
I am developing an app which displays shaded country boundaries for selected countries.  Most of the time, all of the country boundaries are turned off.  I am using a UniqueValueRenderer to then "turn on" one or a few selected countries and display them shaded with an outline.

My default "empty" symbol is currently:

var outlineNull = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_NULL, '#000000', 0);
mapLayerCountries.defSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL, outlineNull, '#000000');



This works, but is currently non-optimal.  Looking at the svg in Firebug, I see that each invisible country still has its huge outline, in svg code that looks like this:

<path fill="none" fill-opacity="0" stroke="none" stroke-opacity="0" stroke-width="1" 
stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" 
path="M 195,333 195,333 195,333 195,333 195,333 195,334 195,333 195,333 195,334 196,334 196,333 
196,333 196,333 196,333 197,333 197,333 197,333 197,333 197,334 195,334 195,334 195,334 195,334 
194,334 192,334 192,334 192,334 192,334 191,335 191,335 190,335 190,335 190,335 190,335 189,335 
188,336 188,336 188,336 188,336 187,336 .......


How do I make a truly NULL default symbol which results in no svg being generated for the countries which are not selected?  I have tried using undefined for the symbol but the toolkit complains "sym is undefined".

Thank you,

Rex Bradford
Direct Relief International
0 Kudos
5 Replies
JohnGravois
Frequent Contributor
have you considered creating a separate GraphicsLayer for your selected features instead of attempting to maintain invisible symbology?
0 Kudos
RexBradford
New Contributor II
have you considered creating a separate GraphicsLayer for your selected features instead of attempting to maintain invisible symbology?


No.  Are you suggesting that I keep my country outline data layer invisible, or even just get the data and not make a layer at all, and then copy features to a separate GraphicsLayer when needed (and delete them when not needed)?

And does your answer imply that indeed there isn't a straightforward way to "turn off" individual elements in my current feature layer?  What about hiding all of the graphic items in my feature layer and then showing those which I want to be visible?  I didn't try that, would that solve the svg performance issue?

Thanks,

Rex Bradford
Direct Relief International
0 Kudos
JohnGravois
Frequent Contributor
when working with featurelayers using a definition expression gives you the ability to separate features based on SQL expressions and working in selection mode allows you to query for individual features spatially and only draw specific items.

i still don't know if i understand exactly what your workflow is, but i think either one or the other of these techniques would be the most straightforward way to go.
0 Kudos
RexBradford
New Contributor II
when working with featurelayers using a definition expression gives you the ability to separate features based on SQL expressions and working in selection mode allows you to query for individual features spatially and only draw specific items.

i still don't know if i understand exactly what your workflow is, but i think either one or the other of these techniques would be the most straightforward way to go.


I see, thanks, that seems reasonable.

Although the reason I am using a Feature Layer with UniqueValueRenderer in mode esri.layers.FeatureLayer.MODE_SNAPSHOT, is that then the 360K worth of outline data (for this dataset) only gets downloaded once in the browser at map startup.  I presume that if I do what you're suggesting, I will get new web traffic each time.  Admittedly it would presumably only download the needed outlines, but still the network traffic is another factor here that I am balancing.  The same map may have other modes where I want to turn on all countries and color-code them, and if so the single-startup-download is desirable.

Rex Bradford
Direct Relief International
0 Kudos
StephenLead
Regular Contributor III
the 360K worth of outline data (for this dataset) only gets downloaded once in the browser at map startup


An alternative approach could be to generate JSON from the layer, and create your feature layer from the collection of features.

Potentially, this could allow you to download the features once only, and store them in memory. You could then slice+dice the features as necessary.

Note that I haven't tested this, so it's just a wild suggestion. You'd have to weigh up whether it's worth the complexity.

Cheers,
Steve
0 Kudos