Added a new GIS map source type called WMS

This commit is contained in:
Alejandro Gallardo Escobar 2018-04-27 12:17:42 +02:00
parent 3855e4c378
commit cc06dfe876
5 changed files with 83 additions and 7 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,24 @@ $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") . ':</td>' .
'<td>' .
html_print_input_text('layers', $layers, '', 90, 255, true) .
'</td>' .
'</tr>' .
'</table>';
if ($mapConnectionData != null) {
switch ($mapConnection_type) {
case 'OSM':
@ -271,6 +304,9 @@ if ($mapConnectionData != null) {
case 'Static_Image':
$optionsConnectionTypeTable = $optionsConnectionImageTable;
break;
case 'WMS':
$optionsConnectionTypeTable = $optionsConnectionWMSTable;
break;
}
}
@ -434,6 +470,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 +525,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

@ -139,7 +139,7 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob
map.events.on({"zoomend": EventZoomEnd});
map.events.on({"mouseup": EventZoomEnd});
//Define the maps layer
for (var baselayerIndex in objBaseLayers) {
if (isInt(baselayerIndex)) {
@ -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) {