Skip to content

Commit fb5f6cc

Browse files
authored
Merge pull request #442 from IGNF/ticket-704/ajustement
gfi accessible menu context + icon controllist
2 parents 2e5c10c + 85cc393 commit fb5f6cc

File tree

7 files changed

+76
-5
lines changed

7 files changed

+76
-5
lines changed

DRAFT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ __DATE__
1515

1616
*[Added]
1717

18+
- Contextual Menu : Ajout du getFeatureInfo dans les entrées du menu contextuel (#442)
19+
1820
* 🔨 [Changed]
1921

2022
* 🔥 [Deprecated]

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "geopf-extensions-openlayers",
33
"description": "French Geoportal Extensions for OpenLayers libraries",
4-
"version": "1.0.0-beta.6",
5-
"date": "18/09/2025",
4+
"version": "1.0.0-beta.6-442",
5+
"date": "22/09/2025",
66
"module": "src/index.js",
77
"directories": {},
88
"engines": {

samples-src/pages/tests/ContextMenu/pages-ol-modules-contextmenu-dsfr.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{{#content "vendor"}}
33
<link rel="stylesheet" href="{{ baseurl }}/dist/modules/GpfExtOlLayerSwitcher.css" />
44
<script src="{{ baseurl }}/dist/modules/GpfExtOlLayerSwitcher.js"></script>
5+
<link rel="stylesheet" href="{{ baseurl }}/dist/modules/GpfExtOlGetFeatureInfo.css" />
6+
<script src="{{ baseurl }}/dist/modules/GpfExtOlGetFeatureInfo.js"></script>
57
<link rel="stylesheet" href="{{ baseurl }}/dist/modules/GpfExtOlIsocurve.css" />
68
<script src="{{ baseurl }}/dist/modules/GpfExtOlIsocurve.js"></script>
79
<link rel="stylesheet" href="{{ baseurl }}/dist/modules/GpfExtOlLayerImport.css" />
@@ -48,6 +50,7 @@ <h2>Ajout de tous les widgets</h2>
4850
})
4951
});
5052

53+
5154
// 2. Ajout de plusieurs couches différentes.
5255
var gpMaps = new ol.layer.Tile({
5356
source : new ol.source.GeoportalWMTS({
@@ -56,6 +59,35 @@ <h2>Ajout de tous les widgets</h2>
5659
});
5760
map.addLayer(gpMaps);
5861

62+
var gpDrone = new ol.layer.Tile({
63+
source : new ol.source.GeoportalWMTS({
64+
layer: "TRANSPORTS.DRONES.RESTRICTIONS"
65+
})
66+
});
67+
map.addLayer(gpDrone);
68+
69+
var gpMyKml = new ol.layer.Vector({
70+
source: new ol.source.Vector({
71+
url: '{{ resources }}/data/kml/S_TOP100.kml',
72+
format: new ol.format.KML()
73+
})
74+
});
75+
map.addLayer(gpMyKml);
76+
77+
var gpRoad = new ol.layer.Tile({
78+
source : new ol.source.GeoportalWMS({
79+
layer: "TN.RoadTransportNetwork"
80+
})
81+
});
82+
map.addLayer(gpRoad);
83+
84+
var gpHydro = new ol.layer.Tile({
85+
source : new ol.source.GeoportalWMS({
86+
layer: "HY.PhysicalWaters"
87+
})
88+
});
89+
map.addLayer(gpHydro);
90+
5991
// 3. Ajout du context menu
6092
var itemsOpt = [ {
6193
text : "Imprimer la carte",
@@ -110,6 +142,10 @@ <h2>Ajout de tous les widgets</h2>
110142
auto: true
111143
});
112144
map.addControl(catalog);
145+
var getFeatureInfo = new ol.control.GetFeatureInfo({
146+
position : "bottom-left",
147+
});
148+
map.addControl(getFeatureInfo);
113149
};
114150
Gp.Services.getConfig({
115151
customConfigFile : "https://data.geopf.fr/annexes/cartes.gouv.fr-config/public/layers.json",

src/packages/CSS/Controls/ControlList/DSFRcontrolListStyle.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/* GET FEATURE INFO */
2+
3+
button[id^="GPshowControlListPicto-"]::after {
4+
-webkit-mask: url("img/more-line.svg") center no-repeat;
5+
mask: url("img/more-line.svg") center no-repeat;
6+
mask-size: 70%;
7+
}
8+
19
button[id^="GPshowControlListPicto-"][aria-pressed="true"] + dialog {
210
width: 370px;
311
}
@@ -9,7 +17,7 @@ div[id^="GPcontrolList-"] {
917
div[id^="GPcontrolList-"] .GPshowOpen > span {
1018
font-size: 32px;
1119
position: absolute;
12-
transform: translate(-5px, -2px);
20+
/* transform: translate(-5px, -2px); */
1321
}
1422

1523
dialog[id^="GPcontrolListPanel-"] .gpf-panel__content {
@@ -75,5 +83,5 @@ dialog[id^="GPcontrolListPanel-"] .gpf-panel__footer > button {
7583
width: 32px;
7684
background-color: var(--border-default-grey);
7785
position: absolute;
78-
transform: translate(-7px, -7px);
86+
/* transform: translate(-7px, -7px); */
7987
}
Lines changed: 1 addition & 0 deletions
Loading

src/packages/Controls/ContextMenu/ContextMenu.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ class ContextMenu extends Control {
291291
*/
292292
getAvailableContextMenuControls () {
293293
var allItems = [
294+
{
295+
text : "Obtenir informations",
296+
classname : "ol-context-menu-custom fr-text--md",
297+
callback : this.getFeatureInfo.bind(this),
298+
control_CLASSNAME : "GetFeatureInfo"
299+
},
294300
{
295301
text : "Adresse / Coordonnées",
296302
classname : "ol-context-menu-custom fr-text--md",
@@ -414,6 +420,25 @@ class ContextMenu extends Control {
414420
isocurve.setData(data);
415421
}
416422

423+
/**
424+
* Fonction qui lance le GFI
425+
* pour les coordonnées sous le clic
426+
*
427+
* @param {*} evt event
428+
*/
429+
getFeatureInfo (evt) {
430+
var gfi = this.getMap().getControls().getArray().filter(control => control.CLASSNAME == "GetFeatureInfo")[0];
431+
gfi.buttonGetFeatureInfoShow.click();
432+
gfi.buttonGetFeatureInfoShow.setAttribute("aria-pressed", true);
433+
let pixel = this.getMap().getPixelFromCoordinate(evt.coordinate);
434+
let fakeEvent = {
435+
pixel : pixel,
436+
map : this.getMap(),
437+
coordinate : evt.coordinate
438+
};
439+
this.getMap().dispatchEvent({ type : "singleclick", ...fakeEvent });
440+
}
441+
417442
/**
418443
* Fonction qui ouvre le widget des légendes
419444
*

src/packages/Controls/ControlList/ControlListDOM.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ var ControlListDOM = {
4242
// INFO: Ajout d'une SPAN pour enlever des marges de 6px dans CHROMIUM (?!)
4343
var span = document.createElement("span");
4444
button.appendChild(span);
45-
span.innerText = "+";
4645
button.id = this._addUID("GPshowControlListPicto");
4746
button.className = "GPshowOpen GPshowAdvancedToolPicto GPshowControlListPicto gpf-btn gpf-btn--tertiary gpf-btn-icon gpf-btn-icon-controllist fr-btn fr-btn--tertiary";
4847
button.setAttribute("aria-label", "Tous mes outils");

0 commit comments

Comments
 (0)