Index: modules/openlayers_ui/includes/openlayers_ui.presets.inc =================================================================== --- modules/openlayers_ui/includes/openlayers_ui.presets.inc (revision 2) +++ modules/openlayers_ui/includes/openlayers_ui.presets.inc (working copy) @@ -131,6 +131,18 @@ $defaults['proxy_host'] : '', ); + $form['info']['hide_empty_map'] = array( + '#type' => 'checkbox', + '#title' => t('Hide empty map'), + '#description' => t("By default, this map is always displayed. When + this option is selected, the map is only displayed if it has one + or more features (marker, line, etc) to show. If there are no + features (ie an empty map), no map is shown. (If you're using a + view to display this map and you select this option, the view's + 'Empty Text' is shown when the map is empty)."), + '#default_value' => isset($defaults['hide_empty_map']), + ); + // Center $form['center'] = array( '#title' => t('Center & Bounds'), @@ -535,6 +547,7 @@ 'image_path', 'css_path', 'proxy_host', + 'hide_empty_map', 'center', 'behaviors', 'layers', Index: modules/openlayers_views/views/openlayers-views-map.tpl.php =================================================================== --- modules/openlayers_views/views/openlayers-views-map.tpl.php (revision 2) +++ modules/openlayers_views/views/openlayers-views-map.tpl.php (working copy) @@ -6,4 +6,6 @@ * Template file for map */ ?> -
+ +
+ Index: openlayers.module =================================================================== --- openlayers.module (revision 2) +++ openlayers.module (working copy) @@ -155,6 +155,19 @@ // Run map through build process $map = openlayers_build_map($map); + if ($map['hide_empty_map']){ + // Check if the map has any features defined. If not, assume it is + // an empty map and shouldn't be displayed. + $feature_count = 0; + $layers = $map['layers']; + foreach ($layers as $layer) { + $feature_count += count($layer['features']); + } + if ($feature_count == 0) { + return '' ; + } + } + // Return themed map if no errors found if (empty($map['errors'])) { $js = array('openlayers' => array('maps' => array($map['id'] => $map)));