ThinkGeo.com    |     Documentation    |     Premium Support

Trying to get a label to draw only on ZoomLevel20

Hello.


I am trying to use the following code to get the layer to draw a zoom level 17 but the label to draw only on zoom level 20:


                            Select Case layerToAdd.Name
                                Case "Parcels"
                                    With layerToAdd.ZoomLevelSet
                                        .ZoomLevel17.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(layerAreaFill)
                                        .ZoomLevel17.DefaultAreaStyle.OutlinePen.Color = layerOutlineColor
                                        .ZoomLevel17.DefaultAreaStyle.OutlinePen.Width = layerOutlineWidth
                                        .ZoomLevel17.DefaultLineStyle.InnerPen.Color = layerLineColor
                                        .ZoomLevel17.DefaultLineStyle.InnerPen.Width = layerLineWidth
                                        .ZoomLevel17.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
                                    End With

                                    AddHandler layerToAdd.DrawingFeatures, AddressOf parcelLayer_DrawingFeatures
                                    layerToAdd.ZoomLevelSet.ZoomLevel17.DefaultAreaStyle.RequiredColumnNames.Add("INTEREST")
                                    layerToAdd.ZoomLevelSet.ZoomLevel17.DefaultTextStyle = TextStyles.County2("MAP_PAR_ID")


The layer to add is an iteration of all my layers. all layers add correctly so if possible please assume that it does. The layer draws from level 17 - 20 which is the desired effect. The last line specifies that I was the label to draw from 17-20 also, which I don't but this code does make that happen as is intended by the syntax. If I change this to level 20 specifically, or any other layer than 17, my labels do not draw...


                            Select Case layerToAdd.Name
                                Case "Parcels"
                                    With layerToAdd.ZoomLevelSet
                                        .ZoomLevel17.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(layerAreaFill)
                                        .ZoomLevel17.DefaultAreaStyle.OutlinePen.Color = layerOutlineColor
                                        .ZoomLevel17.DefaultAreaStyle.OutlinePen.Width = layerOutlineWidth
                                        .ZoomLevel17.DefaultLineStyle.InnerPen.Color = layerLineColor
                                        .ZoomLevel17.DefaultLineStyle.InnerPen.Width = layerLineWidth
                                        .ZoomLevel17.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
                                    End With

                                    AddHandler layerToAdd.DrawingFeatures, AddressOf parcelLayer_DrawingFeatures
                                    layerToAdd.ZoomLevelSet.ZoomLevel17.DefaultAreaStyle.RequiredColumnNames.Add("INTEREST")
                                    layerToAdd.ZoomLevelSet.ZoomLevel20.DefaultTextStyle = TextStyles.County2("MAP_PAR_ID")


What is the easiest way to get around this?



Nelson, 


Create another Layer just for labeling and make it only available within ZoomLevel20. Please have a look at the sample websamples.thinkgeo.com/webeditionsamples/ Labeling->LabelNiceLookingRoads and you will see it’s very easy to implement it.
 
Also I saw for layer “Parcels”, you set DefaultAreaStyle and DefaultLineStyle. Just wonder why you set both of them as finally only one will take effect, depends on the “Parcels” is a line-based layer or area-based layer. I didn’t see the context and maybe it’s correct. Just a little strange.
 
Ben

I bet it does seem strange! For the demo site, I will have polygon layers and line type layers and so rather than write logic to distinguish the two and apply styles accordingly, I just set all the styles for each layer. This wouldn't be the case in a production environment but for the sake of getting a demo out quickly, this seemed to work. My only quiestion about this additional parcel label layer is there a way to make its visibility  depndant on another lay ers visibility? So for instance, I wouldn't show the labels layer without parcels being on to being with?



Nelson,  
  
 I see why you set both of the LineStyle and AreaStyle, it makes sense. 
  
 Just wonder why you want to make one layer’s visibility dependant on another. As the symbol layer is visible from ZoomLevel17 to ZoomLevel20 and the label layer is visible only within ZoomLevel20, no matter how you zoom in or out, if the symbol is not drawn, the label is definitely not visible.  
  
 If you want to have a button let’s say, ChangeParcelVisibility, you can set the visible property of both layers to true or false in the button.click event, it’s also convenient.  
  
 I don’t know if it answers your question about the visibility dependence. Please let me know for more queries.  
  
 Ben.