Skip to content

Commit

Permalink
Update or add options of the various controls.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaudinFlorence committed Sep 13, 2022
1 parent 3c05e88 commit 39dafb8
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 94 deletions.
42 changes: 21 additions & 21 deletions examples/GeoportalControls.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "3a686d99-c3ca-4596-81aa-24442564bea2",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "47bf5fd8b8aa413fb0eacad5627beee6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[44.799999, 2.26667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"#LayerSwitcher control\n",
"m1 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
Expand Down Expand Up @@ -75,14 +59,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "0a7ca855-c96d-4864-9b9c-1873712033bb",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "787604374bd34bbdba450d271c0f60bb",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[44.799999, 2.26667], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', '…"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#MousePosition control\n",
"m3 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
"mouse_position_control = GeoportalMousePosition()\n",
"mouse_position_control = GeoportalMousePosition(display_altitude=True)\n",
"m3.add(mouse_position_control)"
]
},
Expand Down
91 changes: 52 additions & 39 deletions ipyleaflet/geoportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Distributed under the terms of the Modified BSD License.


from traitlets import Unicode, Bool, List, Dict
from traitlets import Unicode, Bool, List, Dict, Instance, Any
from .leaflet import TileLayer, Control


Expand Down Expand Up @@ -36,6 +36,17 @@ class GeoportalLayerSwitcher(Control):

_view_name = Unicode("LeafletGeoportalLayerSwitcherView").tag(sync=True)
_model_name = Unicode("LeafletGeoportalLayerSwitcherModel").tag(sync=True)
position = Unicode("bottomleft").tag(sync=True, o=True)
collapsed = Bool(False).tag(sync=True, o=True)
layers = List([]).tag(sync=True, o=True)
layer = Instance(TileLayer).tag(sync=True, o=True)
display = Bool(True).tag(sync=True, o=True)
config = Any().tag(sync=True, o=True)
visibility = Unicode("").tag(sync=True, o=True)
title = Unicode("").tag(sync=True, o=True)
description = Unicode("").tag(sync=True, o=True)
quicklook_url = Unicode("").tag(sync=True, o=True)
legends = List([]).tag(sync=True, o=True)


class GeoportalSearchEngine(Control):
Expand All @@ -54,7 +65,6 @@ class GeoportalSearchEngine(Control):
collapsed = Bool(True).tag(sync=True, o=True)
zoomTo = Unicode("auto").tag(sync=True, o=True)
displayInfo = Bool(True).tag(sync=True, o=True)
apiKey = Unicode("cartes").tag(sync=True, o=True)
displayAdvancedSearch = Bool(True).tag(sync=True, o=True)
resources = List(["PositionOfInterest", "StreetAddress"]).tag(sync=True, o=True)
advancedSearch = Dict({}).tag(sync=True, o=True)
Expand All @@ -69,14 +79,19 @@ class GeoportalRoute(Control):
----------
"""

_view_name = Unicode("LeafletGeoportalRouteView").tag(sync=True)
_model_name = Unicode("LeafletGeoportalRouteModel").tag(sync=True)
position = Unicode("bottomleft").tag(sync=True)
collapsed = Bool(True).tag(sync=True)
exclusions = Dict({"toll": True, "bridge": False, "tunnel": True}).tag(sync=True)
graphs = List(["Pieton", "Voiture"]).tag(sync=True)
autocompleteOptions = Dict({}).tag(sync=True)
routeOptions = Dict({}).tag(sync=True)
_view_name = Unicode("LeafletGeoportalRouteView").tag(sync=True, o=True)
_model_name = Unicode("LeafletGeoportalRouteModel").tag(sync=True, o=True)
api_key = Unicode("essentiels").tag(sync=True, o=True)
position = Unicode("bottomleft").tag(sync=True, o=True)
collapsed = Bool(True).tag(sync=True, o=True)
ssl = Bool(True).tag(sync=True, o=True)
disableReverse = Bool(False).tag(sync=True, o=True)
exclusions = Dict({"toll": True, "bridge": False, "tunnel": True}).tag(
sync=True, o=True
)
graphs = List(["Pieton", "Voiture"]).tag(sync=True, o=True)
autocompleteOptions = Dict({}).tag(sync=True, o=True)
routeOptions = Dict({}).tag(sync=True, o=True)


class GeoportalMousePosition(Control):
Expand All @@ -86,27 +101,17 @@ class GeoportalMousePosition(Control):
----------
"""

