Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am working on an integrated mapping project. I would like a button that toggles a layer. I could hold the layers status in a variable and then show/hide it as appropriate but this seems a little hacky.

Is there a way to find out whether a layer's "display" value is set to on or off?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

http://reference.mapinfo.com/software/mapbasic/english/11.0/MapBasicReference.pdf

Page 364.

LayerInfo( window_id, layer_number, 9 )

LAYER_INFO_DISPLAY (9) will return the following:

SmallInt indicating how and whether this layer is displayed; return value will be one of these values:

• LAYER_INFO_DISPLAY_OFF (0) the layer is not displayed

• LAYER_INFO_DISPLAY_GRAPHIC (1) objects in this layer appear in their “default” style—the style saved in the table

• LAYER_INFO_DISPLAY_GLOBAL (2) objects in this layer are displayed with a “style override” specified in Layer Control

• LAYER_INFO_DISPLAY_VALUE (3) objects in this layer appear as thematic shading

share|improve this answer
    
How do you go about finding the layer number from the layer name? –  Mr_Chimp Aug 22 '11 at 9:48
    
You would need to use MapperInfo to find out the number of layers in the map window, then do a for loop, testing the layer name against each of the layers in the Map Window. –  James S Aug 22 '11 at 10:07
    
@James +1 nice one –  kinkajou Aug 22 '11 at 10:08
1  
Please note that there is an issue with MapBasic regarding "turning on" the visibility of the layer. As you can see from James' description above, there is one value for OFF (_OFF), but two values for ON (_GRAPHIC and _GLOBAL). So in order to turn on the layer in the right way, you need to store the value for the layers visible setting (either GRAPHIC or GLOBAL) and then when you turn the visibility on again act depending on how it was when you turned it off. –  Peter Horsbøll Møller Aug 22 '11 at 10:59
    
Every day's an adventure with MapBasic! –  Mr_Chimp Aug 22 '11 at 11:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.