From c0aaf66329e0364dee0528e3b0e48b2889ed8758 Mon Sep 17 00:00:00 2001 From: Jason T Brown Date: Tue, 16 Jun 2020 02:52:30 -0400 Subject: [PATCH] Implement __geo_interface__ for relevant GeoJSON and GeoData classes (#621) --- ipyleaflet/leaflet.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 5e357e6db..ac8674252 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -545,6 +545,16 @@ def _get_data(self): return self.data + @property + def __geo_interface__(self): + """ + Return a dict whose structure aligns to the GeoJSON format + For more information about the ``__geo_interface__``, see + https://gist.github.com/sgillies/2217756 + """ + + return self.data + def _apply_style(self, feature, style_callback): if 'properties' not in feature: feature['properties'] = {} @@ -595,6 +605,16 @@ def _update_data(self, change): def _get_data(self): return json.loads(self.geo_dataframe.to_json()) + @property + def __geo_interface__(self): + """ + Return a dict whose structure aligns to the GeoJSON format + For more information about the ``__geo_interface__``, see + https://gist.github.com/sgillies/2217756 + """ + + return self.geo_dataframe.__geo_interface__ + class Choropleth(GeoJSON): geo_data = Dict()