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 marker styling #83

Open
rsignell-usgs opened this issue Nov 14, 2017 · 11 comments
Open

Support marker styling #83

rsignell-usgs opened this issue Nov 14, 2017 · 11 comments

Comments

@rsignell-usgs
Copy link

rsignell-usgs commented Nov 14, 2017

It would be great if ipyleaflet supported marker styling.

Perhaps the same GeoJSON conventions as GitHub: https://help.github.com/articles/mapping-geojson-files-on-github/ ?

This would allow Ipyleaflet users to easily change marker colors and styles, fixing problems like reproducible-notebooks/ERDDAP_timeseries_explorer#3.

Simple example:
https://github.com/rsignell-usgs/dc-wifi-social/blob/master/bars.geojson

On GitHUB this GeoJSON produces a map that looks like this:
2017-11-14_8-45-05

While the same GeoJSON in Ipyleaflet:

import urllib.request
import json
url = 'https://raw.githubusercontent.com/rsignell-usgs/dc-wifi-social/master/bars.geojson'
req = urllib.request.Request(url)
r = urllib.request.urlopen(req).read()
data = json.loads(r.decode('utf-8'))
center = [38.9, -77.05]
zoom = 12
map = ipyl.Map(center=center, zoom=zoom, layout=ipyl.Layout(width='650px', height='350px'))
feature_layer = ipyl.GeoJSON(data=data)
map.layers = [map.layers[0], feature_layer]
map

produces a map that looks like this:
2017-11-14_8-45-40

@ocefpaf
Copy link
Contributor

ocefpaf commented Nov 17, 2017

I believe that that is specific to mapbox, not sure if it is possible to do it with leaflet.

One way to do it with leaflet is with https://github.com/albburtsev/Leaflet.geojsonCSS

@jasongrout
Copy link
Member

You can create custom marker icons in leaflet: http://leafletjs.com/examples/custom-icons/

That's not hooked directly up to the geojson data, but there may be something possible there.

@ocefpaf
Copy link
Contributor

ocefpaf commented Nov 17, 2017

That's not hooked directly up to the geojson data, but there may be something possible there.

Leaflet.geojsonCSS is a plugin to read the custom-icons info from the GeoJson data, but one would need to convert from the mapbox style to leaflet's style.

@jasongrout
Copy link
Member

For completeness, I think here are the docs about those icons in mapbox: https://www.mapbox.com/help/markers-js/#style-markers-with-simplestyle

@rsignell-usgs rsignell-usgs changed the title Support same GeoJSON conventions as GitHub Support custom icons Nov 21, 2017
@rsignell-usgs rsignell-usgs changed the title Support custom icons Support marker styling Nov 22, 2017
@tanay27
Copy link

tanay27 commented Jan 31, 2018

How do I implement marker styling in jupyter notebook

@Oao2021
Copy link

Oao2021 commented Sep 3, 2021

How to change markers from the default ipyleaflet markers. Say we want to use a custom marker. Is this possible?

@giswqs
Copy link
Contributor

giswqs commented Sep 3, 2021

How to change markers from the default ipyleaflet markers. Say we want to use a custom marker. Is this possible?

Yes, you can use AwesomeIcon. See https://ipyleaflet.readthedocs.io/en/latest/api_reference/awesome_icon.html

@Oao2021
Copy link

Oao2021 commented Sep 3, 2021

@giswqs thanks for the quick response. I am referring to the markers themselves, to have a different shape for example a bus.

@martinRenou
Copy link
Member

This is also supported and documented https://ipyleaflet.readthedocs.io/en/latest/api_reference/icon.html. You can provide your own icon.

@Oao2021
Copy link

Oao2021 commented Sep 3, 2021

@martinRenou thanks so much. Done. Problem solved.

@astrojuanlu
Copy link
Contributor

Using your own icons for individual markers is indeed explained in the docs https://ipyleaflet.readthedocs.io/en/latest/layers/awesome_icon.html but how about providing custom markers for GeoJSON layers?

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

9 participants