_view_name = Unicode("LeafletGeoportalMousePositionView").tag(sync=True)
_model_name = Unicode("LeafletGeoportalMousePositionModel").tag(sync=True)
position = Unicode("bottomleft").tag(sync=True)
collapsed = Bool(False).tag(sync=True)
displayAltitude = Bool(True).tag(sync=True)
displayCoordinates = Bool(True).tag(sync=True)
editCoordinates = Bool(False).tag(sync=True)
altitude = Dict({}).tag(sync=True)
serviceOptions = Dict({})
crs = Unicode().tag(sync=True)
label = Unicode().tag(sync=True)
selectedtype = Unicode().tag(sync=True)
systems = (
List(
[
{crs: "", label: "Lon,Lat", selectedtype: "Geographical"},
{crs: "", label: "Lambert 93", selectedtype: "Metric"},
]
).tag(sync=True),
)
units = List(["DEC", "DMS"]).tag(sync=True)
_view_name = Unicode("LeafletGeoportalMousePositionView").tag(sync=True, o=True)
_model_name = Unicode("LeafletGeoportalMousePositionModel").tag(sync=True, o=True)
api_key = Unicode("essentiels").tag(sync=True, o=True)
position = Unicode("bottomleft").tag(sync=True, o=True)
collapsed = Bool(False).tag(sync=True, o=True)
display_altitude = Bool(False).tag(sync=True, o=True)
display_coordinates = Bool(True).tag(sync=True, o=True)
edit_coordinates = Bool(True).tag(sync=True, o=True)
systems = List([]).tag(sync=True, o=True)
altitude = Any([]).tag(sync=True, o=True)
units = List([]).tag(sync=True, o=True)


class GeoportalElevationPath(Control):
Expand All @@ -118,6 +123,13 @@ class GeoportalElevationPath(Control):

_view_name = Unicode("LeafletGeoportalElevationPathView").tag(sync=True)
_model_name = Unicode("LeafletGeoportalElevationPathModel").tag(sync=True)
api_key = Unicode("essentiels").tag(sync=True, o=True)
position = Unicode("bottomleft").tag(sync=True, o=True)
openssl = Bool(True).tag(sync=True, o=True)
active = Bool(False).tag(sync=True, o=True)
stylesOptions = Unicode("DEFAULT_STYLES").tag(sync=True, o=True)
elevationPathOptions = Dict({}).tag(sync=True, o=True)
displayProfileOptions = Dict({}).tag(sync=True, o=True)


