diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-09-25 18:52:47 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-09-25 18:52:47 +0200 |
commit | e0bad3de8c2ceaca933a283e1675cf029e8733b7 (patch) | |
tree | 527f1d0274b753a1059c677c10e3659c56411be4 | |
parent | cfd0123064e68546e86745ca550a45794cdf27dc (diff) | |
download | Chimère-e0bad3de8c2ceaca933a283e1675cf029e8733b7.tar.bz2 Chimère-e0bad3de8c2ceaca933a283e1675cf029e8733b7.zip |
Display POI name on hover (refs #4125)
-rw-r--r-- | chimere/static/chimere/js/jquery.chimere.js | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js index ec9513e..62899ec 100644 --- a/chimere/static/chimere/js/jquery.chimere.js +++ b/chimere/static/chimere/js/jquery.chimere.js @@ -522,6 +522,8 @@ function transformCoordToLonLat(coord) { */ settings[map_id].map.addLayer(settings[map_id].layerDbFeatures); + settings[map_id].mouse_hover_opened = ''; + if (!settings[map_id].edition){ // popup management settings[map_id].popup_item = document.getElementById(settings[map_id].popupId); @@ -579,25 +581,46 @@ function transformCoordToLonLat(coord) { document.getElementById(target) : target; target.style.cursor = hit ? 'pointer' : ''; /* manage hover on a feature */ - if (feature && feature.getProperties()['hover_div']){ + if (feature) { var pk = feature.getId(); - if (settings[map_id].current_hover == pk) return; - settings[map_id].current_hover = pk; - $("#" + map_id + "_hover").html( - feature.getProperties()['hover_div']); - var pixel = settings[map_id].map.getPixelFromCoordinate( - feature.getGeometry().getCoordinates() - ); - var x = pixel[0] + feature.getProperties()['popup_offset_x'] - + 22; - var y = pixel[1] - feature.getProperties()['popup_offset_y'] - - 0; - $("#" + map_id + "_hover").css( - {top: y + 'px', left: x + 'px'} - ); - $("#" + map_id + "_hover").show(); + if (feature.getProperties()['hover_div']){ + if (settings[map_id].current_hover == pk) return; + settings[map_id].current_hover = pk; + $("#" + map_id + "_hover").html( + feature.getProperties()['hover_div']); + var pixel = settings[map_id].map.getPixelFromCoordinate( + feature.getGeometry().getCoordinates() + ); + var x = pixel[0] + feature.getProperties()['popup_offset_x'] + + 22; + var y = pixel[1] - feature.getProperties()['popup_offset_y'] + - 0; + $("#" + map_id + "_hover").css( + {top: y + 'px', left: x + 'px'} + ); + $("#" + map_id + "_hover").show(); + } else { + if (settings[map_id].mouse_hover_opened != pk){ + settings[map_id].mouse_hover_opened = pk; + if ($('.popover-content').is(':visible')){ + $(settings[map_id].popup_item).popover('destroy'); + } + if (feature.get('name')){ + methods.openPopup( + map_id, feature, null, null, + feature.getGeometry().getCoordinates(), + true); + } + } + } } else { + if (settings[map_id].mouse_hover_opened){ + settings[map_id].mouse_hover_opened = null; + if ($('.popover-content').is(':visible')){ + $(settings[map_id].popup_item).popover('destroy'); + } + } if (settings[map_id].current_hover){ settings[map_id].current_hover = null; $("#" + map_id + "_hover").html(""); @@ -1342,7 +1365,8 @@ function transformCoordToLonLat(coord) { }); return feature; }, - openPopup: function(map_id, feature, offset_x, offset_y, alt_coordinates){ + openPopup: function(map_id, feature, offset_x, offset_y, + alt_coordinates, no_detail){ settings[map_id].current_feature = feature; if (!offset_x){ offset_x = feature.get('popup_offset_x'); @@ -1379,7 +1403,9 @@ function transformCoordToLonLat(coord) { methods._unregister_popuphovering(map_id); }) $(settings[map_id].popup_item).popover('show'); - methods.display_feature_detail(map_id, feature.get('key'), feature.get('name')); + if (!no_detail){ + methods.display_feature_detail(map_id, feature.get('key'), feature.get('name')); + } }, /* end of new ol3 */ update_permalink_activation:function(map_id){ |