Jump to content

Get the zoom level of a map through IronPython


B I

Recommended Posts

I want to find out how "zoomed in" I am on a map so that I can then set the zoom level of another map to the same level and the contents of the map can be compared on the same scale.

from Spotfire.Dxp.Application.Visuals import *from Spotfire.Dxp.Application.Visuals.Maps import * sourceMap = sourceMapChart.As[MapChart]() destinationMap = destinationMapChart.As[MapChart]() #Get zoom level of source map ##### #Set zoom level of destination map ####

Does anyone know if there is an API to get this value

Cheers,

BI

Link to comment
Share on other sites

Thanks for the feedback but that doesn't solve my issue unfortunately. That code allows me to zoom to preset view extents but I just want the map to zoom in/out on whatever area it is currently centred on. I need to get the "zoom-level" of one map in its current state and then apply that to the second map.
Link to comment
Share on other sites

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 1':

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

 

map.InteractionMode = im.Panning

map.Projection = pn.WebMercator

 

Document.Properties["South"] = str(map.ViewExtent.South)

Document.Properties["East"] = str(map.ViewExtent.East)

Document.Properties["North"] = str(map.ViewExtent.North)

Document.Properties["West"] = str(map.ViewExtent.West)

Link to comment
Share on other sites

Thank you for the suggestion but, again, I don't want the second map to be focused on the same area of the map as the first map. I just want the second map to be zoomed in or out of whatever area it is currently focused on so that the scale of its content matches that of the first map.

 

For example, the first map might be zoomed on Europe at a scale of 1:10,000 and I want the second map to be zoomed in/out to a scale of 1:10,000 on whatever part of the map it is currently set over (e.g. Arabia)

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