Skip to content

Commit a7c624e

Browse files
committed
add parameter to display popup or not
1 parent a896858 commit a7c624e

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

docs/customization.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ Non-existent fields can be used if a display function exist.
228228

229229
If a model isn't configured in ``LABEL_PER_MODEL``, the object's string representation is used as the title.
230230
If a specified field doesn't exist on the model, it won't be displayed. The detail page button is always shown.
231+
If the option ``displayPopup`` is setup to false, then the popup will not appear when clicking on the feature.
231232

232233
Settings
233234
-----------

mapentity/static/mapentity/leaflet-objectslayer.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ L.ObjectsLayer = L.GeoJSON.extend({
33
indexing: true,
44
highlight: true,
55
objectUrl: null,
6+
displayPopup: true,
67
styles: {
78
'default': {'color': 'blue', 'weight': 2, 'opacity': 0.8},
89
highlight: {'color': 'red', 'weight': 5, 'opacity': 1},
@@ -70,24 +71,25 @@ L.ObjectsLayer = L.GeoJSON.extend({
7071
}, this));
7172

7273
this.on('click', async function (e) {
73-
var popup_content;
74-
try{
75-
popup_content = await this.getPopupContent(e.layer);
76-
} catch (error) {
77-
popup_content = gettext('Data unreachable');
78-
}
79-
if (e.target._popup){
80-
// update popup content if it has been already bind
81-
var popup = e.target._popup;
82-
popup.setContent(popup_content);
83-
popup.update();
84-
} else {
85-
// bind a new popup
86-
this.bindPopup(popup_content).openPopup(e.latlng);
74+
if(this.options.displayPopup){
75+
var popup_content;
76+
try{
77+
popup_content = await this.getPopupContent(e.layer);
78+
} catch (error) {
79+
popup_content = gettext('Data unreachable');
80+
}
81+
if (e.target._popup){
82+
// update popup content if it has been already bind
83+
var popup = e.target._popup;
84+
popup.setContent(popup_content);
85+
popup.update();
86+
} else {
87+
// bind a new popup
88+
this.bindPopup(popup_content).openPopup(e.latlng);
89+
}
8790
}
8891
}, this);
8992

90-
9193
var dataurl = null;
9294
if (typeof(geojson) == 'string') {
9395
dataurl = geojson;
@@ -250,7 +252,7 @@ L.ObjectsLayer = L.GeoJSON.extend({
250252
throw new Error('Cannot parse data');
251253
}
252254
}
253-
}
255+
},
254256

255257
});
256258

0 commit comments

Comments
 (0)