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

support for custom mapboxgl style #19

Closed
nlehuby opened this issue Nov 20, 2017 · 10 comments
Closed

support for custom mapboxgl style #19

nlehuby opened this issue Nov 20, 2017 · 10 comments
Milestone

Comments

@nlehuby
Copy link

nlehuby commented Nov 20, 2017

It would be nice to be able to load a custom json file with a malboxgl style in it, instead of using mapbox ones.

@ryanbaumann
Copy link
Contributor

ryanbaumann commented Nov 20, 2017

@nlehuby great call - right now we wrap the python variable passed to style_url as a string in each jinja template. We should enable an option to pass a python dictionary in JSON format and have the Jinja template format it as a JS object, not a string.

Proposal

Change the parameter name for viz class to style from style_url, and in the viz.py class, check if the style parameter is a url string or a Mapbox GL format JSON object.

Sample Python syntax for a mapboxgl.viz class:

# Stylesheet as Python dictionary in JSON format
mystyle = {my_mapbox_stylesheet}

#Load as a local stylesheet
viz3 = CircleViz(data, access_token=token, color_property='Avg Covered Charges',
                 style=mystyle,
                 color_stops=color_stops, center=[-95, 40], zoom=3)

#Load as a Mapbox Style
viz3 = CircleViz(data, access_token=token, color_property='Avg Covered Charges',
                 style="mapbox://ryanbaumann/styles/mystyle",
                 color_stops=color_stops, center=[-95, 40], zoom=3)

@nlehuby
Copy link
Author

nlehuby commented Nov 20, 2017

thanks for your reply !

Your proposal is very close to the javascript mapboxgl API, so it would very easy to use. I do approve 👍

@ryanbaumann
Copy link
Contributor

@nlehuby is this an issue you could submit a PR for?

@ryanbaumann
Copy link
Contributor

This shipped in #59 !

@ryanbaumann ryanbaumann added this to the 0.6.0 milestone Mar 25, 2018
@kevalshah90
Copy link

Stumbled upon this issue while looking for a fix for: https://stackoverflow.com/questions/62751062/mapbox-gl-in-jupyter-notebook-add-custom-marker/.

I'd like to use a custom marker for point coordinates, however, not seeing where do I make the fix.

@akacarlyann
Copy link
Collaborator

akacarlyann commented Jul 7, 2020

Hey there @kevalshah90 , I had started something along those lines with #149. Does something along those lines meet your need? Or are you looking for something that just substitutes a different shape in place of a circle marker? That's not (yet) supported, but definitely something we could look into! Feel free to open a new issue :) https://github.com/mapbox/mapboxgl-jupyter/issues/

@kevalshah90
Copy link

kevalshah90 commented Jul 7, 2020 via email

@akacarlyann
Copy link
Collaborator

@kevalshah90 ah yes, the maki icons was the direction we decided to go, instead of that old PR I linked. I haven't gotten around to it yet, but glad to hear there's another vote for that feature.

For changing the marker radius, if you are using the CircleViz type, (https://mapbox-mapboxgl-jupyter.readthedocs-hosted.com/en/latest/viz.html#class-circleviz) then you can set the radius as an argument. Here's an example:

viz = CircleViz(data,
                radius=5,
                access_token=token)
viz.show()

Hope that helps!

@kevalshah90
Copy link

kevalshah90 commented Jul 7, 2020 via email

@akacarlyann
Copy link
Collaborator

Glad to hear it! I think the answer to your question is yes. This repository just implements Python bindings to create visualizations embedded in a Jupyter notebook using Mapbox's JavaScript library. We are currently loading the Mapbox GL JS version 1.5.0 in our HTML template.

Thanks for reaching out! Hoping to revisit some more features on this project again soon :)

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

4 participants