From 97a9610a4c1c6734d07798f442bf486560a74b94 Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Wed, 9 Jul 2014 14:23:49 +1200 Subject: [PATCH] Attempts to revert features committed from #1516758 and #2038463 --- plugins/behaviors/openlayers_behavior_popup.inc | 14 ------- plugins/behaviors/openlayers_behavior_popup.js | 40 ++------------------ .../behaviors/openlayers_behavior_zoomtolayer.js | 24 ++---------- 3 files changed, 7 insertions(+), 71 deletions(-) diff --git a/plugins/behaviors/openlayers_behavior_popup.inc b/plugins/behaviors/openlayers_behavior_popup.inc index ba4df8f..b2ca8d1 100644 --- a/plugins/behaviors/openlayers_behavior_popup.inc +++ b/plugins/behaviors/openlayers_behavior_popup.inc @@ -16,8 +16,6 @@ class openlayers_behavior_popup extends openlayers_behavior { 'layers' => array(), 'panMapIfOutOfView' => FALSE, 'keepInMap' => TRUE, - 'zoomToPoint' => FALSE, - 'zoomToCluster' => FALSE, 'popupAtPosition' => 'mouse' ); } @@ -66,18 +64,6 @@ class openlayers_behavior_popup extends openlayers_behavior { '#description' => t('If panMapIfOutOfView is false, and this property is true, contrain the popup such that it always fits in the available map space.'), '#default_value' => isset($defaults['keepInMap']) ? $defaults['keepInMap'] : TRUE ), - 'zoomToPoint' => array( - '#type' => 'checkbox', - '#title' => t('Zoom to point'), - '#description' => t('When a point is clicked, zoom to it instead of displaying a popup.'), - '#default_value' => isset($defaults['zoomToPoint']) ? $defaults['zoomToPoint'] : FALSE - ), - 'zoomToCluster' => array( - '#type' => 'checkbox', - '#title' => t('Zoom to cluster'), - '#description' => t('When a cluster is clicked, zoom to it instead of displaying a popup.'), - '#default_value' => isset($defaults['zoomToCluster']) ? $defaults['zoomToCluster'] : FALSE - ), ); } diff --git a/plugins/behaviors/openlayers_behavior_popup.js b/plugins/behaviors/openlayers_behavior_popup.js index 33eae5e..4c63fd8 100644 --- a/plugins/behaviors/openlayers_behavior_popup.js +++ b/plugins/behaviors/openlayers_behavior_popup.js @@ -75,37 +75,6 @@ Drupal.openlayers.addBehavior('openlayers_behavior_popup', function (data, optio } }, onSelect: function(feature) { - // Check if we have any zoom settings set. If zoom to point is enabled, - // it will disable the popup behavior for points, - // and the same for clusters. - if (options.zoomToPoint || options.zoomToCluster) { - var fullExtent; - // If we have zoomToCluster enabled and the feature is a cluster, - // accumulate the fullExtent of all points in the cluster. - var isCluster = typeof feature.cluster != 'undefined' && feature.cluster.length > 1; - if (options.zoomToCluster && isCluster) { - for (var i = 0; i < feature.cluster.length; i++) { - point = feature.cluster[i]; - if (fullExtent instanceof OpenLayers.Bounds) { - fullExtent.extend(point.geometry.getBounds()); - } else { - fullExtent = point.geometry.getBounds(); - } - } - } - // Otherwise, if zoomToPoint is enabled and it's not a cluster, set - // the fullExtent to the bounds of the point. - else if (options.zoomToPoint && !isCluster){ - fullExtent = feature.geometry.getBounds(); - } - - if (fullExtent instanceof OpenLayers.Bounds) { - map.zoomToExtent(fullExtent); - // Don't attempt to popup when zooming. - return; - } - } - var lonlat; if (options.popupAtPosition == 'mouse') { lonlat = map.getLonLatFromPixel( @@ -141,12 +110,9 @@ Drupal.openlayers.addBehavior('openlayers_behavior_popup', function (data, optio Drupal.attachBehaviors(); }, onUnselect: function(feature) { - // If the feature has a popup, remove it. - if (feature.popup) { - map.removePopup(feature.popup); - feature.popup.destroy(); - feature.popup = null; - } + map.removePopup(feature.popup); + feature.popup.destroy(); + feature.popup = null; this.unselectAll(); Drupal.attachBehaviors(); } diff --git a/plugins/behaviors/openlayers_behavior_zoomtolayer.js b/plugins/behaviors/openlayers_behavior_zoomtolayer.js index 1a38cc5..db8506b 100644 --- a/plugins/behaviors/openlayers_behavior_zoomtolayer.js +++ b/plugins/behaviors/openlayers_behavior_zoomtolayer.js @@ -59,27 +59,11 @@ Drupal.openlayers.addBehavior('openlayers_behavior_zoomtolayer', function (data, */ function accumulate_extent(layer){ var layerextent = layer.getDataExtent(); - var featureCount = layer.features.length; - // If there is only one feature and it's a cluster, zoom into that cluster. - if (featureCount == 1 && layer.features[0].cluster) { - var cluster = layer.features[0].cluster; - // Accumulate the extent of the cluster points - for (var i = 0; i < cluster.length; i++) { - point = cluster[i]; - if (fullExtent instanceof OpenLayers.Bounds) { - fullExtent.extend(point.geometry.getBounds()); - } else { - fullExtent = point.geometry.getBounds(); - } - } + if (fullExtent instanceof OpenLayers.Bounds) { + fullExtent.extend(layerextent); } - // Otherwise zoom to the extent of the layer. - else { - if(fullExtent instanceof OpenLayers.Bounds){ - fullExtent.extend(layerextent); - } else if(layerextent instanceof OpenLayers.Bounds) { - fullExtent = layerextent; - } + else if (layerextent instanceof OpenLayers.Bounds) { + fullExtent = layerextent; } } -- 1.7.9.5