Jump to content

It's possibile reset the navigation in a Map Chart with python


Luca de Falco 4

Recommended Posts

  • 1 year later...
  • 7 months later...

You can switch to autozoom with:

 

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

 

#map is a script parameter pointing to your map

m = map.As[MapChart]()

 

#Toogle Map AutoZoom

m.AutoZoom = not m.AutoZoomBut that is probably not what you want.

 

 

Instead, youcan use the ViewExtent property to explicitly set the zoom level.

 

https://docs.tibco.com/pub/sfire_dev/area/doc/api/TIB_sfire-analyst/html...

 

See "KB 42422 Zooming a map to a pre-defined location using scripts" which describes this process:

 

https://support.tibco.com/s/article/Tibco-KnowledgeArticle-Article-42422

 

Excerpt:

To create a view we need each of the boundary points. This will later be used as a reference when we create the view. Doing this manually is quite complicated since the final coordinates are calculated by Spotfire using the selected projection system. The easier way is to first zoom and pan the map to the location we want and then run the script below to get the coordinates we can later use to "zoom" to that location.

 

# Save the string to a property control instead if this is not done in the desktop client.

import clr

clr.AddReference('System.Windows.Forms')

from System.Windows.Forms import MessageBox

from Spotfire.Dxp.Application.Visuals import Maps

from Spotfire.Dxp.Application.Visuals.Maps import GeographicExtent, InteractionMode as im, Projection as pn

 

for vis in Document.ActivePageReference.Visuals:

if vis.Title == 'Map Chart':

map = vis.As[Maps.MapChart]()

 

map.InteractionMode = im.Panning

map.Projection = pn.WebMercator

MessageBox.Show('South: ' + str(map.ViewExtent.South) + ', East:' + str(map.ViewExtent.East) + ', North: ' + str(map.ViewExtent.North) + ', West: ' + str(map.ViewExtent.West))

Now we can use the coordinates from above to create a script that can show us the desired location on the map.

 

from Spotfire.Dxp.Application.Visuals.Maps import GeographicExtent, InteractionMode, Projection

for vis in Document.ActivePageReference.Visuals:

if vis.Title == 'Map Chart':

map = vis.As[Maps.MapChart]()

 

# Define how we should interact with the map

map.InteractionMode = InteractionMode.Panning

# Set the projection to None

map.Projection = Projection.None

# Set the ViewExtent, this is the coordinates that the defines the edges of the view (west, south, east, north)

map.ViewExtent = GeographicExtent.Create(Projection.None, 1, 1, 1, 1)

Link to comment
Share on other sites

  • 3 years later...

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