Select to view content in your preferred language

Labelling / Graphic Layer's visibility

708
4
04-22-2010 10:21 AM
SannaPaavilainen
Emerging Contributor
Hi,

We playing with ArcGIS and FlexBuilder for the first time. We are trying to build up a simple map application for searching real estates based on their location and type.

Now we have problems with labelling the points. In our service we have two graphics layers and the graphics for these layers come from a query, so in both graphic layers the data is always the same. The first graphics layer is visible all the time and it shows only the points based on the query. The other layer shows the points with labels and this layer should become visible when certain limiting value in map scale is reached.

Our problem is that we can't get that other layer with labels visible. We have an event listener which is checking the map scale all the time. Then we have a boolean fuction (called labelling) which returns true when the map scale is below the limiting scale value. When map scale is bigger than the limiting value, the fuction returns false. Then we are trying use that boolean fuction in our graphics layer's (with labels) visibility condition. Like this: visible = "{labelling()}" . When we are running our application, we don't get any error messages but when we execute a query, only the points are shown on a map and nothing more.   

So we are wondering what we are doing wrong? What kind of things can be put to the graphics layer's visibility condition?

We appreciate all kind tips and are very thankful if anyone can give us some tips or hints.

- Sanna, Sonja, Laura and Krista
Tags (2)
0 Kudos
4 Replies
DasaPaddock
Esri Regular Contributor
If you leave visible set to true, do you see it how you want?

If yes, instead of trying to set the visible property yourself, you can use the Layer's maxScale/minScale properties.

Reference:
http://resources.esri.com/help/9.3/arcgisserver/apis/flex/apiref/com/esri/ags/layers/Layer.html#maxS...

maxScale/minScale Sample (This is using 2.0, but can be done in 1.3 also):
http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=AddLODS

1.3 Sample that sets the visible property:
http://resources.esri.com/help/9.3/arcgisserver/apis/flex/samples/index.html?sample=AddLODS
0 Kudos
SannaPaavilainen
Emerging Contributor
Thank you for your help!

We tried to use those maxScale and minScale properties and those worked with the first graphic layer. Now we have problems with the thing that we should present the same data from a query in two different graphic layers. It just seems to be impossible.. Here's the code:

<--! THE FIRST LAYER -->
<esri:GraphicsLayer id="myGraphicsLayer"  graphicProvider="{queryTask.executeLastResult.features}" maxScale="80000" >  
<esri:symbol>               
      <esri:CompositeSymbol>                   
        <esri:SimpleMarkerSymbol id="defaultSymbol" color="0x0000FF" style="circle" size="10" alpha="0.5"/>                    
      </esri:CompositeSymbol>           
</esri:symbol>
</esri:GraphicsLayer>


<--! THE SECOND LAYER -->
<esri:GraphicsLayer id="labellingGraphics" graphicProvider="{queryTask.executeLastResult.features}" minScale="80000" >  
<esri:symbol>               
      <esri:CompositeSymbol>
      <esri:SimpleMarkerSymbol id="defaultSymbol2" color="0x0000FF" style="circle" size="10" alpha="0.5"/>                  
        <esri:TextSymbol textAttribute="Katusoite" placement="start" yoffset="10" color="0x660099" backgroundColor="0x0000FF">                           
        <flash:TextFormat bold="true" size="10" font="Verdana"/>                      
        </esri:TextSymbol>               
      </esri:CompositeSymbol>           
</esri:symbol>
</esri:GraphicsLayer>

So our question is: is it possible to present exactly the same data in two separate graphic layers? The first layer works properly but the second one never comes visible.

Thank you!
0 Kudos
DasaPaddock
Esri Regular Contributor
A Graphic can not be in more than one GraphicsLayer at a time. You'll need to have two Graphic instances for each feature. A quick way to do this would be to use two QueryTasks, or you could loop through the results and create a new duplicate Graphic for each result.
0 Kudos
SannaPaavilainen
Emerging Contributor
Thank you Dasa. We did two query tasks and now our application works like we wanted.
0 Kudos