question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate entire Mapbox Style sheet in Python thread

See original GitHub issue

Background

Currently, there is business logic occurring in both the Python mapboxgl library and the javascript templates. Since this is a Python library, we should isolate all business logic to Python, and make the Javascript/HTML components true templates only. This should greatly increase supportability of the mapboxgl library as it grows by isolating bugs to Mapbox GL Style Spec changes, which are much rarer than changes to the Mapbox GL JS Javascript library.

Approach

  1. Generate a complete Mapbox GL Style Sheet in a Python dictionary in the viz.py
  2. Serve the JSON-format style sheet to the HTML template via a the Jupyter Notebook local web server.
  3. Each time the analysis updates, the templates do not need to be destroyed & recreated. The map style simply updates with map.setStyle(newStyleURL)

cc @perrygeo

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
akacarlyanncommented, Apr 19, 2018

This is going to help so much with multi-layer maps if we can include the layer definitions!! Been playing around with serializing the property expressions on the Python side to get styled heatmaps layered under a point and linestring viz. Fun stuff : )

screen shot 2018-04-18 at 10 53 54 pm
1reaction
murphy214commented, Dec 5, 2017

This could be done with a websocket as well! As for the parsing and jinja issue, have you ever considered using something with a little more structure like a protocol buffer thats serialized as json if you knew what your were doing you could probably scrape the page with the style sheet spec on it to generate the protocol buffer structures based on the required fields etc. I’m not saying it’d be easy, in fact it’d probably be a pain but once you did once you could probably do it as things are updated (assuming that style-spec page stays up to date.) lol I may have to try this now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blank or missing map tiles | Help - Mapbox docs
This guide explains how to troubleshoot some common reasons maps fail to load. Your style ID is invalid. If you are using a...
Read more >
Self-hosting Mapbox vector tiles - GIS Stack Exchange
One step of the new vector tile process is to curate the vector data by adjusting what you want in the data. The...
Read more >
Mapbox map layers in Python - Plotly
Detailed examples of Mapbox Map Layers including changing color, size, log axes, and more in Python.
Read more >
Micromobility: Threading Traffic on 2 Wheels - Winter 2022
Micromobility: Threading Traffic on 2 Wheels | BUILD with Mapbox - Winter 2022. 11 views · 8 days ago ...more ...
Read more >
MapLibre – Mapbox GL Native Open Source Fork - YouTube
Want to learn how to build applications with vector maps for iOS or Android? Looking for more information about #MapLibre?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found