Jump to content
  • IronPython script to Toggle Map Layer Visibility


    Use this script to create a shortcut allowing you to easily turn on/off map layers with a single click

    Introduction

    Use this script to create a shortcut allowing you to easily turn on/off map layers with a single click. Very useful when you have multiple map layers that need to be configured on/off at once, or to control multiple map charts at once.

    Code Snippet

    # Copyright © 2019. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    # Author - Neil Kanungo, TIBCO Software, June 2019
    
    from Spotfire.Dxp.Application.Visuals import * 
    from Spotfire.Dxp.Application.Visuals.Maps import * 
    
    myMap = myMap.As[VisualContent]() #myMap is a script parameter you must assign to your map visualization
    
    for lyr in myMap.Layers: 
     if (lyr.Title == "YOUR LAYER 1") or (lyr.Title == "YOUR LAYER 2"): #Enter each layer to remain VISIBLE here, separated by "or" statement. Alternatively, use only one layer and remove "or" statement
    	lyr.Enabled = True
     else:
    	lyr.Enabled = False
    
    #to do multiple maps at once, copy/paste code starting at line 8 but use with a different script parameter (e.g. "myMap2")
     

    Example

    maplayersip.thumb.gif.fc6345654673cdd5418b51fc63dc720a.gif

    License: TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...