Skip to content

Instantly share code, notes, and snippets.

@giswqs
Created July 15, 2020 19:39
Show Gist options
  • Save giswqs/ee244b5341612b4bade0f68601db8cbb to your computer and use it in GitHub Desktop.
Save giswqs/ee244b5341612b4bade0f68601db8cbb to your computer and use it in GitHub Desktop.
map controls
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import geemap",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "Map = geemap.Map()\nMap",
"execution_count": 2,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "Map(center=[40, -100], controls=(WidgetControl(options=['position'], widget=HBox(children=(ToggleButton(value=…",
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "afd8117a83894ee384bc56d19131feea"
}
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "Map.controls",
"execution_count": 3,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 3,
"data": {
"text/plain": "(WidgetControl(options=['position'], widget=HBox(children=(ToggleButton(value=False, icon='globe', layout=Layout(width='36px'), tooltip='Search location/data'),))),\n SearchControl(marker=Marker(icon=AwesomeIcon(icon_color='darkgreen', marker_color='green', name='check'), location=[0.0, 0.0], options=['alt', 'draggable', 'keyboard', 'rise_offset', 'rise_on_hover', 'rotation_angle', 'rotation_origin', 'title', 'z_index_offset']), options=['animate_location', 'auto_collapse', 'auto_type', 'jsonp_param', 'position', 'property_loc', 'property_name', 'url', 'zoom'], property_loc=['lat', 'lon'], url='https://nominatim.openstreetmap.org/search?format=json&q={s}', zoom=5),\n ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoom_out_text', 'zoom_out_title']),\n LayersControl(options=['position'], position='topright'),\n ScaleControl(options=['imperial', 'max_width', 'metric', 'position', 'update_when_idle'], position='bottomleft'),\n FullScreenControl(options=['position']),\n MeasureControl(active_color='orange', options=['active_color', 'capture_z_index', 'completed_color', 'popup_options', 'position', 'primary_area_unit', 'primary_length_unit', 'secondary_area_unit', 'secondary_length_unit'], popup_options={'className': 'leaflet-measure-resultpopup', 'autoPanPadding': [10, 10]}, position='bottomleft', primary_length_unit='kilometers'),\n AttributionControl(options=['position', 'prefix'], position='bottomright'),\n DrawControl(circle={'shapeOptions': {'color': '#0000FF'}}, marker={'shapeOptions': {'color': '#0000FF'}}, options=['position'], polygon={'shapeOptions': {}}, polyline={'shapeOptions': {}}, rectangle={'shapeOptions': {'color': '#0000FF'}}),\n WidgetControl(options=['position'], position='topright', widget=VBox(children=(Checkbox(value=False, description='Inspector', indent=False, layout=Layout(height='18px', width='13ex')), Checkbox(value=False, description='Plotting', indent=False, layout=Layout(width='13ex'))))),\n WidgetControl(options=['position'], position='topright', widget=Output(layout=Layout(border='1px solid black'))),\n WidgetControl(options=['position'], position='topright', widget=VBox(children=(ToggleButton(value=False, icon='wrench', layout=Layout(width='37px'), tooltip='Toolbar'),))),\n WidgetControl(options=['position'], position='topright', widget=Output()))"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "print(len(Map.controls))",
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"text": "13\n",
"name": "stdout"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "Remove one specific control"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "index = 0 # up to len(Map.controls)\nselected_control = Map.controls[index]\nMap.remove_control(selected_control)",
"execution_count": 5,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "print(len(Map.controls))",
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"text": "12\n",
"name": "stdout"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "Clear all controls"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "Map.clear_controls()",
"execution_count": 7,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"varInspector": {
"window_display": false,
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"library": "var_list.py",
"delete_cmd_prefix": "del ",
"delete_cmd_postfix": "",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"library": "var_list.r",
"delete_cmd_prefix": "rm(",
"delete_cmd_postfix": ") ",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
]
},
"hide_input": false,
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": true,
"base_numbering": 1,
"title_cell": "Table of Contents",
"title_sidebar": "Table of Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
},
"language_info": {
"name": "python",
"version": "3.8.2",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "map controls",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment