Skip to content

Commit c70fb9d

Browse files
Add the attribute format to enable to set the format of the image of the layer.
1 parent 7b899f0 commit c70fb9d

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

examples/Geoportal.ipynb

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,57 @@
1818
{
1919
"cell_type": "code",
2020
"execution_count": null,
21-
"id": "119aacd7-fb6b-4bf5-9a97-ac8301eabfed",
21+
"id": "68a99b3b-58f1-4251-a724-f5135ac72be1",
2222
"metadata": {},
2323
"outputs": [],
2424
"source": [
2525
"from ipyleaflet import *\n",
2626
"from ipyleaflet.geoportal import GeoportalWMTS\n",
27-
"m1 = Map(center=(48.799999, 2.26667), zoom=10, zoom_control=True)\n",
27+
"m1 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
2828
"layer1 = GeoportalWMTS() #default\n",
2929
"m1.add(layer1)"
3030
]
3131
},
3232
{
3333
"cell_type": "code",
3434
"execution_count": null,
35-
"id": "2936c8dc-1546-4f13-8c18-6984aaf1c0e3",
35+
"id": "9452eaf1-38ff-463f-b272-95baa8f840a5",
3636
"metadata": {},
3737
"outputs": [],
3838
"source": [
39-
"m2 = Map(center=(44.400002, 3.36667), zoom=8, zoom_control=True)\n",
39+
"m2 = Map(center=(44.400002, 3.36667), zoom=10, zoom_control=True)\n",
4040
"layer2 = GeoportalWMTS(layer = 'ELEVATION.SLOPES', api_key = 'altimetrie')\n",
4141
"m2.add(layer2)"
4242
]
4343
},
4444
{
4545
"cell_type": "code",
4646
"execution_count": null,
47-
"id": "cfeff952-288f-4e56-9dd7-4b7e160e6305",
47+
"id": "69d5a707-f501-4d5c-a22e-3e59e2656aaf",
4848
"metadata": {},
4949
"outputs": [],
5050
"source": [
51-
"m3 = Map(center=(48.799999, 2.26667), zoom=10, zoom_control=True)\n",
52-
"layer3 = GeoportalWMTS(layer = 'GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2', api_key = 'cartes')\n",
51+
"m3 = Map(center=(44.799999, 2.26667), zoom=10, zoom_control=True)\n",
52+
"layer3 = GeoportalWMTS(layer = 'GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2', api_key = 'cartes', format = 'image/png')\n",
5353
"m3.add(layer3)"
5454
]
5555
},
5656
{
5757
"cell_type": "code",
5858
"execution_count": null,
59-
"id": "54d2e006-a2f3-406b-9bb0-c1d7cb6b250e",
59+
"id": "2936c8dc-1546-4f13-8c18-6984aaf1c0e3",
60+
"metadata": {},
61+
"outputs": [],
62+
"source": [
63+
"m4 = Map(center=(44.400002, 3.36667), zoom=10, zoom_control=True)\n",
64+
"layer4 = GeoportalWMTS(layer = 'HYDROGRAPHY.BCAE.LATEST', api_key = 'agriculture', format = 'image/png')\n",
65+
"m4.add(layer4)"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": null,
71+
"id": "b6edf13b-f9a1-45c4-b28a-7e9028d4f89f",
6072
"metadata": {},
6173
"outputs": [],
6274
"source": []

ipyleaflet/geoportal.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ class GeoportalWMTS(TileLayer):
1717
name of the layer to show.
1818
api_key: string, default "essentiels"
1919
key to access a given ressource, detailed correspondances are given here : https://geoservices.ign.fr/documentation/services/tableau_ressources
20+
format: string, default "image/png"
21+
format of the image
2022
"""
2123

2224
_view_name = Unicode('LeafletGeoportalWMTSView').tag(sync=True)
2325
_model_name = Unicode('LeafletGeoportalWMTSModel').tag(sync=True)
24-
layer = Unicode("ORTHOIMAGERY.ORTHOPHOTOS").tag(sync=True, o=True)
25-
api_key = Unicode("essentiels").tag(sync=True, o=True)
26+
layer = Unicode('ORTHOIMAGERY.ORTHOPHOTOS').tag(sync=True, o=True)
27+
api_key = Unicode('essentiels').tag(sync=True, o=True)
28+
format = Unicode('image/jpeg').tag(sync=True, o=True)

js/src/layers/Geoportal.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ export class LeafletGeoportalWMTSModel extends layer.LeafletTileLayerModel {
1111
...super.defaults(),
1212
_view_name: 'LeafletGeoportalWMTSView',
1313
_model_name: 'LeafletGeoportalWMTSModel',
14-
layer : "ORTHOIMAGERY.ORTHOPHOTOS",
15-
apiKey : "essentiels"
14+
layer : 'ORTHOIMAGERY.ORTHOPHOTOS',
15+
apiKey : 'essentiels',
16+
format : 'image/jpeg'
1617
};
1718
}
1819
}
1920

2021
export class LeafletGeoportalWMTSView extends layer.LeafletTileLayerView {
2122
create_obj() {
22-
this.obj = L.geoportalLayer.WMTS({layer : this.model.get('layer'), apiKey : this.model.get('api_key')})
23+
this.obj = L.geoportalLayer.WMTS(this.get_options(), {format : this.model.get('format')})
2324
}
2425
}

0 commit comments

Comments
 (0)