Skip to content

Commit

Permalink
Allow titles for additional WMS layers
Browse files Browse the repository at this point in the history
When listing WMS layers from GeoServer in the Other Map Settings, allows
a title to be specified which appears in the layer switcher. Previously
layers were simply numbered.
  • Loading branch information
JimBacon committed Feb 19, 2016
1 parent 8d6e110 commit c86ebea
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions prebuilt_forms/includes/map.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ function iform_map_get_map_parameters() {
array(
'name' => 'indicia_wms_layers',
'caption' => 'WMS layers from GeoServer',
'description' => 'List of WMS feature type names, one per line, which are installed on the GeoServer and are to be added to the map as overlays.',
'description' => 'List of WMS feature type names, one per line, which are installed on the GeoServer and are to be added to the map as overlays. ' .
'Optionally, prefix the feature type name with a title to appear in the layer switcher using the form title = feature-name.',
'type' => 'textarea',
'group'=>'Other Map Settings',
'required'=>false
Expand Down Expand Up @@ -287,7 +288,21 @@ function iform_map_get_map_options($args, $readAuth) {
}
// And any indicia Wms layers from the GeoServer
if (!empty($args['indicia_wms_layers'])) {
$options['indiciaWMSLayers'] = explode("\n", $args['indicia_wms_layers']);
$wmsLayers = explode("\n", $args['indicia_wms_layers']);
// Each layer may either just be a feature name or, optionally, may be
// prefixed by a title in the form title = feature.
foreach ($wmsLayers as $layer) {
$separatorPos = strpos($layer, '=');
if ($separatorPos !== FALSE) {
// A title is present.
$title = trim(substr($layer, 0, $separatorPos - 1));
$feature = trim(substr($layer, $separatorPos + 1));
$options['indiciaWMSLayers'][$title] = $feature;
}
else {
$options['indiciaWMSLayers'][] = $layer;
}
}
}
// set up standard control list if supplied
if (array_key_exists('standard_controls', $args) && $args['standard_controls']) {
Expand Down

0 comments on commit c86ebea

Please sign in to comment.