2010-03-03 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_gis.php: add in the last time a function "printMap2" that it is a clean function. Change the function "printMap" to call "printMap2". * include/javascript/openlayers.pandora.js: in function "js_printMap" set the spherical Mercator for google maps. * operation/gis_maps/render_view.php: add to list of $baselayers the name of baselayer. Change order of div for map because now the script don't call when document ready. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2458 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
28159d9fa0
commit
8a1fd27b22
|
@ -1,3 +1,16 @@
|
|||
2010-03-03 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_gis.php: add in the last time a function "printMap2"
|
||||
that it is a clean function. Change the function "printMap" to call
|
||||
"printMap2".
|
||||
|
||||
* include/javascript/openlayers.pandora.js: in function "js_printMap" set
|
||||
the spherical Mercator for google maps.
|
||||
|
||||
* operation/gis_maps/render_view.php: add to list of $baselayers the name
|
||||
of baselayer. Change order of div for map because now the script don't
|
||||
call when document ready.
|
||||
|
||||
2010-03-03 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* include/functions_db.php: Use mysql_fetch_assoc instead of
|
||||
|
|
|
@ -52,10 +52,165 @@ function getDataLastPositionAgent($idAgent, $returnEmptyArrayInFail = false) {
|
|||
return $returnVar;
|
||||
}
|
||||
|
||||
function printMap2($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $baselayers, $controls = null) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//$(document).ready (function () {
|
||||
|
||||
var controlVar = [
|
||||
<?php
|
||||
foreach ($controls as $control) {
|
||||
switch ($control) {
|
||||
case 'Navigation':
|
||||
echo "new OpenLayers.Control.Navigation(),";
|
||||
break;
|
||||
case 'MousePosition':
|
||||
echo "new OpenLayers.Control.MousePosition(),";
|
||||
break;
|
||||
case 'OverviewMap':
|
||||
echo "new OpenLayers.Control.OverviewMap(),";
|
||||
break;
|
||||
case 'PanZoom':
|
||||
echo "new OpenLayers.Control.PanZoom(),";
|
||||
break;
|
||||
case 'PanZoomBar':
|
||||
echo "new OpenLayers.Control.PanZoomBar(),";
|
||||
break;
|
||||
case 'ScaleLine':
|
||||
echo "new OpenLayers.Control.ScaleLine(),";
|
||||
break;
|
||||
case 'Scale':
|
||||
echo "new OpenLayers.Control.Scale(),";
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
new OpenLayers.Control.LayerSwitcher()];
|
||||
|
||||
|
||||
var option = {
|
||||
controls: controlVar,
|
||||
projection: new OpenLayers.Projection("EPSG:900913"),
|
||||
displayProjection: new OpenLayers.Projection("EPSG:4326"),
|
||||
units: "m",
|
||||
numZoomLevels: 18,
|
||||
maxResolution: 156543.0339,
|
||||
maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34)
|
||||
};
|
||||
|
||||
map = new OpenLayers.Map ("<?php echo $idDiv; ?>", option);
|
||||
|
||||
//BASELAYER
|
||||
var baseLayer = null;
|
||||
<?php
|
||||
foreach ($baselayers as $baselayer) {
|
||||
switch ($baselayer['typeBaseLayer']) {
|
||||
case 'OSM':
|
||||
?>
|
||||
baseLayer = null;
|
||||
baseLayer = new OpenLayers.Layer.OSM(
|
||||
"<?php echo $baselayer['name']; ?>",
|
||||
"<?php echo $baselayer['url']; ?>",
|
||||
{numZoomLevels: <?php echo $baselayer['num_zoom_levels']; ?>,
|
||||
'sphericalMercator': true
|
||||
}
|
||||
);
|
||||
map.addLayer(baseLayer);
|
||||
<?php
|
||||
break;
|
||||
case 'Gmap':
|
||||
?>
|
||||
baseLayer = null;
|
||||
<?php
|
||||
switch ($baselayer['gmap_type']) {
|
||||
case 'G_PHYSICAL_MAP':
|
||||
?>
|
||||
baseLayer = new OpenLayers.Layer.Google(
|
||||
"<?php echo $baselayer['name']; ?>",
|
||||
{type: G_PHYSICAL_MAP,
|
||||
numZoomLevels: <?php echo $baselayer['num_zoom_levels']; ?>,
|
||||
'sphericalMercator': true
|
||||
}
|
||||
);
|
||||
map.addLayer(baseLayer);
|
||||
<?php
|
||||
break;
|
||||
case 'G_HYBRID_MAP':
|
||||
?>
|
||||
baseLayer = new OpenLayers.Layer.Google(
|
||||
"<?php echo $baselayer['name']; ?>",
|
||||
{type: G_HYBRID_MAP,
|
||||
numZoomLevels: <?php echo $baselayer['num_zoom_levels']; ?>,
|
||||
'sphericalMercator': true
|
||||
}
|
||||
);
|
||||
map.addLayer(baseLayer);
|
||||
<?php
|
||||
break;
|
||||
case 'G_SATELLITE_MAP':
|
||||
?>
|
||||
baseLayer = new OpenLayers.Layer.Google(
|
||||
"<?php echo $baselayer['name']; ?>",
|
||||
{type: G_SATELLITE_MAP,
|
||||
numZoomLevels: <?php echo $baselayer['num_zoom_levels']; ?>,
|
||||
'sphericalMercator': true
|
||||
}
|
||||
);
|
||||
map.addLayer(baseLayer);
|
||||
<?php
|
||||
break;
|
||||
default:
|
||||
?>
|
||||
baseLayer = new OpenLayers.Layer.Google(
|
||||
"<?php echo $baselayer['name']; ?>",
|
||||
{numZoomLevels: <?php echo $baselayer['num_zoom_levels']; ?>,
|
||||
'sphericalMercator': true}
|
||||
);
|
||||
map.addLayer(baseLayer);
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'Static_Image':
|
||||
?>
|
||||
baseLayer = null;
|
||||
baseLayer = new OpenLayers.Layer.Image(
|
||||
"<?php echo $baselayer['name']; ?>",
|
||||
"<?php echo $baselayer['url']; ?>",
|
||||
new OpenLayers.Bounds(<?php echo $baselayer['bb_left']; ?>,
|
||||
<?php echo $baselayer['bb_bottom']; ?>,
|
||||
<?php echo $baselayer['bb_right']; ?>,
|
||||
<?php echo $baselayer['bb_top']; ?>
|
||||
),
|
||||
new OpenLayers.Size(<?php echo $baselayer['image_width']; ?>, <?php echo $baselayer['image_height']; ?>),
|
||||
{projection: new OpenLayers.Projection("EPSG:4326"),
|
||||
numZoomLevels: <?php echo $baselayer['num_zoom_levels']; ?>
|
||||
}
|
||||
);
|
||||
map.addLayer(baseLayer);
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
var lonLat = new OpenLayers.LonLat(<?php echo $lonCenter; ?>, <?php echo $latCenter; ?>)
|
||||
.transform(map.displayProjection, map.getProjectionObject());
|
||||
|
||||
map.setCenter (lonLat, <?php echo $iniZoom; ?>);
|
||||
//});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
function printMap($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $baselayers, $controls = null) {
|
||||
$controls = (array)$controls;
|
||||
|
||||
require_javascript_file('OpenLayers/OpenLayers');
|
||||
|
||||
printMap2($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $baselayers, $controls);
|
||||
return;
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready (
|
||||
|
|
|
@ -146,27 +146,27 @@ function js_printMap(id_div, initial_zoom, num_levels_zoom, center_latitude, cen
|
|||
//var baseLayer = new OpenLayers.Layer.Google();
|
||||
var gphy = new OpenLayers.Layer.Google(
|
||||
"Google Physical",
|
||||
{type: G_PHYSICAL_MAP, maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)});
|
||||
{type: G_PHYSICAL_MAP, 'sphericalMercator': true, maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)});
|
||||
map.addLayer(gphy);
|
||||
break;
|
||||
case 'G_HYBRID_MAP':
|
||||
var ghyb = new OpenLayers.Layer.Google(
|
||||
"Google Hybrid",
|
||||
{type: G_HYBRID_MAP, numZoomLevels: 20}
|
||||
{type: G_HYBRID_MAP, 'sphericalMercator': true, numZoomLevels: 20}
|
||||
);
|
||||
map.addLayer(ghyb);
|
||||
break;
|
||||
case 'G_SATELLITE_MAP':
|
||||
var gsat = new OpenLayers.Layer.Google(
|
||||
"Google Satellite",
|
||||
{type: G_SATELLITE_MAP, numZoomLevels: 22}
|
||||
{type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 22}
|
||||
);
|
||||
map.addLayer(gsat);
|
||||
break;
|
||||
default:
|
||||
var gmap = new OpenLayers.Layer.Google(
|
||||
"Google Streets", // the default
|
||||
{numZoomLevels: 20}
|
||||
{'sphericalMercator': true, numZoomLevels: 20}
|
||||
);
|
||||
map.addLayer(gmap);
|
||||
break;
|
||||
|
@ -182,7 +182,7 @@ function js_printMap(id_div, initial_zoom, num_levels_zoom, center_latitude, cen
|
|||
objBaseLayers[baselayerIndex]['bb_right'],
|
||||
objBaseLayers[baselayerIndex]['bb_top']),
|
||||
new OpenLayers.Size(objBaseLayers[baselayerIndex]['image_width'], objBaseLayers[baselayerIndex]['image_height']),
|
||||
{numZoomLevels: num_levels_zoom});
|
||||
{'sphericalMercator': true, numZoomLevels: num_levels_zoom});
|
||||
map.addLayer(baseLayer);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -35,6 +35,7 @@ if ($confMap !== false) {
|
|||
foreach ($confMap as $mapC) {
|
||||
$baselayers[$num_baselayer]['typeBaseLayer'] = $mapC['connection_type'];
|
||||
$baselayers[$num_baselayer]['name'] = $mapC['conection_name'];
|
||||
$baselayers[$num_baselayer]['num_zoom_levels'] = $mapC['num_zoom_levels'];
|
||||
$decodeJSON = json_decode($mapC['conection_data'], true);
|
||||
|
||||
switch ($mapC['connection_type']) {
|
||||
|
@ -121,6 +122,13 @@ $buttons[] = __('Show agents in state: ');
|
|||
|
||||
print_page_header(__('Map') . " » " . __('Map') . " " . $map['map_name'], "", false, "", false, $buttons);
|
||||
|
||||
if ($config["pure"] == 0) {
|
||||
echo "<div id='map' style='width: 99%; height: 500px; border: 1px solid black;' ></div>";
|
||||
}
|
||||
else {
|
||||
echo "<div id='map' style='position:absolute;top:40px; z-index:100; width: 98%; height:94%; border: 1px solid black;' ></div>";
|
||||
}
|
||||
|
||||
printMap('map', $map['zoom_level'], $numZoomLevels, $map['initial_latitude'],
|
||||
$map['initial_longitude'], $baselayers, $controls);
|
||||
|
||||
|
@ -163,11 +171,4 @@ if ($layers != false) {
|
|||
activateSelectControl();
|
||||
activateAjaxRefresh($layers, $timestampLastOperation);
|
||||
}
|
||||
|
||||
if ($config["pure"] == 0) {
|
||||
echo "<div id='map' style='width: 99%; height: 500px; border: 1px solid black;' ></div>";
|
||||
}
|
||||
else {
|
||||
echo "<div id='map' style='position:absolute;top:40px; z-index:100; width: 98%; height:94%; border: 1px solid black;' ></div>";
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue