2010-02-09 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_gis.php: clean source code, and extract the javascript code to openlayers.pandora.js. * include/javascript/openlayers.pandora.js: new file, have a source code of gis in javascript. * operation/gis_maps/render_view.php, operation/gis_maps/index.php, operation/agentes/gis_view.php, godmode/agentes/agent_manager.php, godmode/setup/gis.php, godmode/gis_maps/configure_gis_map.php, godmode/gis_maps/index.php: add the require javascript to "openlayers.pandora.js". * godmode/setup/gis_step_2.php: add the source code to improve usability, now can set with the mouse points of center and default position for agents without gis data. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2335 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
0b48209afc
commit
bc425eee8b
|
@ -1,3 +1,21 @@
|
|||
2010-02-09 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_gis.php: clean source code, and extract the javascript
|
||||
code to openlayers.pandora.js.
|
||||
|
||||
* include/javascript/openlayers.pandora.js: new file, have a source code of
|
||||
gis in javascript.
|
||||
|
||||
* operation/gis_maps/render_view.php, operation/gis_maps/index.php,
|
||||
operation/agentes/gis_view.php, godmode/agentes/agent_manager.php,
|
||||
godmode/setup/gis.php, godmode/gis_maps/configure_gis_map.php,
|
||||
godmode/gis_maps/index.php: add the require javascript to
|
||||
"openlayers.pandora.js".
|
||||
|
||||
* godmode/setup/gis_step_2.php: add the source code to improve usability,
|
||||
now can set with the mouse points of center and default position for agents
|
||||
without gis data.
|
||||
|
||||
2010-02-08 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* general/header.php, extensions/module_groups.php: Applied patch from
|
||||
|
|
|
@ -45,6 +45,8 @@ enterprise_include ('godmode/agentes/agent_manager.php');
|
|||
require_once ('include/functions_servers.php');
|
||||
require_once ('include/functions_gis.php');
|
||||
|
||||
require_javascript_file('openlayers.pandora');
|
||||
|
||||
$new_agent = (bool) get_parameter ('new_agent');
|
||||
|
||||
if (! isset ($id_agente) && ! $new_agent) {
|
||||
|
|
|
@ -19,6 +19,8 @@ check_login ();
|
|||
|
||||
require_once ('include/functions_gis.php');
|
||||
|
||||
require_javascript_file('openlayers.pandora');
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "IW")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access map builder");
|
||||
require ("general/noaccess.php");
|
||||
|
|
|
@ -19,12 +19,31 @@ check_login ();
|
|||
|
||||
require_once ('include/functions_gis.php');
|
||||
|
||||
require_javascript_file('openlayers.pandora');
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "IW")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access map builder");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_ajax ()) {
|
||||
$action = get_parameter('action');
|
||||
$id_map = get_parameter('id_map');
|
||||
|
||||
$returnOperationDB = process_sql_update('tgis_map', array('default_map' => 1), array('id_tgis_map' => $id_map));
|
||||
|
||||
if ($returnOperationDB === false)
|
||||
$data['correct'] = false;
|
||||
else
|
||||
$data['correct'] = true;
|
||||
|
||||
echo json_encode($data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$action = get_parameter('action');
|
||||
|
||||
switch ($action) {
|
||||
|
@ -40,11 +59,13 @@ $table->width = '500px';
|
|||
$table->head[0] = __('Map name');
|
||||
$table->head[1] = __('Group');
|
||||
$table->head[2] = __('View');
|
||||
$table->head[3] = __('Delete');
|
||||
$table->head[3] = __('Default');
|
||||
$table->head[4] = __('Delete');
|
||||
|
||||
$table->align[1] = 'center';
|
||||
$table->align[2] = 'center';
|
||||
$table->align[3] = 'center';
|
||||
$table->align[4] = 'center';
|
||||
|
||||
$maps = get_db_all_rows_in_table ('tgis_map','map_name');
|
||||
|
||||
|
@ -52,9 +73,15 @@ $table->data = array();
|
|||
|
||||
if ($maps !== false) {
|
||||
foreach ($maps as $map) {
|
||||
|
||||
$checked = false;
|
||||
if ($map['default_map'])
|
||||
$checked = true;
|
||||
|
||||
$table->data[] = array('<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&id='.$map['id_tgis_map'].'&action=edit_map">' . $map['map_name'] . '</a>',
|
||||
print_group_icon ($map['group_id'], true),
|
||||
'<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&id='.$map['id_tgis_map'].'">' . print_image ("images/eye.png", true).'</a>',
|
||||
print_radio_button_extended('default_map', $map['id_tgis_map'], '', $checked, false, "setDefault(" . $map['id_tgis_map'] . ");", '', true),
|
||||
'<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/index&id_map='.$map['id_tgis_map'].'&action=delete_map">' . print_image ("images/cross.png", true).'</a>');
|
||||
}
|
||||
}
|
||||
|
@ -68,3 +95,19 @@ print_submit_button (__('Create'), '', false, 'class="sub next"');
|
|||
echo '</form>';
|
||||
echo '</div>';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function setDefault(id_tgis_map) {
|
||||
jQuery.ajax ({
|
||||
data: "page=godmode/gis_maps/index&action=set_default&id_map=" + id_tgis_map,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
url: "ajax.php",
|
||||
timeout: 10000,
|
||||
success: function (data) {
|
||||
if (data.correct == 0) {
|
||||
alert('<?php echo __('There was error on setup the default map.');?>');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -26,6 +26,8 @@ if (! give_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_use
|
|||
|
||||
require_once ('include/functions_gis.php');
|
||||
|
||||
require_javascript_file('openlayers.pandora');
|
||||
|
||||
echo "<h2>".__('Pandora Setup')." » ";
|
||||
echo __('Map conections GIS')."</h2>";
|
||||
|
||||
|
|
|
@ -115,29 +115,19 @@ switch ($action) {
|
|||
|
||||
$table->width = '90%';
|
||||
|
||||
//$table->colspan[0][1] = 3;
|
||||
//$table->colspan[1][2] = 2;
|
||||
|
||||
$table->data = array();
|
||||
$table->data[0][0] = __('Name') . ":";
|
||||
$table->data[0][1] = print_input_text ('name', $mapConnection_name, '', 30, 60, true);
|
||||
$table->data[0][2] = __("Default position for not GIS data element");
|
||||
|
||||
$table->data[1][0] = __("Group") . ":";
|
||||
$table->data[1][1] = print_select_from_sql('SELECT id_grupo, nombre FROM tgrupo', 'group', $mapConnection_group, '', '', '0', true);
|
||||
$table->data[1][2] = __('Latitude') . ":";
|
||||
$table->data[1][3] = print_input_text ('default_latitude', $mapConnection_defaultLatitude, '', 4, 10, true);
|
||||
|
||||
$table->data[2][0] = __('Num levels zoom') . ":";
|
||||
$table->data[2][1] = print_input_text ('num_levels_zoom', $mapConnection_numLevelsZoom, '', 4, 10, true);
|
||||
$table->data[2][2] = __('Longitude') . ":";
|
||||
$table->data[2][3] = print_input_text ('default_longitude', $mapConnection_defaultLongitude, '', 4, 10, true);
|
||||
|
||||
|
||||
$table->data[3][0] = __('Default zoom level') . ":";
|
||||
$table->data[3][1] = print_input_text ('initial_zoom', $mapConnection_defaultZoom, '', 4, 10, true);
|
||||
$table->data[3][2] = __('Altitude') . ":";
|
||||
$table->data[3][3] = print_input_text ('default_altitude', $mapConnection_defaultAltitude, '', 4, 10, true);
|
||||
|
||||
echo "<h3>" . __('Basic configuration') . "</h3>";
|
||||
print_table($table);
|
||||
|
@ -180,42 +170,147 @@ if ($mapConnectionData != null) {
|
|||
|
||||
echo "<div id='form_map_connection_type'>" . $optionsConnectionTypeTable . "</div>";
|
||||
|
||||
echo "<h3>" . __('Preview and Select the center') . "</h3>";
|
||||
echo "<p>" . __("For test the conf and set the center of map.") . "</p>";
|
||||
echo "<a href='javascript: refreshMapView();'>" . __("Refresh the map view") . "</a>";
|
||||
echo "<div id='map' style='width: 300px; height: 300px; border: 1px solid black;'></div>";
|
||||
echo "<h3>" . __('Preview and Select the center of the map and the default position of an agent without gis data') . "</h3>";
|
||||
echo "<a id='link_save_refresh' href='javascript: refreshMapView();'>" . __("Load the map view") . "</a>";
|
||||
echo "<div id='map' style='width: 300px; height: 300px; border: 1px solid black; float: left'></div>";
|
||||
|
||||
$table->width = '30%';
|
||||
$table->width = '60%';
|
||||
$table->data = array();
|
||||
|
||||
$table->colspan[0][0] = 2;
|
||||
$table->data[0][0] = __('Center map connection');
|
||||
//$table->colspan[0][3] = 3;
|
||||
$table->data[0][0] = '';
|
||||
$table->data[0][1] = __('Center map connection');
|
||||
$table->data[0][2] = __("Default position for agents without GIS data");
|
||||
|
||||
$table->data[1][2] = __('Latitude') . ":";
|
||||
$table->data[1][3] = print_input_text ('center_latitude', $mapConnection_centerLatitude, '', 4, 10, true);
|
||||
$table->data[1][0] = __('Modify in map');
|
||||
$table->data[1][1] = print_radio_button_extended('radio_button', 1, '', 1, false, "changeSetManualPosition(true, false)", '', true);
|
||||
$table->data[1][2] = print_radio_button_extended('radio_button', 2, '', 0, false, "changeSetManualPosition(false, true)", '', true);
|
||||
|
||||
$table->data[2][2] = __('Longitude') . ":";
|
||||
$table->data[2][3] = print_input_text ('center_longitude', $mapConnection_centerLongitude, '', 4, 10, true);
|
||||
$table->data[2][0] = __('Latitude') . ":";
|
||||
$table->data[2][1] = print_input_text ('center_latitude', $mapConnection_centerLatitude, '', 10, 10, true);
|
||||
$table->data[2][2] = print_input_text ('default_latitude', $mapConnection_defaultLatitude, '', 10, 10, true);
|
||||
|
||||
$table->data[3][2] = __('Altitude') . ":";
|
||||
$table->data[3][3] = print_input_text ('center_altitude', $mapConnection_centerAltitude, '', 4, 10, true);
|
||||
$table->data[3][0] = __('Longitude') . ":";
|
||||
$table->data[3][1] = print_input_text ('center_longitude', $mapConnection_centerLongitude, '', 10, 10, true);
|
||||
$table->data[3][2] = print_input_text ('default_longitude', $mapConnection_defaultLongitude, '', 10, 10, true);
|
||||
|
||||
$table->data[4][0] = __('Altitude') . ":";
|
||||
$table->data[4][1] = print_input_text ('center_altitude', $mapConnection_centerAltitude, '', 10, 10, true);
|
||||
$table->data[4][2] = print_input_text ('default_altitude', $mapConnection_defaultAltitude, '', 10, 10, true);
|
||||
print_table($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'; float: left;">';
|
||||
echo '<div class="action-buttons" style="clear: left; width: 90%; float: left;">';
|
||||
print_submit_button (__('Save'), '', false, 'class="sub save"');
|
||||
echo '</div>';
|
||||
echo "</form>";
|
||||
?>
|
||||
<script type="text/javascript" src="http://dev.openlayers.org/nightly/OpenLayers.js"></script>
|
||||
<?php
|
||||
require_javascript_file('openlayers.pandora');
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var mapConfig = false;
|
||||
var setCenter = true;
|
||||
var centerPoint = null;
|
||||
var setGISDefaultPosition = false;
|
||||
var GISDefaultPositionPoint = null;
|
||||
|
||||
function refreshMapView() {
|
||||
if (mapConfig) {
|
||||
}
|
||||
else
|
||||
alert('<?php echo __('Please conf '); ?>');
|
||||
/**
|
||||
* Set the item to change, the center point or the center default.
|
||||
*
|
||||
* @param boolean stCenter Set center point for changing.
|
||||
* @param boolean stGISDefault Set GISDefault point for changing.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
function changeSetManualPosition(stCenter, stGISDefault) {
|
||||
setCenter = stCenter;
|
||||
setGISDefaultPosition = stGISDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback function when click the map. And make or move the points.
|
||||
*
|
||||
* @param object e The object of openlayer, that it has the parammeters of click.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
function changePoints(e) {
|
||||
var lonlat = map.getLonLatFromViewPortPx(e.xy);
|
||||
lonlat.transform(map.getProjectionObject(), map.displayProjection); //transform the lonlat in object proyection to "standar proyection"
|
||||
|
||||
if (setCenter) {
|
||||
//Change the fields
|
||||
center_latitude = $('input[name=center_latitude]').val(lonlat.lat);
|
||||
center_longitude = $('input[name=center_longitude]').val(lonlat.lon);
|
||||
|
||||
if (centerPoint == null) {
|
||||
centerPoint = js_addPointExtent('temp_layer', '<?php echo __('Center'); ?>', lonlat.lon, lonlat.lat, 'images/dot_green.png', 20, 20, 'center', '');
|
||||
}
|
||||
else {
|
||||
//return to no-standar the proyection for to move
|
||||
centerPoint.move(lonlat.transform(map.displayProjection, map.getProjectionObject()));
|
||||
}
|
||||
}
|
||||
|
||||
if (setGISDefaultPosition) {
|
||||
//Change the fields
|
||||
center_latitude = $('input[name=default_latitude]').val(lonlat.lat);
|
||||
center_longitude = $('input[name=default_longitude]').val(lonlat.lon);
|
||||
|
||||
if (GISDefaultPositionPoint == null) {
|
||||
GISDefaultPositionPoint = js_addPointExtent('temp_layer', '<?php echo __('Default'); ?>', lonlat.lon, lonlat.lat, 'images/dot_red.png', 20, 20, 'default', '');
|
||||
}
|
||||
else {
|
||||
//return to no-standar the proyection for to move
|
||||
GISDefaultPositionPoint.move(lonlat.transform(map.displayProjection, map.getProjectionObject()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to show and refresh the map. The function give the params for map of
|
||||
* fields. And make two points, center and default.
|
||||
*/
|
||||
function refreshMapView() {
|
||||
//Clear the previous map.
|
||||
map = null;
|
||||
$("#map").html('');
|
||||
//Clear the points.
|
||||
centerPoint = null;
|
||||
GISDefaultPositionPoint = null;
|
||||
|
||||
//Change the text.
|
||||
$("#link_save_refresh").html('<?php echo __("Refresh the map view");?>');
|
||||
|
||||
//Obtain data of map of fields.
|
||||
inital_zoom = $('input[name=initial_zoom]').val();
|
||||
num_levels_zoom =$('input[name=num_levels_zoom').val();
|
||||
center_latitude = $('input[name=center_latitude]').val();
|
||||
center_longitude = $('input[name=center_longitude]').val();
|
||||
center_altitude = $('input[name=center_altitude]').val();
|
||||
|
||||
var objBaseLayers = Array();
|
||||
objBaseLayers[0] = Array();
|
||||
objBaseLayers[0]['type'] = $('select[name=sel_type] :selected').val();
|
||||
objBaseLayers[0]['name'] = $('input[name=name]').val();
|
||||
objBaseLayers[0]['url'] = $('input[name=url]').val();
|
||||
|
||||
arrayControls = null;
|
||||
arrayControls = Array('Navigation', 'PanZoom', 'MousePosition');
|
||||
|
||||
js_printMap('map', inital_zoom, num_levels_zoom, center_latitude, center_longitude, objBaseLayers, arrayControls);
|
||||
|
||||
layer = js_makeLayer('temp_layer', true, null);
|
||||
|
||||
centerPoint = js_addPointExtent('temp_layer', '<?php echo __('Center'); ?>', $('input[name=center_longitude]').val(), $('input[name=center_latitude]').val(), 'images/dot_green.png', 20, 20, 'center', '');
|
||||
GISDefaultPositionPoint = js_addPointExtent('temp_layer', '<?php echo __('Default'); ?>', $('input[name=default_longitude]').val(), $('input[name=default_latitude]').val(), 'images/dot_red.png', 20, 20, 'default', '');
|
||||
|
||||
js_activateEvents(changePoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dinamic write the fields in form when select a type of connection.
|
||||
*/
|
||||
function selMapConnectionType() {
|
||||
switch ($('#sel_type :selected').val()) {
|
||||
case 'OSM':
|
||||
|
|
|
@ -19,14 +19,6 @@ function printMap($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $bas
|
|||
?>
|
||||
<script type="text/javascript" src="http://dev.openlayers.org/nightly/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map;
|
||||
|
||||
function isInt(x) {
|
||||
var y=parseInt(x);
|
||||
if (isNaN(y)) return false;
|
||||
return x==y && x.toString()==y.toString();
|
||||
}
|
||||
|
||||
$(document).ready (
|
||||
function () {
|
||||
map = new OpenLayers.Map ("<?php echo $idDiv; ?>", {
|
||||
|
@ -94,82 +86,11 @@ function printMap($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $bas
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
function showHideLayer(name, action) {
|
||||
var layer = map.getLayersByName(name);
|
||||
|
||||
layer[0].setVisibility(action);
|
||||
}
|
||||
|
||||
function js_addPoint(layerName, pointName, lon, lat, id, type_string) {
|
||||
var point = new OpenLayers.Geometry.Point(lon, lat)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
var layer = map.getLayersByName(layerName);
|
||||
layer = layer[0];
|
||||
|
||||
layer.addFeatures(new OpenLayers.Feature.Vector(point,{nombre: pointName, id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) }));
|
||||
}
|
||||
|
||||
function js_addPointExtent(layerName, pointName, lon, lat, icon, width, height, id, type_string) {
|
||||
var point = new OpenLayers.Geometry.Point(lon, lat)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
var layer = map.getLayersByName(layerName);
|
||||
layer = layer[0];
|
||||
layer.addFeatures(new OpenLayers.Feature.Vector(point,{id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) }, {fontWeight: "bolder", fontColor: "#00014F", labelYOffset: -height, graphicHeight: width, graphicWidth: height, externalGraphic: icon, label: pointName}));
|
||||
}
|
||||
|
||||
function js_addPointPath(layerName, lon, lat, color, manual, id) {
|
||||
var point = new OpenLayers.Geometry.Point(lon, lat)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
var layer = map.getLayersByName(layerName);
|
||||
layer = layer[0];
|
||||
|
||||
var pointRadiusNormal = 4;
|
||||
var strokeWidth = 2;
|
||||
var pointRadiusManual = pointRadiusNormal - (strokeWidth / 2);
|
||||
|
||||
if (manual) {
|
||||
point = new OpenLayers.Feature.Vector(point,{estado: "ok", id: id, type: "point_path_info",
|
||||
long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject())},
|
||||
{fillColor: "#ffffff", pointRadius: pointRadiusManual, stroke: 1, strokeColor: color, strokeWidth: strokeWidth, cursor: "pointer"}
|
||||
);
|
||||
}
|
||||
else {
|
||||
point = new OpenLayers.Feature.Vector(point,{estado: "ok", id: id, type: "point_path_info",
|
||||
long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject())},
|
||||
{fillColor: color, pointRadius: pointRadiusNormal, cursor: "pointer"}
|
||||
);
|
||||
}
|
||||
|
||||
layer.addFeatures(point);
|
||||
}
|
||||
|
||||
function js_addLineString(layerName, points, color) {
|
||||
var mapPoints = new Array(points.length);
|
||||
var layer = map.getLayersByName(layerName);
|
||||
|
||||
layer = layer[0];
|
||||
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
mapPoints[i] = points[i].transform(map.displayProjection, map.getProjectionObject());
|
||||
}
|
||||
|
||||
var lineString = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString(mapPoints),
|
||||
null,
|
||||
{ strokeWidth: 2, fillOpacity: 0.2, fillColor: color, strokeColor: color}
|
||||
);
|
||||
|
||||
layer.addFeatures(lineString);
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
function makeLayer($name, $visible = true, $dot = null) { static $i = 0;
|
||||
function makeLayer($name, $visible = true, $dot = null) {
|
||||
if ($dot == null) {
|
||||
$dot['url'] = 'images/dot_green.png';
|
||||
$dot['width'] = 20; //11;
|
||||
|
|
|
@ -0,0 +1,360 @@
|
|||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
var map; // Map global var object is use in multiple places.
|
||||
|
||||
/**
|
||||
* Inicialize the map in the browser and the object map.
|
||||
*
|
||||
* @param string id_div The id of div to draw the map.
|
||||
* @param integer initial_zoom The initial zoom to show the map.
|
||||
* @param integer num_levels_zoom The numbers of zoom levels.
|
||||
* @param float center_latitude The coord of latitude for center.
|
||||
* @param float center_longitude The coord of longitude for center.
|
||||
* @param array objBaseLayers The array of baselayers with number index, and the baselayer is another asociative array that content 'type', 'name' and 'url'.
|
||||
* @param array arrayControls The array of enabled controls, the controls is: 'Navigation', 'MousePosition', 'OverviewMap', 'PanZoom', 'PanZoomBar', 'ScaleLine', 'Scale'
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
function js_printMap(id_div, initial_zoom, num_levels_zoom, center_latitude, center_longitude, objBaseLayers, arrayControls) {
|
||||
$(document).ready (
|
||||
function () {
|
||||
|
||||
controlsList = [];
|
||||
|
||||
for (var controlIndex in arrayControls) {
|
||||
if (isInt(controlIndex)) {
|
||||
switch (arrayControls[controlIndex]) {
|
||||
case 'Navigation':
|
||||
controlsList.push(new OpenLayers.Control.Navigation());
|
||||
break;
|
||||
case 'MousePosition':
|
||||
controlsList.push(new OpenLayers.Control.MousePosition());
|
||||
break;
|
||||
case 'OverviewMap':
|
||||
controlsList.push(new OpenLayers.Control.OverviewMap());
|
||||
break;
|
||||
case 'PanZoom':
|
||||
controlsList.push(new OpenLayers.Control.PanZoom());
|
||||
break;
|
||||
case 'PanZoomBar':
|
||||
controlsList.push(new OpenLayers.Control.PanZoomBar());
|
||||
break;
|
||||
case 'ScaleLine':
|
||||
controlsList.push(new OpenLayers.Control.ScaleLine());
|
||||
break;
|
||||
case 'Scale':
|
||||
controlsList.push(new OpenLayers.Control.Scale());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map = new OpenLayers.Map (id_div, {
|
||||
controls: controlsList,
|
||||
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
|
||||
maxResolution: 156543.0399,
|
||||
numZoomLevels: num_levels_zoom,
|
||||
units: 'm', //metros
|
||||
projection: new OpenLayers.Projection("EPSG:900913"),
|
||||
displayProjection: new OpenLayers.Projection("EPSG:4326")
|
||||
});
|
||||
|
||||
//Define the maps layer
|
||||
for (var baselayerIndex in objBaseLayers) {
|
||||
if (isInt(baselayerIndex)) {
|
||||
switch (objBaseLayers[baselayerIndex]['type']) {
|
||||
case 'OSM':
|
||||
var baseLayer = new OpenLayers.Layer.OSM(objBaseLayers[baselayerIndex]['name'],
|
||||
objBaseLayers[baselayerIndex]['url'], {numZoomLevels: num_levels_zoom});
|
||||
map.addLayer(baseLayer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ! map.getCenter() ){
|
||||
var lonLat = new OpenLayers.LonLat(center_longitude, center_latitude)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
map.setCenter (lonLat, initial_zoom);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the layer in the map.
|
||||
*
|
||||
* @param string name The name of layer, it's show in the toolbar of layer.
|
||||
* @param boolean visible Set visible the layer.
|
||||
* @param array dot It's a asociative array that have 'url' of icon image, 'width' in pixeles and 'height' in pixeles.
|
||||
*
|
||||
* @return object The layer created.
|
||||
*/
|
||||
function js_makeLayer(name, visible, dot) {
|
||||
if (dot == null) {
|
||||
dot = Array();
|
||||
dot['url'] = 'images/dot_green.png';
|
||||
dot['width'] = 20; //11;
|
||||
dot['height'] = 20; //11;
|
||||
}
|
||||
|
||||
//Set the style in layer
|
||||
var style = new OpenLayers.StyleMap(
|
||||
{fontColor: "#ff0000",
|
||||
labelYOffset: - dot['height'],
|
||||
graphicHeight: dot['height'],
|
||||
graphicWidth: dot['width'],
|
||||
externalGraphic: dot['url'],
|
||||
label:"${nombre}"
|
||||
}
|
||||
);
|
||||
|
||||
//Make the layer as type vector
|
||||
var layer = new OpenLayers.Layer.Vector(name, {styleMap: style});
|
||||
|
||||
layer.setVisibility(visible);
|
||||
map.addLayer(layer);
|
||||
|
||||
//Disable for WIP
|
||||
/////
|
||||
// layer.events.on({
|
||||
// "beforefeaturemodified": test,
|
||||
// "featuremodified": test,
|
||||
// "afterfeaturemodified": test,
|
||||
// "vertexmodified": test,
|
||||
// "sketchmodified": test,
|
||||
// "sketchstarted": test,
|
||||
// "sketchcomplete": test
|
||||
// });
|
||||
/////
|
||||
|
||||
|
||||
// layer.events.on({
|
||||
// "featureselected": function(e) {
|
||||
// if (e.feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
|
||||
// var feature = e.feature;
|
||||
// var featureData = feature.data;
|
||||
// var long_lat = featureData.long_lat;
|
||||
//
|
||||
// var popup;
|
||||
//
|
||||
// popup = new OpenLayers.Popup.FramedCloud('cloud00',
|
||||
// long_lat,
|
||||
// null,
|
||||
// '<div class="cloudContent' + featureData.id + '" style="text-align: center;"><img src="images/spinner.gif" /></div>',
|
||||
// null,
|
||||
// true,
|
||||
// function () { popup.destroy(); });
|
||||
// feature.popup = popup;
|
||||
// map.addPopup(popup);
|
||||
//
|
||||
// jQuery.ajax ({
|
||||
// data: "page=operation/gis_maps/ajax&opt="+featureData.type+"&id=" + featureData.id,
|
||||
// type: "GET",
|
||||
// dataType: 'json',
|
||||
// url: "ajax.php",
|
||||
// timeout: 10000,
|
||||
// success: function (data) {
|
||||
// if (data.correct) {
|
||||
// $('.cloudContent' + featureData.id).css('text-align', 'left');
|
||||
// $('.cloudContent' + featureData.id).html(data.content);
|
||||
// popup.updateSize();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Active and set callbacks of events.
|
||||
*
|
||||
* @param callbackFunClick Function to call when the user make single click in the map.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
function js_activateEvents(callbackFunClick) {
|
||||
/**
|
||||
* Pandora click openlayers object.
|
||||
*/
|
||||
OpenLayers.Control.PandoraClick = OpenLayers.Class(OpenLayers.Control, {
|
||||
defaultHandlerOptions: {
|
||||
'single': true,
|
||||
'double': false,
|
||||
'pixelTolerance': 0,
|
||||
'stopSingle': false,
|
||||
'stopDouble': false
|
||||
},
|
||||
initialize: function(options) {
|
||||
this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
this.handler = new OpenLayers.Handler.Click(this, {'click': options.callbackFunctionClick}, this.handlerOptions);
|
||||
}
|
||||
});
|
||||
|
||||
var click = new OpenLayers.Control.PandoraClick({callbackFunctionClick: callbackFunClick});
|
||||
|
||||
map.addControl(click);
|
||||
click.activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the value is a int.
|
||||
*
|
||||
* @param mixed X The val that test to if is int.
|
||||
*
|
||||
* @return Boolean True if it's int.
|
||||
*/
|
||||
function isInt(x) {
|
||||
var y=parseInt(x);
|
||||
if (isNaN(y)) return false;
|
||||
return x==y && x.toString()==y.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visibility of a layer
|
||||
*
|
||||
* @param string name The name of layer.
|
||||
* @param boolean action True or false
|
||||
*/
|
||||
function showHideLayer(name, action) {
|
||||
var layer = map.getLayersByName(name);
|
||||
|
||||
layer[0].setVisibility(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a point with the default icon in the map.
|
||||
*
|
||||
* @param string layerName The name of layer to put the point.
|
||||
* @param string pointName The name to show in the point.
|
||||
* @param float lon The coord of latitude for point.
|
||||
* @param float lat The coord of longitude for point.
|
||||
* @param string id The id of point.
|
||||
* @param string type_string The type of point, it's use for ajax request.
|
||||
*
|
||||
* @return Object The point.
|
||||
*/
|
||||
function js_addPoint(layerName, pointName, lon, lat, id, type_string) {
|
||||
var point = new OpenLayers.Geometry.Point(lon, lat)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
var layer = map.getLayersByName(layerName);
|
||||
layer = layer[0];
|
||||
|
||||
feature = new OpenLayers.Feature.Vector(point,{nombre: pointName, id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) });
|
||||
|
||||
layer.addFeatures(feature);
|
||||
|
||||
return feature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a point and set the icon in the map.
|
||||
*
|
||||
* @param string layerName The name of layer to put the point.
|
||||
* @param string pointName The name to show in the point.
|
||||
* @param float lon The coord of latitude for point.
|
||||
* @param float lat The coord of longitude for point.
|
||||
* @param string icon Url of icon image.
|
||||
* @param integer width The width of icon.
|
||||
* @param integer height The height of icon.
|
||||
* @param string id The id of point.
|
||||
* @param string type_string The type of point, it's use for ajax request.
|
||||
*
|
||||
* @return Object The point.
|
||||
*/
|
||||
function js_addPointExtent(layerName, pointName, lon, lat, icon, width, height, id, type_string) {
|
||||
var point = new OpenLayers.Geometry.Point(lon, lat)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
var layer = map.getLayersByName(layerName);
|
||||
layer = layer[0];
|
||||
|
||||
feature = new OpenLayers.Feature.Vector(point,{id: id, type: type_string, long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject()) }, {fontWeight: "bolder", fontColor: "#00014F", labelYOffset: -height, graphicHeight: width, graphicWidth: height, externalGraphic: icon, label: pointName});
|
||||
|
||||
layer.addFeatures(feature);
|
||||
|
||||
return feature;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string layerName The name of layer to put the point path.
|
||||
* @param float lon The coord of latitude for point path.
|
||||
* @param float lat The coord of longitude for point path.
|
||||
* @param string color The color of point path in rrggbb format.
|
||||
* @param boolean manual The type of point path, if it's manual, the point is same a donut.
|
||||
* @param string id The id of point path.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
function js_addPointPath(layerName, lon, lat, color, manual, id) {
|
||||
var point = new OpenLayers.Geometry.Point(lon, lat)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
var layer = map.getLayersByName(layerName);
|
||||
layer = layer[0];
|
||||
|
||||
var pointRadiusNormal = 4;
|
||||
var strokeWidth = 2;
|
||||
var pointRadiusManual = pointRadiusNormal - (strokeWidth / 2);
|
||||
|
||||
if (manual) {
|
||||
point = new OpenLayers.Feature.Vector(point,{estado: "ok", id: id, type: "point_path_info",
|
||||
long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject())},
|
||||
{fillColor: "#ffffff", pointRadius: pointRadiusManual, stroke: 1, strokeColor: color, strokeWidth: strokeWidth, cursor: "pointer"}
|
||||
);
|
||||
}
|
||||
else {
|
||||
point = new OpenLayers.Feature.Vector(point,{estado: "ok", id: id, type: "point_path_info",
|
||||
long_lat: new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.getProjectionObject())},
|
||||
{fillColor: color, pointRadius: pointRadiusNormal, cursor: "pointer"}
|
||||
);
|
||||
}
|
||||
|
||||
layer.addFeatures(point);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the lineString.
|
||||
*
|
||||
* @param string layerName The name of layer to put the point path.
|
||||
* @param Array points The array have content the points, but the point as lonlat openlayers object without transformation.
|
||||
* @param string color The color of point path in rrggbb format.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
function js_addLineString(layerName, points, color) {
|
||||
var mapPoints = new Array(points.length);
|
||||
var layer = map.getLayersByName(layerName);
|
||||
|
||||
layer = layer[0];
|
||||
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
mapPoints[i] = points[i].transform(map.displayProjection, map.getProjectionObject());
|
||||
}
|
||||
|
||||
var lineString = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString(mapPoints),
|
||||
null,
|
||||
{ strokeWidth: 2, fillOpacity: 0.2, fillColor: color, strokeColor: color}
|
||||
);
|
||||
|
||||
layer.addFeatures(lineString);
|
||||
}
|
|
@ -27,6 +27,8 @@ if (! give_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_use
|
|||
require_once ('include/functions_gis.php');
|
||||
require_once ('include/functions_html.php');
|
||||
|
||||
require_javascript_file('openlayers.pandora');
|
||||
|
||||
/* Get the parameters */
|
||||
$period = get_parameter ("period", 86400);
|
||||
$agentId = get_parameter('id_agente');
|
||||
|
|
|
@ -21,6 +21,8 @@ check_login ();
|
|||
|
||||
require_once ('include/functions_gis.php');
|
||||
|
||||
require_javascript_file('openlayers.pandora');
|
||||
|
||||
echo "<h2>".__('GIS Maps')." » ".__('Summary')."</h2>";
|
||||
|
||||
$maps = getMaps();
|
||||
|
|
|
@ -20,6 +20,8 @@ check_login ();
|
|||
|
||||
require_once ('include/functions_gis.php');
|
||||
|
||||
require_javascript_file('openlayers.pandora');
|
||||
|
||||
$idMap = (int) get_parameter ('map_id');
|
||||
$show_history = get_parameter ('show_history', 'n');
|
||||
|
||||
|
|
Loading…
Reference in New Issue