Skip to content

Commit 6395e6f

Browse files
Add SearchEngine control.
1 parent 1ef06d9 commit 6395e6f

File tree

5 files changed

+103
-30
lines changed

5 files changed

+103
-30
lines changed

examples/GeoportalControls.ipynb

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,22 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 4,
5+
"execution_count": null,
66
"id": "6bb0dd68-f96d-45c5-b3de-48c2092f2690",
77
"metadata": {},
8-
"outputs": [
9-
{
10-
"data": {
11-
"application/vnd.jupyter.widget-view+json": {
12-
"model_id": "72c6852ad1be48459976e5b4c009a77a",
13-
"version_major": 2,
14-
"version_minor": 0
15-
},
16-
"text/plain": [
17-
"Map(center=[44.799999, 2.26667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
18-
]
19-
},
20-
"metadata": {},
21-
"output_type": "display_data"
22-
}
23-
],
8+
"outputs": [],
249
"source": [
2510
"from ipyleaflet import *\n",
26-
"from ipyleaflet.geoportal import GeoportalWMTS, GeoportalLayerSwitcher\n",
11+
"from ipyleaflet.geoportal import GeoportalWMTS, GeoportalLayerSwitcher, GeoportalSearchEngine\n",
2712
"m = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
2813
"layer1 = GeoportalWMTS() #default\n",
29-
"layer2 = GeoportalWMTS(layer = 'ELEVATION.SLOPES', api_key = 'altimetrie')\n",
14+
"layer2 = GeoportalWMTS(layer = 'ELEVATION.SLOPE')\n",
3015
"m.add(layer1)\n",
3116
"m.add(layer2)\n",
3217
"layer_control = GeoportalLayerSwitcher()\n",
33-
"m.add(layer_control)"
18+
"search_control = GeoportalSearchEngine()\n",
19+
"m.add(layer_control)\n",
20+
"m.add(search_control)"
3421
]
3522
},
3623
{

examples/GeoportalLayers.ipynb

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
},
1818
{
1919
"cell_type": "code",
20-
"execution_count": 2,
20+
"execution_count": 1,
2121
"id": "68a99b3b-58f1-4251-a724-f5135ac72be1",
2222
"metadata": {},
2323
"outputs": [
2424
{
2525
"data": {
2626
"application/vnd.jupyter.widget-view+json": {
27-
"model_id": "abe319d952074d1c8517503b7c05313b",
27+
"model_id": "417572db6a764f559a34856fb1306fcc",
2828
"version_major": 2,
2929
"version_minor": 0
3030
},
@@ -46,10 +46,25 @@
4646
},
4747
{
4848
"cell_type": "code",
49-
"execution_count": null,
49+
"execution_count": 2,
5050
"id": "9452eaf1-38ff-463f-b272-95baa8f840a5",
5151
"metadata": {},
52-
"outputs": [],
52+
"outputs": [
53+
{
54+
"data": {
55+
"application/vnd.jupyter.widget-view+json": {
56+
"model_id": "a0f3cb258b4a4769b7fb30cca72df05c",
57+
"version_major": 2,
58+
"version_minor": 0
59+
},
60+
"text/plain": [
61+
"Map(center=[44.400002, 3.36667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
62+
]
63+
},
64+
"metadata": {},
65+
"output_type": "display_data"
66+
}
67+
],
5368
"source": [
5469
"m2 = Map(center=(44.400002, 3.36667), zoom=10, zoom_control=True)\n",
5570
"layer2 = GeoportalWMTS(layer = 'ELEVATION.SLOPES', api_key = 'altimetrie')\n",
@@ -58,10 +73,25 @@
5873
},
5974
{
6075
"cell_type": "code",
61-
"execution_count": null,
76+
"execution_count": 3,
6277
"id": "69d5a707-f501-4d5c-a22e-3e59e2656aaf",
6378
"metadata": {},
64-
"outputs": [],
79+
"outputs": [
80+
{
81+
"data": {
82+
"application/vnd.jupyter.widget-view+json": {
83+
"model_id": "bdc4d761ead245b3842ff2be4f5a600a",
84+
"version_major": 2,
85+
"version_minor": 0
86+
},
87+
"text/plain": [
88+
"Map(center=[44.799999, 2.26667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
89+
]
90+
},
91+
"metadata": {},
92+
"output_type": "display_data"
93+
}
94+
],
6595
"source": [
6696
"m3 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
6797
"layer3 = GeoportalWMTS(layer = 'GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2', api_key = 'cartes', format = 'image/png')\n",
@@ -70,15 +100,38 @@
70100
},
71101
{
72102
"cell_type": "code",
73-
"execution_count": null,
103+
"execution_count": 4,
74104
"id": "2936c8dc-1546-4f13-8c18-6984aaf1c0e3",
75105
"metadata": {},
76-
"outputs": [],
106+
"outputs": [
107+
{
108+
"data": {
109+
"application/vnd.jupyter.widget-view+json": {
110+
"model_id": "902bb6b777a14cae8d2e377e514ed5e8",
111+
"version_major": 2,
112+
"version_minor": 0
113+
},
114+
"text/plain": [
115+
"Map(center=[44.400002, 3.36667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
116+
]
117+
},
118+
"metadata": {},
119+
"output_type": "display_data"
120+
}
121+
],
77122
"source": [
78123
"m4 = Map(center=(44.400002, 3.36667), zoom=10, zoom_control=True)\n",
79124
"layer4 = GeoportalWMTS(layer = 'HYDROGRAPHY.BCAE.LATEST', api_key = 'agriculture', format = 'image/png')\n",
80125
"m4.add(layer4)"
81126
]
127+
},
128+
{
129+
"cell_type": "code",
130+
"execution_count": null,
131+
"id": "ee4e38eb-0ac7-47d4-bc7d-be74a7e761c7",
132+
"metadata": {},
133+
"outputs": [],
134+
"source": []
82135
}
83136
],
84137
"metadata": {

ipyleaflet/geoportal.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,14 @@ class GeoportalLayerSwitcher(Control):
3737

3838
_view_name = Unicode('LeafletGeoportalLayerSwitcherView').tag(sync=True)
3939
_model_name = Unicode('LeafletGeoportalLayerSwitcherModel').tag(sync=True)
40+
41+
class GeoportalSearchEngine(Control):
42+
"""GeoportalSearchEngine class, with Control as parent class
43+
44+
Attributes
45+
----------
46+
"""
47+
48+
_view_name = Unicode('LeafletGeoportalSearchEngineView').tag(sync=True)
49+
_model_name = Unicode('LeafletGeoportalSearchEngineModel').tag(sync=True)
50+

js/src/jupyter-leaflet.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ require('leaflet.awesome-markers/dist/leaflet.awesome-markers.css');
6161
require('spin.js/spin.css');
6262
require('./jupyter-leaflet.css');
6363
require('leaflet-search/dist/leaflet-search.src.css');
64+
require('geoportal-extensions-leaflet/dist/GpPluginLeaflet-map.css');
65+
require('geoportal-extensions-leaflet/dist/GpPluginLeaflet-src.css');
66+
require('geoportal-extensions-leaflet/dist/GpPluginLeaflet.css');

js/src/layers/Geoportal.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ export class LeafletGeoportalWMTSModel extends layer.LeafletTileLayerModel {
2121

2222
export class LeafletGeoportalWMTSView extends layer.LeafletTileLayerView {
2323
create_obj() {
24-
console.log('this.get_options():', this.get_options())
25-
this.obj = L.geoportalLayer.WMTS(this.get_options(), {format : this.model.get('format')})
24+
this.obj = L.geoportalLayer.WMTS({layer : this.model.get('layer'), apiKey : this.model.get('api_key')}, {format : this.model.get('format')})
2625
}
2726
}
2827

@@ -46,3 +45,23 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
4645
}
4746
}
4847

48+
export class LeafletGeoportalSearchEngineModel extends control.LeafletControlModel {
49+
defaults() {
50+
return {
51+
...super.defaults(),
52+
_view_name: 'LeafletGeoportalSearchEngineView',
53+
_model_name: 'LeafletGeoportalSearchEngineModel'
54+
};
55+
}
56+
}
57+
58+
export class LeafletGeoportalSearchEngineView extends control.LeafletControlView {
59+
initialize(parameters) {
60+
super.initialize(parameters);
61+
this.map_view = this.options.map_view;
62+
}
63+
create_obj() {
64+
this.obj = L.geoportalControl.SearchEngine({position : "topright"})
65+
}
66+
}
67+

0 commit comments

Comments
 (0)