Skip to content

Commit

Permalink
Added split map
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Mar 26, 2020
1 parent 1c53b57 commit 9185673
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/notebooks/geemap_and_ipyleaflet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,12 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"import geemap\n",
"Map = geemap.Map()\n",
"Map.split_map(left_layer='HYBRID', right_layer='ESRI')\n",
"Map"
]
}
],
"metadata": {
Expand Down
24 changes: 24 additions & 0 deletions geemap/geemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def handle_draw(target, action, geo_json):
checkbox.layout.width='18ex'
chk_control = WidgetControl(widget=checkbox, position='topright')
self.add_control(chk_control)
self.inspector_control = chk_control

self.inspector_checked = checkbox.value

Expand Down Expand Up @@ -584,6 +585,29 @@ def add_layer_control(self):
addLayerControl = add_layer_control


def split_map(self, left_layer='HYBRID', right_layer='ESRI'):
"""Adds split map.
Args:
left_layer (str, optional): The layer tile layer. Defaults to 'HYBRID'.
right_layer (str, optional): The right tile layer. Defaults to 'ESRI'.
"""
try:
self.remove_control(self.layer_control)
self.remove_control(self.inspector_control)
if left_layer in ee_basemaps.keys():
left_layer = ee_basemaps[left_layer]

if right_layer in ee_basemaps.keys():
right_layer = ee_basemaps[right_layer]

control = ipyleaflet.SplitMapControl(left_layer=left_layer, right_layer=right_layer)
self.add_control(control)

except:
print('The provided layers are invalid!')


def ee_tile_layer(ee_object, vis_params={}, name='Layer untitled', shown=True, opacity=1.0):
"""Converts and Earth Engine layer to ipyleaflet TileLayer.
Expand Down

0 comments on commit 9185673

Please sign in to comment.