Merge branch 'ent-2103-wms-map-server' into 'develop'

Added a new GIS map source type called WMS

See merge request artica/pandorafms!1469
This commit is contained in:
vgilc 2018-05-09 10:28:30 +02:00
commit 220ea8d319
5 changed files with 99 additions and 27 deletions

View File

@ -123,6 +123,15 @@ switch ($action) {
'image_height' => $image_height
);
break;
case 'WMS':
$url = get_parameter('url');
$layers = get_parameter('layers');
$mapConnectionData = array(
'type' => 'WMS',
'url' => $url,
'layers' => $layers
);
break;
}
//TODO VALIDATE PARAMETERS
@ -168,6 +177,7 @@ $table->data = array();
$types["OSM"] = __('Open Street Maps');
$types["Gmap"] = __('Google Maps');
$types["Static_Image"] = __('Static Image');
$types["WMS"] = __('WMS Server');
$table->data[0][0] = __('Type') . ":";
$table->data[0][1] = html_print_select($types, 'sel_type', $mapConnection_type, "selMapConnectionType();", __('Please select the connection type'), 0, true);
@ -184,6 +194,7 @@ $bb_bottom = '';
$bb_top = '';
$image_width = '';
$image_height = '';
$layers = '';
if ($mapConnectionData != null) {
switch ($mapConnection_type) {
case 'OSM':
@ -202,6 +213,10 @@ if ($mapConnectionData != null) {
$image_width= $mapConnectionData['image_width'];
$image_height= $mapConnectionData['image_height'];
break;
case 'WMS':
$mapConnectionDataUrl = $mapConnectionData['url'];
$layers = $mapConnectionData['layers'];
break;
}
}
// Open Street Map Connection
@ -260,6 +275,27 @@ $optionsConnectionImageTable = '<table class="databox" border="0" cellpadding="4
'<td>'. html_print_input_text ('image_height', $image_height, '', 25, 25, true) . '</td>' .
'</tr>' .
'</table>';
// WMS Server Connection
$optionsConnectionWMSTable = '<table class="databox" border="0" cellpadding="4" cellspacing="4" width="50%">' .
'<tr class="row_0">' .
'<td>' . __("WMS Server URL") . '</td>' .
'<td>' .
'<input id="type" type="hidden" name="type" value="WMS" />' .
html_print_input_text('url', $mapConnectionDataUrl, '', 90, 255, true) .
'</td>' .
'</tr>' .
'<tr class="row_1">' .
'<td>' .
__("Layers") .
ui_print_help_tip (__('Enter a single element or a comma separated list'), true) .
'</td>' .
'<td>' .
html_print_input_text('layers', $layers, '', 90, 255, true) .
'</td>' .
'</tr>' .
'</table>';
if ($mapConnectionData != null) {
switch ($mapConnection_type) {
case 'OSM':
@ -271,6 +307,9 @@ if ($mapConnectionData != null) {
case 'Static_Image':
$optionsConnectionTypeTable = $optionsConnectionImageTable;
break;
case 'WMS':
$optionsConnectionTypeTable = $optionsConnectionWMSTable;
break;
}
}
@ -434,6 +473,8 @@ function refreshMapViewSecondStep() {
objBaseLayers[0]['bb_top'] = $('input[name=bb_top]').val();
objBaseLayers[0]['image_width'] = $('input[name=image_width]').val();
objBaseLayers[0]['image_height'] = $('input[name=image_height]').val();
// type WMS
objBaseLayers[0]['layers'] = $('input[name=layers]').val();
arrayControls = null;
arrayControls = Array('Navigation', 'PanZoom', 'MousePosition');
@ -487,6 +528,9 @@ function selMapConnectionType() {
case 'Static_Image':
$('#form_map_connection_type').html('<?php echo $optionsConnectionImageTable; ?>').hide();
break;
case 'WMS':
$('#form_map_connection_type').html('<?php echo $optionsConnectionWMSTable; ?>').hide();
break;
default:
$('#form_map_connection_type').html('').hide();
break;

View File

@ -118,6 +118,10 @@ function gis_print_map($idDiv, $iniZoom, $latCenter, $lonCenter, $baselayers, $c
case 'Gmap':
echo "baselayer['gmap_type'] = '" . $baselayer['gmap_type'] . "';";
break;
case 'WMS':
echo "baselayer['url'] = '" . $baselayer['url'] . "';";
echo "baselayer['layers'] = '" . $baselayer['layers'] . "';";
break;
}
echo "baselayerList.push(baselayer);";
@ -1035,6 +1039,10 @@ function gis_get_agent_map($agent_id, $heigth, $width, $show_history = false, $c
$baselayers[0]['image_width'] = $conectionData['image_width'];
$baselayers[0]['image_height'] = $conectionData['image_height'];
break;
case 'WMS':
$baselayers[0]['url'] = $conectionData['url'];
$baselayers[0]['layers'] = $conectionData['layers'];
break;
}
if ($gmap_layer === true) {

View File

@ -217,6 +217,29 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob
);
map.addLayer(baseLayer);
break;
case 'WMS':
// http://<server>/geoserver/wms
// ?bbox=-130,24,-66,50
// &styles=population
// &Format=application/openlayers
// &request=GetMap
// &layers=topp:states
// &width=550
// &height=250
// &srs=EPSG:4326
var layer = new OpenLayers.Layer.WMS(
objBaseLayers[baselayerIndex]['name'],
objBaseLayers[baselayerIndex]['url'],
{
layers: objBaseLayers[baselayerIndex]['layers'],
format: "image/png"
},
{
numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels']
}
);
map.addLayer(layer);
break;
}
}
}

View File

@ -96,6 +96,10 @@ if ($confMap !== false) {
$baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width'];
$baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height'];
break;
case 'WMS':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
$baselayers[$num_baselayer]['layers'] = $decodeJSON['layers'];
break;
}
$num_baselayer++;
if ($mapC['default_map_connection'] == 1) {
@ -203,11 +207,7 @@ if ($layers != false) {
// Resize GIS map on fullscreen
?>
<script type="text/javascript">
$().ready(function() {
var new_height = $(document).height();
$("#map").css("height", new_height - 60);
$("svg[id*=OpenLayers]").css("height", new_height - 60);
$(document).ready(function() {
$("#map").css("height", $(document).height() - 100);
});
</script>

View File

@ -77,6 +77,10 @@ if ($confMap !== false) {
$baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width'];
$baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height'];
break;
case 'WMS':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
$baselayers[$num_baselayer]['layers'] = $decodeJSON['layers'];
break;
}
$num_baselayer++;
if ($mapC['default_map_connection'] == 1) {
@ -157,12 +161,12 @@ $buttons[]['text'] = '&nbsp;' . __('Show agents by state: ') .
ui_print_page_header(__('Map') . " &raquo; " . __('Map') . "&nbsp;" . $map['map_name'],
"images/op_gis.png", false, "", false, $buttons);
if ($config["pure"] == 0) {
echo "<div id='map' style='width: 100%; height: 500px; border: 1px solid black;' ></div>";
}
else {
echo "<div id='map' style='position:absolute; top:40px; z-index:100; width: 100%; height: 500px; min-height:500px; border: 1px solid black;' ></div>";
}
$map_inline_style = "width: 100%; min-height:500px; height: calc(100vh - 80px);";
$map_inline_style .= $config["pure"]
? "position:absolute; top: 80px; left: 0px;"
: "border: 1px solid black;";
echo '<div id="map" style="' . $map_inline_style . '" />';
gis_print_map('map', $map['zoom_level'], $map['initial_latitude'],
$map['initial_longitude'], $baselayers, $controls);
@ -234,18 +238,11 @@ if ($layers != false) {
gis_activate_ajax_refresh($layers, $timestampLastOperation);
}
// Resize GIS map on fullscreen
if ($config["pure"] != 0) {
?>
<script type="text/javascript">
$().ready(function() {
var new_height = $(document).height();
$("#map").css("height", new_height - 60);
$("svg[id*=OpenLayers]").css("height", new_height - 60);
});
</script>
<?php
}
?>
<script type="text/javascript">
$(document).ready(function() {
var $map = $("#map");
$map.css("height", "calc(100vh - " + $map.offset().top + "px - 20px)");
});
</script>