Skip to content

Commit

Permalink
Add Isocurve control.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaudinFlorence committed Sep 9, 2022
1 parent f77f1fe commit d6b4259
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 20 deletions.
36 changes: 17 additions & 19 deletions examples/GeoportalControls.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "6bb0dd68-f96d-45c5-b3de-48c2092f2690",
"metadata": {},
"outputs": [],
"source": [
"from ipyleaflet import *\n",
"from ipyleaflet.geoportal import GeoportalWMTS, GeoportalLayerSwitcher, GeoportalSearchEngine, GeoportalRoute, GeoportalMousePosition, GeoportalElevationPath"
"from ipyleaflet.geoportal import GeoportalWMTS, GeoportalLayerSwitcher, GeoportalSearchEngine, GeoportalRoute, GeoportalMousePosition, GeoportalElevationPath, GeoportalIsocurve"
]
},
{
Expand Down Expand Up @@ -76,25 +76,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "17a9e9bb-f3a5-40e5-90ea-8d57049cda5f",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "de83e395ef634b6da1c061289ceac763",
"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": [
"#ElevationPath control\n",
"m4 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
Expand All @@ -108,6 +93,19 @@
"id": "88acf040-74f1-419d-a3b8-766b9a538d43",
"metadata": {},
"outputs": [],
"source": [
"#Isocurve control\n",
"m5 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
"isocurve_control = GeoportalIsocurve()\n",
"m5.add(isocurve_control)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b6ca529f-62dd-4464-ba19-e2f4b5b15df5",
"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 @@ -81,3 +81,14 @@ class GeoportalElevationPath(Control):

_view_name = Unicode('LeafletGeoportalElevationPathView').tag(sync=True)
_model_name = Unicode('LeafletGeoportalElevationPathModel').tag(sync=True)


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

_view_name = Unicode('LeafletGeoportalIsocurveView').tag(sync=True)
_model_name = Unicode('LeafletGeoportalIsocurveModel').tag(sync=True)
48 changes: 47 additions & 1 deletion js/src/layers/Geoportal.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,22 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
this.map_view = this.options.map_view;
}
create_obj() {
this.obj = L.geoportalControl.SearchEngine({position : "bottomleft"})
this.obj = L.geoportalControl.SearchEngine({
position : "topleft",
collapsed : true,
zoomTo : "auto",
displayInfo : true,
displayAdvancedSearch : true,
resources : ["PositionOfInterest", "StreetAddress"],
advancedSearch : {
PositionOfInterest : [{name : "municipality", title : "Ville"}],
StreetAddress : [{}],
CadastralParcel : null,
},
apiKey : "cartes",
geocodeOptions : {},
autocompleteOptions : {}
})
}
}

Expand Down Expand Up @@ -125,5 +140,36 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
}
}

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

export class LeafletGeoportalIsocurveView extends control.LeafletControlView {
initialize(parameters) {
super.initialize(parameters);
this.map_view = this.options.map_view;
}
create_obj() {
this.obj = L.geoportalControl.Isocurve({
collapsed : false,
methods : ["time", "distance"],
exclusions : {
toll : true,
bridge : false,
tunnel : true
},
graphs : ["Pieton", "Voiture"],
isocurveOptions : {},
autocompleteOptions : {}})
}
}




0 comments on commit d6b4259

Please sign in to comment.