diff options
-rw-r--r-- | chimere/static/chimere/css/styles.css | 2 | ||||
-rw-r--r-- | chimere/static/chimere/js/jquery.chimere.js | 113 |
2 files changed, 71 insertions, 44 deletions
diff --git a/chimere/static/chimere/css/styles.css b/chimere/static/chimere/css/styles.css index 1494c2f..3d8ba13 100644 --- a/chimere/static/chimere/css/styles.css +++ b/chimere/static/chimere/css/styles.css @@ -558,7 +558,7 @@ div#sidebar-container{ width: 400px; top: 35px; height: 80px; - padding: 2px 0; + padding: 4px 0; overflow: hidden; box-shadow: 0 -10px 5px rgba(0, 0, 0, 0.6); } diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js index 06f437b..a680724 100644 --- a/chimere/static/chimere/js/jquery.chimere.js +++ b/chimere/static/chimere/js/jquery.chimere.js @@ -558,44 +558,7 @@ function transformCoordToLonLat(coord) { return feature; } ); - if (typeof feature != 'undefined'){ - if (settings[map_id].current_feature == feature){ - return - } else { - settings[map_id].current_feature = feature; - } - } else { - settings[map_id].current_feature = null; - } - if (!settings[map_id].edition){ - if (methods._is_popuphovering(map_id)) return; - $(settings[map_id].popup_item).popover('destroy'); - settings[map_id].current_hover = null; - $("#" + map_id + "_hover").html(""); - $("#" + map_id + "_hover").hide(); - if (feature) { - // wait for the popover to be fully destroyed... - // should be better managed with BS4 - setTimeout(function(){ - // zoom on aggregated - var key = feature.get('key'); - if (key && key.length > 3 && key.substring(0, 3) == 'agg' && - settings[map_id]._zoom_need_reload){ - var current_zoom = settings[map_id].map.getView().getZoom(); - if (current_zoom < settings[map_id]._zoom_need_reload){ - settings[map_id].map.getView().setZoom(settings[map_id]._zoom_need_reload); - settings[map_id].map.getView().setCenter(evt.coordinate); - } - return - } - if (key && key.length > 6 && key.substring(0, 7) == 'cluster'){ - feature = methods.clickOnCluster(map_id, feature); - } else { - methods.openPopup(map_id, feature); - } - }, 200); - } - } + methods._showPopupForFeature(map_id, feature); }); $("#" + map_id).append( "<div class='map_hover_div' id='" + map_id + "_hover'></div>"); @@ -1008,12 +971,12 @@ function transformCoordToLonLat(coord) { // have to wait for something - but cannot figure what... setTimeout(function(){ if (current_feature){ - methods._showPopup(map_id, current_feature); + methods._showPopup(map_id, current_feature, false); } settings[map_id].layerDbFeatures.dispatchEvent('change'); settings[map_id].clusterLayer.dispatchEvent('change'); settings[map_id].map.render(); - }, 500); + }, 1500); } if (current_feature != "" || routing_start != "" @@ -3386,12 +3349,76 @@ function transformCoordToLonLat(coord) { var bounds = settings[map_id].layerVectors.getDataExtent(); if (bounds) settings[map_id].map.zoomToExtent(bounds); }, - _showPopup: function (map_id, feature_pk){ + _showPopupForFeature: function (map_id, feature){ + if (typeof feature != 'undefined'){ + if (settings[map_id].current_feature == feature){ + return + } else { + settings[map_id].current_feature = feature; + } + } else { + settings[map_id].current_feature = null; + } + if (!settings[map_id].edition){ + if (methods._is_popuphovering(map_id)) return; + $(settings[map_id].popup_item).popover('destroy'); + settings[map_id].current_hover = null; + $("#" + map_id + "_hover").html(""); + $("#" + map_id + "_hover").hide(); + if (feature) { + // wait for the popover to be fully destroyed... + // should be better managed with BS4 + setTimeout(function(){ + // zoom on aggregated + var key = feature.get('key'); + if (key && key.length > 3 && key.substring(0, 3) == 'agg' && + settings[map_id]._zoom_need_reload){ + var current_zoom = settings[map_id].map.getView().getZoom(); + if (current_zoom < settings[map_id]._zoom_need_reload){ + settings[map_id].map.getView().setZoom(settings[map_id]._zoom_need_reload); + settings[map_id].map.getView().setCenter(evt.coordinate); + } + return + } + if (key && key.length > 6 && key.substring(0, 7) == 'cluster'){ + feature = methods.clickOnCluster(map_id, feature); + } else { + methods.openPopup(map_id, feature); + } + }, 200); + } + } + }, + _showPopup: function (map_id, feature_pk, zoom){ var feats = settings[map_id].dbFeatures.getArray(); for (j in feats){ var c_marker = feats[j]; if (c_marker.getProperties()['key'] == feature_pk){ - methods.openPopup(map_id, c_marker); + if (zoom){ + var v = settings[map_id].map.getView(); + var zoom_level = 14; + + duration = settings[map_id].animation_duration * 2; + // zoom + v.setZoom(zoom_level); + methods._set_animation(map_id, duration); + // center + if ($("#panel").is(":visible")){ + var delta_x = $("#panel").width() / 2; + // paning before zoom base delta divided by 2 + if (zoom_level < settings[map_id].maxZoom){ + delta_x = delta_x / 2; + } + v.centerOn( + c_marker.getGeometry().getCoordinates(), + [0, 0], + [delta_x, 0]); + } else { + v.setCenter(c_marker.getGeometry().getCoordinates()); + } + } + + methods._showPopupForFeature(map_id, c_marker); return true } } @@ -3408,7 +3435,7 @@ function transformCoordToLonLat(coord) { alert("showPopup - Public method only"); return; } - return methods._showPopup(map_id, feature_pk); + return methods._showPopup(map_id, feature_pk, true); }, hidePopup: function () { var map_id = methods.map_id(this); |