Jump to content

Using a Python script, how do you change Marker Layers on a Map Chart


Teresa Kleb 2

Recommended Posts

I have two marker layers on a map. One to select by counties and then it returns On-Demand data back to the map. I want to build a Python script that will select the next Marker Layer without people having to know how to use the Layers Control to switch the layers. I just want them to click a button and then be able to select from the On-Demand data. I have been unsuccessful in finding any helpful examples on this site and on the Internet in general. Any Python examples will be greatly appreciated. Thank you.
Link to comment
Share on other sites

Here is an example that changes the shape and the size. Refer to the API doc (https://docs.tibco.com/pub/doc_remote/spotfire/7.6.0/doc/api/html/T_Spotfire_Dxp_Application_Visuals_MarkerType.htmto see all shape options.

 

 

 

# import required classes

from Spotfire.Dxp.Application.Visuals.Maps import MapChart, MarkerLayerVisualization

from Spotfire.Dxp.Application.Visuals import MarkerType, MarkerShape

 

# set visual

visual = myVisual #Script Parameter

 

map = visual.As[MapChart]()

 

# get the marker layer and set the marker size

for layer in map.Layers:

if layer.Title == "SalesAndMarketing": #My Layer Name

markerLayer = layer.As[MarkerLayerVisualization]()

markerLayer.ShapeAxis.DefaultShape = MarkerShape(MarkerType.Square)

#print dir(markerLayer.Visual)

markerLayer.MarkerSize = 5.0

Link to comment
Share on other sites

  • 2 months later...

In Spotfire 7.7 it is now possible to set a layer as interactive based on the zoom visibility setting. Assuming marker layer 1 (county) is displayed at higher level than marker layer 2 then when Map chart switch from layer 1 to layer 2 and layer 2 will be automatically set as interactive layer when displayed.

 

To do this you should just set marker layer 1 to be visible at higher level than marker layer 2 from the Zoom Visibility property panel on your Map chart properties.

Link to comment
Share on other sites

  • 1 year later...

from Spotfire.Dxp.Application.Visuals.Maps import MapChart, MarkerLayerVisualization

from Spotfire.Dxp.Application.Visuals import MarkerType, MarkerShape,CategoryKey

from System.Collections.Generic import List

m = MapChart1.As[MapChart]()

#Layers is called by integer and it probably isn't the way you see them in the interface so you'll have to play around to find the right one

MyLayers= m.Layers[2]

MyLayer = MyLayers.As[MarkerLayerVisualization]()

MyTypeCY =MarkerType.StarFive

MyTypeLY =MarkerType.Diamond

MyShapeCY =MarkerShape(MyTypeCY)

MyShapeLY=MarkerShape(MyTypeLY)

# you can also use something like KeyLY=CategoryKey('2017')

# MyLayer.ShapeAxis.ShapeMap[KeyLY]=MyShapeCY

for Cat in MyLayer.ShapeAxis.ShapeMap.GetCategories():

if Cat.ToString()==CYText:

MyLayer.ShapeAxis.ShapeMap[Cat]=MyShapeCY

elif Cat.ToString()==LYText:

MyLayer.ShapeAxis.ShapeMap[Cat]=MyShapeLY

Link to comment
Share on other sites

  • 1 year later...
Hi Luvigz,IS there a way to change the Visibility of Marker Layer Only, if i preset the Properties of the Layers. I have 4 different Datatables(A,B,C,D) in my dxp, i added these 4 data tables as my marker layers and i would like to load the pointers of them on the Map based on my Data tables Selection through Button. For Example, i select Button 1, then only MArker Layer A Visibility should be enabled and rest 3 should be disabled. Any Help is much appreciated. thanks.
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...