diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 12c3eabec5..d9626d3300 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2010-03-08 Miguel de Dios + + * include/functions_gis.php: cleaned source code of "printMap", now it is + more clean the code because it call the js_printMap only and it haven't the + num zoom levels. + + * include/javascript/openlayers.pandora.js: cleaned source code of + "js_printMap", now it is more clean the code and it haven't the num zoom + levels. + + * operation/gis_maps/render_view.php, godmode/setup/gis_step_2.php, + godmode/gis_maps/configure_gis_map.php: use new form of "printMap" and + "js_printMap". + 2010-03-08 Pablo de la Concepción New theme for the maps: New images and background color for the Openlayers diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index ac7f65fa1f..6b08e4c005 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -504,7 +504,7 @@ function refreshMapView() { objBaseLayers[0]['name'] = mapConnection['conection_name']; objBaseLayers[0]['url'] = baseLayer['url']; - js_printMap('map', inital_zoom, num_levels_zoom, center_latitude, center_longitude, objBaseLayers, arrayControls); + js_printMap('map', inital_zoom, center_latitude, center_longitude, objBaseLayers, arrayControls); } } }); diff --git a/pandora_console/godmode/setup/gis_step_2.php b/pandora_console/godmode/setup/gis_step_2.php index 56d3a0fdb6..ceba1fe3d2 100755 --- a/pandora_console/godmode/setup/gis_step_2.php +++ b/pandora_console/godmode/setup/gis_step_2.php @@ -434,7 +434,7 @@ function refreshMapViewSecondStep() { arrayControls = null; arrayControls = Array('Navigation', 'PanZoom', 'MousePosition'); - js_printMap('map', inital_zoom, num_levels_zoom, center_latitude, center_longitude, objBaseLayers, arrayControls); + js_printMap('map', inital_zoom, center_latitude, center_longitude, objBaseLayers, arrayControls); layer = js_makeLayer('temp_layer', true, null); diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index 39c48208eb..0a18b0b7d6 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -52,302 +52,77 @@ function getDataLastPositionAgent($idAgent, $returnEmptyArrayInFail = false) { return $returnVar; } -function printMap2($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $baselayers, $controls = null) { - ?> - - '; - printMap2($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $baselayers, $controls); - return; - ?> - - "; + echo "var controlsList = [];"; + foreach ($controls as $control) { + echo "controlsList.push('" . $control . "');"; + } + echo "var idDiv = '" . $idDiv . "';"; + echo "var initialZoom = " . $iniZoom . ";"; + echo "var centerLatitude = " . $latCenter . ";"; + echo "var centerLongitude = " . $lonCenter . ";"; + + echo "var baselayerList = [];"; + echo "var baselayer = null;"; + + foreach ($baselayers as $baselayer) { + echo "baselayer = { + bb_bottom: null, + bb_left: null, + bb_right: null, + bb_top: null, + gmap_type: null, + image_height: null, + image_width: null, + num_zoom_levels: null, + name: null, + type: null, + url: null + };"; + + echo "baselayer['type'] = '" . $baselayer['typeBaseLayer'] . "';"; + echo "baselayer['name'] = '" . $baselayer['name'] . "';"; + echo "baselayer['num_zoom_levels'] = '" . $baselayer['num_zoom_levels'] . "';"; + + switch ($baselayer['typeBaseLayer']) { + case 'OSM': + echo "baselayer['url'] = '" . $baselayer['url'] . "';"; + break; + case 'Static_Image': + echo "baselayer['bb_left'] = '" . $baselayer['bb_left'] . "';"; + echo "baselayer['bb_bottom'] = '" . $baselayer['bb_bottom'] . "';"; + echo "baselayer['bb_right'] = '" . $baselayer['bb_right'] . "';"; + echo "baselayer['bb_top'] = '" . $baselayer['bb_top'] . "';"; + echo "baselayer['image_width'] = '" . $baselayer['image_width'] . "';"; + echo "baselayer['image_height'] = '" . $baselayer['image_height'] . "';"; + echo "baselayer['url'] = '" . $baselayer['url'] . "';"; + break; + case 'Gmap': + echo "baselayer['gmap_type'] = '" . $baselayer['gmap_type'] . "';"; + break; + } + + echo "baselayerList.push(baselayer);"; + } + + echo "js_printMap(idDiv, initialZoom, centerLatitude, centerLongitude, + baselayerList, controlsList)"; + echo ""; } function makeLayer($name, $visible = true, $dot = null, $idLayer = null) { @@ -1054,7 +829,7 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerI $controls = array('PanZoomBar', 'ScaleLine', 'Navigation', 'MousePosition'); printMap($agent_name."_agent_map", $defaultMap['zoom_level'], - $defaultMap['num_zoom_levels'], $defaultMap['initial_latitude'], + $defaultMap['initial_latitude'], $defaultMap['initial_longitude'], $baselayers, $controls); makeLayer("layer_for_agent_".$agent_name); diff --git a/pandora_console/include/javascript/openlayers.pandora.js b/pandora_console/include/javascript/openlayers.pandora.js index f6eee1e7c7..4d4aef4f7c 100755 --- a/pandora_console/include/javascript/openlayers.pandora.js +++ b/pandora_console/include/javascript/openlayers.pandora.js @@ -77,7 +77,6 @@ function js_refreshParentLines(layerName) { * * @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'. @@ -85,119 +84,138 @@ function js_refreshParentLines(layerName) { * * @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 - //Disabled projection because with Image map not run fine...I don't know -// 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; - case 'Gmap': - tipito = objBaseLayers[baselayerIndex]['gmap_type']; - switch (tipito) { - case 'G_PHYSICAL_MAP': - //var baseLayer = new OpenLayers.Layer.Google(); - var gphy = new OpenLayers.Layer.Google( - "Google Physical", - {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, 'sphericalMercator': true, numZoomLevels: 20} - ); - map.addLayer(ghyb); - break; - case 'G_SATELLITE_MAP': - var gsat = new OpenLayers.Layer.Google( - "Google Satellite", - {type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 22} - ); - map.addLayer(gsat); - break; - default: - var gmap = new OpenLayers.Layer.Google( - "Google Streets", // the default - {'sphericalMercator': true, numZoomLevels: 20} - ); - map.addLayer(gmap); - break; - } - break; - case 'Static_Image': - - var baseLayer = new OpenLayers.Layer.Image( - objBaseLayers[baselayerIndex]['name'], - objBaseLayers[baselayerIndex]['url'], - new OpenLayers.Bounds(objBaseLayers[baselayerIndex]['bb_left'], - objBaseLayers[baselayerIndex]['bb_bottom'], - objBaseLayers[baselayerIndex]['bb_right'], - objBaseLayers[baselayerIndex]['bb_top']), - new OpenLayers.Size(objBaseLayers[baselayerIndex]['image_width'], objBaseLayers[baselayerIndex]['image_height']), - {'sphericalMercator': true, numZoomLevels: num_levels_zoom}); - map.addLayer(baseLayer); - break; - default: - alert('connection type invalid'); - } - } - } - - if( ! map.getCenter() ){ - var lonLat = new OpenLayers.LonLat(center_longitude, center_latitude) - .transform(map.displayProjection, map.getProjectionObject()); - map.setCenter (lonLat, initial_zoom); +function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, objBaseLayers, arrayControls) { + 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; + case 'layerSwitcher': + controlsList.push(new OpenLayers.Control.LayerSwitcher()); + break; } } - ); + } + + + var option = { + controls: controlsList, + 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(id_div, option); + + var baseLayer = null; + + //Define the maps layer + for (var baselayerIndex in objBaseLayers) { + if (isInt(baselayerIndex)) { + switch (objBaseLayers[baselayerIndex]['type']) { + case 'OSM': + baseLayer = null; + baseLayer = new OpenLayers.Layer.OSM( + objBaseLayers[baselayerIndex]['name'], + objBaseLayers[baselayerIndex]['url'], + {numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels'], + 'sphericalMercator': true + } + ); + map.addLayer(baseLayer); + break; + case 'Gmap': + switch (objBaseLayers[baselayerIndex]['gmap_type']) { + case 'G_PHYSICAL_MAP': + baseLayer = new OpenLayers.Layer.Google( + objBaseLayers[baselayerIndex]['name'], + {type: G_PHYSICAL_MAP, + numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels'], + 'sphericalMercator': true + } + ); + map.addLayer(baseLayer); + break; + case 'G_HYBRID_MAP': + baseLayer = new OpenLayers.Layer.Google( + objBaseLayers[baselayerIndex]['name'], + {type: G_HYBRID_MAP, + numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels'], + 'sphericalMercator': true + } + ); + map.addLayer(baseLayer); + break; + case 'G_SATELLITE_MAP': + baseLayer = new OpenLayers.Layer.Google( + objBaseLayers[baselayerIndex]['name'], + {type: G_SATELLITE_MAP, + numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels'], + 'sphericalMercator': true + } + ); + map.addLayer(baseLayer); + break; + default: + baseLayer = new OpenLayers.Layer.Google( + objBaseLayers[baselayerIndex]['name'], + {numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels'], + 'sphericalMercator': true + } + ); + map.addLayer(baseLayer); + break; + } + break; + case 'Static_Image': + baseLayer = null; + baseLayer = new OpenLayers.Layer.Image( + objBaseLayers[baselayerIndex]['name'], + objBaseLayers[baselayerIndex]['url'], + new OpenLayers.Bounds(objBaseLayers[baselayerIndex]['bb_left'], + objBaseLayers[baselayerIndex]['bb_bottom'], + objBaseLayers[baselayerIndex]['bb_right'], + objBaseLayers[baselayerIndex]['bb_top'] + ), + new OpenLayers.Size(objBaseLayers[baselayerIndex]['image_width'], objBaseLayers[baselayerIndex]['image_height']), + {projection: new OpenLayers.Projection("EPSG:4326"), + numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels'] + } + ); + map.addLayer(baseLayer); + break; + } + } + } + console.log(map); + var lonLat = new OpenLayers.LonLat(center_longitude, center_latitude) + .transform(map.displayProjection, map.getProjectionObject()); + + map.setCenter (lonLat, initial_zoom); } /** diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index a7f215f86c..97348920de 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -129,9 +129,9 @@ else { echo "
"; } -printMap('map', $map['zoom_level'], $numZoomLevels, $map['initial_latitude'], +printMap('map', $map['zoom_level'], $map['initial_latitude'], $map['initial_longitude'], $baselayers, $controls); - + if ($layers != false) { foreach ($layers as $layer) { makeLayer($layer['layer_name'], $layer['view_layer'], null, $layer['id_tmap_layer']);