diff --git a/plugins/behaviors/openlayers_behavior_popup.inc b/plugins/behaviors/openlayers_behavior_popup.inc index 9e02e0c..74ff9aa 100644 --- a/plugins/behaviors/openlayers_behavior_popup.inc +++ b/plugins/behaviors/openlayers_behavior_popup.inc @@ -30,7 +30,9 @@ class openlayers_behavior_popup extends openlayers_behavior { function options_init() { return array( 'layers' => array(), - ); + 'panMapIfOutOfView' => FALSE, + 'keepInMap' => TRUE, + ); } /** @@ -55,6 +57,18 @@ class openlayers_behavior_popup extends openlayers_behavior { '#default_value' => isset($defaults['layers']) ? $defaults['layers'] : array(), ), + 'panMapIfOutOfView' => array( + '#type' => 'checkbox', + '#title' => t('Pan map if popup out of view'), + '#description' => t('When drawn, pan map such that the entire popup is visible in the current viewport (if necessary).'), + '#default_value' => isset($defaults['panMapIfOutOfView']) ? $defaults['panMapIfOutOfView'] : FALSE + ), + 'keepInMap' => array( + '#type' => 'checkbox', + '#title' => t('Keep in map'), + '#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 + ), ); } diff --git a/plugins/behaviors/openlayers_behavior_popup.js b/plugins/behaviors/openlayers_behavior_popup.js index 82ecfb4..5042ca1 100644 --- a/plugins/behaviors/openlayers_behavior_popup.js +++ b/plugins/behaviors/openlayers_behavior_popup.js @@ -76,6 +76,8 @@ Drupal.openlayers.addBehavior('openlayers_behavior_popup', function (data, optio // Assign popup to feature and map. feature.popup = popup; + feature.popup.panMapIfOutOfView = options.panMapIfOutOfView; + feature.popup.keepInMap = options.keepInMap; feature.layer.map.addPopup(popup); Drupal.attachBehaviors(); Drupal.openlayers.popup.selectedFeature = feature;