class GeoportalIsocurve(Control):
Expand All @@ -127,11 +139,12 @@ class GeoportalIsocurve(Control):
----------
"""

_view_name = Unicode("LeafletGeoportalIsocurveView").tag(sync=True)
_model_name = Unicode("LeafletGeoportalIsocurveModel").tag(sync=True)
collapsed = (Bool(False).tag(sync=True),)
methods = (List(["time", "distance"]).tag(sync=True),)
exclusions = (Dict({}).tag(sync=True),)
graphs = (List(["Pieton", "Voiture"]).tag(sync=True),)
isocurveOptions = (Dict({}).tag(sync=True),)
autocompleteOptions = Dict({}).tag(sync=True)
_view_name = Unicode("LeafletGeoportalIsocurveView").tag(sync=True, o=True)
_model_name = Unicode("LeafletGeoportalIsocurveModel").tag(sync=True, o=True)
api_key = Unicode("essentiels").tag(sync=True, o=True)
collapsed = Bool(False).tag(sync=True, o=True)
methods = List(["time", "distance"]).tag(sync=True, o=True)
exclusions = Dict({}).tag(sync=True).tag(sync=True, o=True)
graphs = List(["Pieton", "Voiture"]).tag(sync=True, o=True)
isocurveOptions = Dict({}).tag(sync=True, o=True)
autocompleteOptions = Dict({}).tag(sync=True).tag(sync=True, o=True)
62 changes: 28 additions & 34 deletions js/src/controls/GeoportalControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
defaults() {
return {
...super.defaults(),
_view_name: 'LeafletGeoportalLayerSwitcherView',
_model_name: 'LeafletGeoportalLayerSwitcherModel'
_view_name: 'LeafletGeoportalLayerSwitcherView',
_model_name: 'LeafletGeoportalLayerSwitcherModel',
position : "bottomleft",
collapsed : false,
layers : []
};
}
}
Expand All @@ -21,7 +24,7 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
this.map_view = this.options.map_view;
}
create_obj() {
this.obj = L.geoportalControl.LayerSwitcher()
this.obj = L.geoportalControl.LayerSwitcher(this.get_options())
}
}

Expand All @@ -31,11 +34,11 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
...super.defaults(),
_view_name: 'LeafletGeoportalSearchEngineView',
_model_name: 'LeafletGeoportalSearchEngineModel',
apiKey : 'essentiels',
position : 'topleft',
collapsed : true,
zoomTo : 'auto',
displayInfo : true,
apiKey : 'cartes',
displayAdvancedSearch : true,
resources : ["PositionOfInterest", "StreetAddress"],
advancedSearch : {},
Expand All @@ -61,8 +64,11 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
...super.defaults(),
_view_name: 'LeafletGeoportalRouteView',
_model_name: 'LeafletGeoportalRouteModel',
apiKey : 'essentiels',
position : "bottomleft",
collapsed : true,
ssl : true,
disableReverse : false,
exclusions : {"toll" : true,
"bridge" : false,
"tunnel" : true
Expand Down Expand Up @@ -90,35 +96,15 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
...super.defaults(),
_view_name: 'LeafletGeoportalMousePositionView',
_model_name: 'LeafletGeoportalMousePositionModel',
apiKey : 'essentiels',
position : 'bottomleft',
collapsed : false,
displayAltitude : true,
displayAltitude : false,
displayCoordinates : true,
editCoordinates : false,
crs : '',
label : '',
selectedtype: '',
altitude : {
triggerDelay : 100,
responseDelay : 500,
noDataValue : -99999,
noDataValueTolerance : 90000,
serviceOptions : {}
},
systems : [
{
crs : L.CRS.EPSG4326,
label : "Lon,Lat",
selectedtype : "Geographical"
},
{
crs : L.geoportalCRS.EPSG2154,
label : "Lambert 93",
selectedtype : "Metric"
}
],
units : ["DEC", "DMS"]

editCoordinates : true,
altitude : {},
systems : [],
units : []
};
}
}
Expand All @@ -129,16 +115,23 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
this.map_view = this.options.map_view;
}
create_obj() {
this.obj = L.geoportalControl.MousePosition({})
this.obj = L.geoportalControl.MousePosition(this.get_options())
}
}

export class LeafletGeoportalElevationPathModel extends control.LeafletControlModel {
defaults() {
return {
...super.defaults(),
_view_name: 'LeafletGeoportalElevationPathView',
_model_name: 'LeafletGeoportalElevationPathModel'
_view_name: 'LeafletGeoportalElevationPathView',
_model_name: 'LeafletGeoportalElevationPathModel',
apiKey : 'essentiels',
position : 'bottomleft',
openssl : true,
active : false,
stylesOptions : 'DEFAULT_STYLES',
elevationPathOptions: {},
displayProfileOptions : {},
};
}
}
Expand All @@ -149,7 +142,7 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
this.map_view = this.options.map_view;
}
create_obj() {
this.obj = L.geoportalControl.ElevationPath({})
this.obj = L.geoportalControl.ElevationPath(this.get_options())
}
}

Expand All @@ -159,6 +152,7 @@ export class LeafletGeoportalLayerSwitcherModel extends control.LeafletControlMo
...super.defaults(),
_view_name: 'LeafletGeoportalIsocurve',
_model_name: 'LeafletGeoportalIsocurveModel',
apiKey : 'essentiels',
collapsed : false,
methods : ["time", "distance"],
exclusions : {
Expand Down
Binary file not shown.
3 changes: 3 additions & 0 deletions ui-tests/playwright-report/index.html

Large diffs are not rendered by default.

Binary file not shown.

0 comments on commit 39dafb8

Please sign in to comment.