Skip to content

Change GeoJSON style_callback post-instantiation? #675

Open
@deeplook

Description

@deeplook

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions