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.

Change GeoJSON style_callback post-instantiation?

See original GitHub issue

When I add a GeoJSON layer like this:

m = Map(center=[38.8976, -77.0365], zoom=11)
gj = GeoJSON(data=open("my.geojson").read())
m.add_layer(gj)

I can change its style attribute later and the browser will apply the change:

gj.style = {"color": "red"}  # changes color from default to red

It would be very useful if the same would happen when “changing” the style_callback parameter" dynamically at any time later (and not only when instantiating the object) like this (setting it to a constant value only for illustration):

gj.style_callback = lambda feature: {"color": "green"}

But this has no effect now. I see that style_callback is not listed in gj.keyswhich is likely one part of the reason… I’m trying to understand if this would be possible or not.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
sackhcommented, Oct 17, 2020

@martinRenou - I would like to work on this for JupyterCon sprint. Please assign this to me.

0reactions
deeplookcommented, Oct 17, 2020

load_data_style?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet Geojson Styling - GIS Stack Exchange
First try drawing the layer without specifying a style, does it draw with the default styling ? This will help determine if the...
Read more >
Callback on clicking a layer in Open Layer - Stack Overflow
I have an Open Map that I created, with a vector layer with several polygons. How can I detect a user click on...
Read more >
GeoJSONLayer | ArcGIS Maps SDK for JavaScript 4.25
The GeoJSONLayer class is used to create a layer based on GeoJSON. GeoJSON is a format for encoding a variety of geographic data...
Read more >
Documentation - a JavaScript library for interactive maps
Changes styles of GeoJSON vector layers with the given style function. ▷ Methods inherited from FeatureGroup ...
Read more >
Managing Asynchrony - Understanding Ember.js
getJSON('/posts/1', function(json) { // set all of the JSON properties on the model ... the computation in a callback when the underlying property...
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