Skip to content

CityOfBoston/vanishing-glass

Repository files navigation

The GIS / Mapping world is divided into desktop mappers (using Python) and web mappers (using JavaScript and other technologies, but mostly JavaScript).

Vanishing-Glass is an experiment to bridge the gap, and make interactive mapping and custom data maps accessible in 100% Python. The code is all client-side, so projects can be hosted via GitHub Pages.

Examples

An example map which adds a marker to a map. Python source

A more complex example, loading JSON from ArcGIS Server API.

Components

Brython is an open source (New BSD License) framework to write web apps and client-side code in Python.

ArcGIS.com is a web-mapping platform with JavaScript APIs and thousands of datasets.

Current Status

  • Simple commands work

    // JS: map.centerAndZoom( [ -70, 40 ], 11 );

    Python: map.centerAndZoom( [ -70, 40 ], 11 )

  • More complex commands where JavaScript uses the 'new' keyword or anonymous functions are proving difficult:

    // JS: new esri.geometry.Point( [-70, 40], { "wkid": 4326 } );

    Python: esri.geometry.Point( [-70, 40], { "wkid": 4326 } )

  • The workaround for using the 'new' keyword is currently using a JavaScript function to return an initialized object to the Brython script

    // Old JS: new esri.geometry.Point( [-70, 40], { "wkid": 4326 } );

    becomes

    // New JS: ptmaker = function(lnglat, sr){ return new esri.geometry.Point( lnglat, sr ); };

    Python: ptmaker( [ -70, -40 ], { "wkid": 4326 } )