From bdb0459b8bd2be54d7e005601d0ac55ea0dde67c Mon Sep 17 00:00:00 2001 From: thechumley Date: Fri, 24 Aug 2012 09:31:10 +0200 Subject: [PATCH] Issue #1710634: Zoom to Layer doesn't work when the layer contains only one item --- plugins/behaviors/openlayers_behavior_zoomtolayer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/behaviors/openlayers_behavior_zoomtolayer.js b/plugins/behaviors/openlayers_behavior_zoomtolayer.js index 3dc4ff7..71897b2 100644 --- a/plugins/behaviors/openlayers_behavior_zoomtolayer.js +++ b/plugins/behaviors/openlayers_behavior_zoomtolayer.js @@ -32,6 +32,12 @@ Drupal.openlayers.addBehavior('openlayers_behavior_zoomtolayer', function (data, layerextent = layers[i].getDataExtent().scale(zoomtolayer_scale); map.fullExtent.extend(layerextent); map.zoomToExtent(map.fullExtent); + + // If unable to find width due to single point, + // zoom in with point_zoom_level option. + if (layerextent.getWidth() == 0.0) { + map.zoomTo(options.point_zoom_level); + } }); } else { -- 1.7.11.msysgit.0