Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save Map to HTML #28

Closed
sherl0cks opened this issue Jan 1, 2018 · 8 comments
Closed

Save Map to HTML #28

sherl0cks opened this issue Jan 1, 2018 · 8 comments

Comments

@sherl0cks
Copy link

This is a feature request to save the map to file such that it could be subsequently served to a web browser, a la folium's save (see cell 3 in this example)

@sherl0cks
Copy link
Author

sherl0cks commented Jan 1, 2018

appears that you can do something along these lines and works well enough. let me know if there is a more interesting solution. else, we can close this.

viz = GraduatedCircleViz(...)

html = open("100000_markers.html", "w")
html.write( viz.create_html() )
html.close()

@ryanbaumann
Copy link
Contributor

ryanbaumann commented Jan 1, 2018

@sherl0cks this is a very common need - I vote we add an export function for each viz object. Html file would be one option, image another option, PDF a 3rd option, possibly other options to come.

@sherl0cks
Copy link
Author

that works for me. we need to make sure the feature it is added to an example when it is built.

@ryanbaumann
Copy link
Contributor

@sherl0cks great, added an initial example using your code - see it in this repo at /examples or at www.mapbox.com/labs/jupyter

Let's leave this ticket open as a placeholder for a broader export viz functionality.

@sherl0cks
Copy link
Author

@ryanbaumann nice. thanks for quick turn around

@ryanbaumann
Copy link
Contributor

Here is the export to HTML approach captured in the example notebook:

with open('viz.html', 'w') as f:
    f.write(viz.create_html())
# Python2
python -m SimpleHTTPServer 8080   
# Python 3
python3 -m http.server 8080   

@anderl80
Copy link

anderl80 commented Jul 4, 2018

Can I share a map with clusters to someone else without starting a web server?

@ryanbaumann
Copy link
Contributor

@anderl80 yes, if you include your map data parameter as a geojson-format python dictionary, then the data for your map will be packaged up inside your exported map HTML file and can be opened just by opening the HTML file in a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants