Jump to content
We've recently updated our Privacy Statement, available here. ×

Mapmarkersize script for multiple pages


Dagfinn Veiberg
Go to solution Solved by David Boot-Olazabal,

Recommended Posts

How can I make this script work for multiple pages?

The mapchart title and the layer titles are the same for all pages.

 

 

# Change the marker size in a Marker Layer on a Spotfire Map Chart

# import required classes
from Spotfire.Dxp.Application.Visuals.Maps import MapChart, MarkerLayerVisualization

# set visual
# could also do this by passing the parameter "visual" to the IronPython script

for p in Document.Pages:
    if p.Title == "Page":
        for v in p.Visuals:
            if v.Title == "Map":
                visual = v


map = visual.As[MapChart]()

# get the marker layer and set the marker size
for layer in map.Layers:
    if layer.Title == "Layer":
        markerLayer = layer.As[MarkerLayerVisualization]()
        markerLayer.MarkerSize = Slidervalue

Link to comment
Share on other sites

Hi Dagfinn,

Looking at the code, the part where you toggle through the pages looks good to me (see also here).

Not sure about the last part, when you define the map part. You can have a look at our iron python code snippet page, where we have a 10 examples of Map related iron python snippets: https://community.spotfire.com/articles/spotfire/ironpython-scripting-in-spotfire/.

How did you map your code to the different pages?
Looking at the code, it looks like you have mapped only one map chart. And you may need to define all maps on each page individually. As you use this line 'map = visual.As[MapChart]()' , I assume you have mapped that to one of the map charts. And that one probably changes upon executing your script. But it doesn't cover other map charts on the other pages.

You can try to define more map charts and refer to them and then see what happens when you execute the script. 

Kind regards,

David

Link to comment
Share on other sites

David,

 

Thanks a lot for you answer.

My dashboards contain numerous pages. All pages contain a mapchart with the same title and more or less the same layers. I would like the script "Changemapmarkersize" to work on all the pages without having to change the script for each page. How is that possible? Can you alter the script to do that?

See attached file.

Mapmarkersize.dxp

Link to comment
Share on other sites

Hi Dagfinn,

I couldn't find a script in your dxp, so I took the code from your initial post and added some blocks of code to cater for all the pages.

The script can be triggered via a button that I added in the text area on page1. The idea behind the script is, whenever you set the slider to a higher or lower value, the script synchronizes this over all the pages involved. You can make it even more dynamic, if you want to trigger it automatically upon changing the marker size, so that every changes is immediately reflected in all other maps:

image.thumb.png.53d461a742a1a53d8823352441a0f587.png

Kind regards,

David

Mapmarkersize.dxp

Link to comment
Share on other sites

David, thank you!

I think the "slidervalue" disappeared in your script and therefor it does not work.

The best functionality would be if one script could work for all pages and with individual size of the marker for each page, because there are normally large difference in the zoom factors for different pages. How is that done? Unfortunately I am not a programmer.

Link to comment
Share on other sites

My original script (see first post) is working for one page.

Your script does not work when I run it. It may be because the parameter "slidervalue" which specify the size of the marker is not defined in the script.

regards,

Dagfinn

Link to comment
Share on other sites

  • Solution

Hi Dagfinn,

I have downloaded your dxp once more, and this time I could see the script. I now see what you did (and what I missed in my script).

The solution I proposed in my earlier responses, can still be used in your script. Just copy the parts for each of the pages and point them to the name of the page. That synchronizes the slider value on all pages and zooms each map equally in or out.

I have attached the dxp with the changes in the script.

Kind regards,

David

Mapmarkersize v05042024.dxp

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...