--- modules/openlayers_ui/includes/openlayers_ui.presets.inc Tue Jun 08 04:41:40 2010 +++ modules/openlayers_ui/includes/openlayers_ui.presets.inc Sun Jun 27 21:38:23 2010 @@ -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', --- modules/openlayers_views/views/openlayers-views-map.tpl.php Tue Mar 23 07:55:10 2010 +++ modules/openlayers_views/views/openlayers-views-map.tpl.php Sun Jun 27 20:51:31 2010 @@ -6,4 +6,6 @@ * Template file for map */ ?> +
+ --- openlayers.module Thu Jun 10 19:06:50 2010 +++ openlayers.module Sun Jun 27 21:47:59 2010 @@ -155,6 +155,18 @@ // 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)));