Skip to content

Commit

Permalink
Popup: remove remaining OL2 dependencies (3liz#4535)
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault authored Jun 20, 2024
1 parent 283ec7c commit 30db326
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1269,15 +1269,13 @@ window.lizMap = function() {

/**
*
* @param text
* @param xy
* @param {string} text - text to display
* @param {object} xy - x and y in pixels
* @param {array} coordinate - coordinate in map unit
*/
function displayGetFeatureInfo(text, xy){
function displayGetFeatureInfo(text, xy, coordinate){
var eventLonLatInfo = map.getLonLatFromPixel(xy);

if (map.popups.length != 0)
map.removePopup(map.popups[0]);

var popup = null;
var popupContainerId = null;
if( 'popupLocation' in config.options && config.options.popupLocation != 'map' ){
Expand Down Expand Up @@ -1320,12 +1318,19 @@ window.lizMap = function() {
$('#button-popupcontent').click();
}
} else {
// Hide previous popup
lizMap.mainLizmap.popup.mapPopup.setVisible(false);

if (!text || text == null || text == ''){
return false;
}

document.getElementById('liz_layer_popup_contentDiv').innerHTML = text;
lizMap.mainLizmap.popup.mapPopup.setPosition([eventLonLatInfo.lon, eventLonLatInfo.lat]);
if (coordinate) {
lizMap.mainLizmap.popup.mapPopup.setPosition(coordinate);
} else {
lizMap.mainLizmap.popup.mapPopup.setPosition([eventLonLatInfo.lon, eventLonLatInfo.lat]);
}

// Activate Boostrap 2 tabs here as they are not
// automatically activated when created in popup anchored
Expand Down Expand Up @@ -3362,8 +3367,8 @@ window.lizMap = function() {
return deactivateToolControls( evt );
},

displayGetFeatureInfo: function( text, xy ) {
return displayGetFeatureInfo( text, xy );
displayGetFeatureInfo: function( text, xy, coordinate ) {
return displayGetFeatureInfo( text, xy, coordinate );
},

/**
Expand Down
2 changes: 1 addition & 1 deletion assets/src/modules/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default class Popup {
attributeNameCheck: /crs|bbox|edition-restricted/,
}
});
lizMap.displayGetFeatureInfo(sanitizedResponse, { x: xCoord, y: yCoord });
lizMap.displayGetFeatureInfo(sanitizedResponse, { x: xCoord, y: yCoord }, evt?.coordinate);
}).finally(() => {
document.getElementById('newOlMap').style.cursor = 'auto';
});
Expand Down

0 comments on commit 30db326

Please sign in to comment.