Skip to content

Commit

Permalink
Add ElevationPath control.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaudinFlorence committed Sep 8, 2022
1 parent 6993f0d commit f77f1fe
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 60 deletions.
88 changes: 28 additions & 60 deletions examples/GeoportalControls.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,21 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"id": "6bb0dd68-f96d-45c5-b3de-48c2092f2690",
"metadata": {},
"outputs": [],
"source": [
"from ipyleaflet import *\n",
"from ipyleaflet.geoportal import GeoportalWMTS, GeoportalLayerSwitcher, GeoportalSearchEngine, GeoportalRoute, GeoportalMousePosition"
"from ipyleaflet.geoportal import GeoportalWMTS, GeoportalLayerSwitcher, GeoportalSearchEngine, GeoportalRoute, GeoportalMousePosition, GeoportalElevationPath"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "fdeacb8e-3113-453d-ab63-a5ab639bf0c8",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6a239c9944c143c8ad49af3d1d5417c2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[44.799999, 2.26667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"#Route control for itinerary calculation\n",
"layer = GeoportalWMTS(layer = 'GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2', api_key = 'cartes', format = 'image/png')\n",
Expand All @@ -43,25 +28,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "3a686d99-c3ca-4596-81aa-24442564bea2",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c8dacf4132a44828a29e0d238dcdc266",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[44.799999, 2.26667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"#LayerSwitcher control\n",
"m1 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
Expand All @@ -79,25 +49,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "57062455-fe86-4e3b-8eaf-94e996b44830",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ca2a469baad0480780ead5013c4d7395",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[44.799999, 2.26667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"#SearchEngine control\n",
"m2 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
Expand All @@ -108,14 +63,27 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "0a7ca855-c96d-4864-9b9c-1873712033bb",
"metadata": {},
"outputs": [],
"source": [
"#MousePosition control\n",
"m3 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
"mouse_position_control = GeoportalMousePosition()\n",
"m3.add(mouse_position_control)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "17a9e9bb-f3a5-40e5-90ea-8d57049cda5f",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fa99ee68017947eba8768c90410b9e03",
"model_id": "de83e395ef634b6da1c061289ceac763",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -128,16 +96,16 @@
}
],
"source": [
"#MousePosition control\n",
"m3 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
"mouse_position_control = GeoportalMousePosition()\n",
"m3.add(mouse_position_control)"
"#ElevationPath control\n",
"m4 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
"elevation_path_control = GeoportalElevationPath()\n",
"m4.add(elevation_path_control)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17a9e9bb-f3a5-40e5-90ea-8d57049cda5f",
"id": "88acf040-74f1-419d-a3b8-766b9a538d43",
"metadata": {},
"outputs": [],
"source": []
Expand Down
11 changes: 11 additions & 0 deletions ipyleaflet/geoportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ class GeoportalMousePosition(Control):

_view_name = Unicode('LeafletGeoportalMousePositionView').tag(sync=True)
_model_name = Unicode('LeafletGeoportalMousePositionModel').tag(sync=True)


class GeoportalElevationPath(Control):
"""GeoportalMousePosition class, with Control as parent class
Attributes
----------
"""

_view_name = Unicode('LeafletGeoportalElevationPathView').tag(sync=True)
_model_name = Unicode('LeafletGeoportalElevationPathModel').tag(sync=True)
21 changes: 21 additions & 0 deletions js/src/layers/Geoportal.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,25 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
}
}

export class LeafletGeoportalElevationPathModel extends control.LeafletControlModel {
defaults() {
return {
...super.defaults(),
_view_name: 'LeafletGeoportalElevationPathView',
_model_name: 'LeafletGeoportalElevationPathModel'
};
}
}

export class LeafletGeoportalElevationPathView extends control.LeafletControlView {
initialize(parameters) {
super.initialize(parameters);
this.map_view = this.options.map_view;
}
create_obj() {
this.obj = L.geoportalControl.ElevationPath({})
}
}



0 comments on commit f77f1fe

Please sign in to comment.