Jump to content
We've recently updated our Privacy Statement, available here. ×
  • How to zoom to a pre-defined map location in Spotfire® using IronPython Scripting


    Introduction

    This example shows how to zoom to a pre-defined map location in Spotfire using IronPython scripting.

    To do this we need to create a view and to do that we need each of the boundary points. This will later be used as a reference when we create the view itself. 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 first script below to get the coordinates we can later use to "zoom" to that location in the second script. See the attached dxp file for the full example.

    maplocationexample.thumb.png.71e9208543c392fc157feebd0cbd2d8f.png

    Code sample

    The first script stores the current map location in 4 document properties.

    # Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Application.Visuals.Maps import MapChart, GeographicExtent, InteractionMode, Projection
    
    mapChart = visual.As[MapChart]()
    mapChart.InteractionMode = InteractionMode.Panning
    mapChart.Projection = Projection.WebMercator
    Document.Properties["Map.West"] = mapChart.ViewExtent.West
    Document.Properties["Map.South"] = mapChart.ViewExtent.South
    Document.Properties["Map.East"] = mapChart.ViewExtent.East
    Document.Properties["Map.North"] = mapChart.ViewExtent.North
     

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

    # Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Application.Visuals.Maps import MapChart, GeographicExtent, InteractionMode, Projection
    
    mapChart = visual.As[MapChart]()
    mapChart.InteractionMode = InteractionMode.Panning
    mapChart.ViewExtent = GeographicExtent.Create(
    	Projection.WebMercator,
    	Document.Properties["Map.West"],
    	Document.Properties["Map.South"],
    	Document.Properties["Map.East"],
    	Document.Properties["Map.North"])
     

    References

    zoomtopredefinedmaplocationexample.dxp

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...