Jump to content

(Spotfire) Image Layer change in map chart


Jungwoo Kim

Recommended Posts

Hi, I'm using Spotfire 10.10.6.58 Version and I wanna know some possibility of customizing function in Spotfire.

Here's the thing.

1. Make Button using Text area or Tree Map

2. When I click that buttons, Image Layer in Map Chart changes

(Example. If I click the "Factory 1" Button, "Factory 1" Image Layer appears in Map Chart.

If I click the "Factory 2" Button, "Factory 2" Image Layer appears in Map Chart.)

Link to comment
Share on other sites

Hello Jungwoo!

There is already an example for how to do that in the IronPython script examples page in the community (https://community.spotfire.com/s/article/IronPython-Scripting-in-TIBCO-Spotfire)

"IronPython script to Toggle Map Layer Visibility"

https://community.spotfire.com/s/article/ironpython-script-toggle-map-layer-visibility

I tested it and confirmed that it works fine in Spotfire 10.10.

Note: I also recommend upgrading to a more recent version of Spotfire. Not only are you missing out on a very great amount of new features in the more recent releases, but also important updates affecting security and stability.

Link to comment
Share on other sites

Hello Fredrik!

Thank you your assistance. I perfectly understand it and it works smoothly.

Sorry but, then, I have another question related previous thing and wanna know sample code.

Here's the thing.

1. Make Button using Text area or Tree Map

2. When I click that buttons, Image Layer and Marker Layer in Map Chart changes simuteneously.

(Example. If I click the "Factory 1" Button, "Factory 1" Image Layer and "Factory 1" Marker Layer apperas in Map Chart.

If I click the "Factory 2" Button, "Factory 2" Image Layer and "Factory 2" Marker Layer apperas in Map Chart.)

Link to comment
Share on other sites

Hi Jungwoo,

The example script is already prepared for that (toggling multiple layers at once) so you just need to enter the correct layer names in script row 11:.

# 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 == "IL_Factory1") or (lyr.Title == "ML_Factory1"): #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:

Let's say we have

Factory1:

Image Layer: IL_Factory1

Marker Layer: ML_Factory1

Factory2:

Image Layer: IL_Factory2

Marker Layer: ML_Factory2

In your Factory1 script, you would then use

if (lyr.Title == "IL_Factory1") or (lyr.Title == "ML_Factory1") (in row 11 in the script above)

In your Factory2 script, you would then use

if (lyr.Title == "IL_Factory2") or (lyr.Title == "ML_Factory2")

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...