diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3665391ec3..bd95b69f8c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2010-03-01 Pablo de la ConcepciĆ³n + + * include/javascript/openlayers.pandora.js: Modified js_printMap to support + Gmap type of maps. + + * include/functions_gis.php: Modified printMap to support Gmap type of maps + + * godmode/setup/gis_step_2.php: Modified to load on demand the Gmaps api + TODO: Use the key from the gmap_key input box. + 2010-03-01 Sancho Lerena * include/styles/menu.css, diff --git a/pandora_console/godmode/setup/gis_step_2.php b/pandora_console/godmode/setup/gis_step_2.php index 787f4c603e..7390850453 100755 --- a/pandora_console/godmode/setup/gis_step_2.php +++ b/pandora_console/godmode/setup/gis_step_2.php @@ -98,7 +98,6 @@ switch ($action) { 'url' => $mapConnection_OSM_url); break; case 'Gmap': - $mapConnection_Gmap_url= get_parameter('url'); $gmap_type= get_parameter('gmap_type'); $gmap_key= get_parameter('gmap_key'); $mapConnectionData = array('type' => 'Gmap', @@ -173,6 +172,7 @@ print_table ($table); $optionsConnectionTypeTable = ''; $mapConnectionDataUrl = ''; $gmap_type = ''; +$gmap_key= ''; $bb_left = ''; $bb_right = ''; $bb_bottom = ''; @@ -392,12 +392,14 @@ function refreshMapView() { center_altitude = $('input[name=center_altitude]').val(); var objBaseLayers = Array(); - objBaseLayers[0] = Array(); + objBaseLayers[0] = {}; objBaseLayers[0]['type'] = $('select[name=sel_type] :selected').val(); objBaseLayers[0]['name'] = $('input[name=name]').val(); objBaseLayers[0]['url'] = $('input[name=url]').val(); - - //objBaseLayers[0]['gmap_type = ''; + // type Gmap + objBaseLayers[0]['gmap_type'] = $('select[name=gmap_type] option:selected').val(); + objBaseLayers[0]['gmap_key'] = $('input[name=gmap_key]').val(); + // type Static Image objBaseLayers[0]['bb_left'] = $('input[name=bb_left]').val(); objBaseLayers[0]['bb_right'] = $('input[name=bb_right]').val(); objBaseLayers[0]['bb_bottom'] = $('input[name=bb_bottom]').val(); @@ -417,6 +419,15 @@ function refreshMapView() { js_activateEvents(changePoints); } +function validateGmapsParamtres () { + gmap_key = $('input[name=gmap_key]').val(); + if (gmap_key == "") { + $('input[name=gmap_key]').css('background-color:red;'); + } +} +function loadGoogleMap() { + google.load("maps", "2", {"callback" : validateGmapsParamtres}); +} /** * Dinamic write the fields in form when select a type of connection. @@ -428,15 +439,12 @@ function selMapConnectionType() { $('#form_map_connection_type').html('').hide(); break; case 'Gmap': - /* TODO: still testing this part... still need to use the provided key - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = 'http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'; - //script.src = 'http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'; - //document.body.appendChild(script); - //document.getElementsByTagName("head")[0].appendChild(script); - $('head').append(script); - */ + // TODO: Validate there is a key, and use it + var script = document.createElement("script"); + script.type = "text/javascript"; + //script.src = 'http://www.google.com/jsapi?key='+gmap_key+'&callback=loadGoogleMap'; + script.src = 'http://www.google.com/jsapi?key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg&callback=loadGoogleMap'; + document.getElementsByTagName("head")[0].appendChild(script); $('#form_map_connection_type').html('').hide(); break; case 'Static_Image': diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index e1ccfc2692..779249f3f8 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -94,6 +94,51 @@ function printMap($idDiv, $iniZoom, $numLevelZooms, $latCenter, $lonCenter, $bas map.addLayer(baseLayer); + //var baseLayer = new OpenLayers.Layer.Google(); + var gphy = new OpenLayers.Layer.Google( + "Google Physical", + {type: G_PHYSICAL_MAP} + ); + map.addLayer(gphy); + + alert("hibrid"); + var ghyb = new OpenLayers.Layer.Google( + "Google Hybrid", + {type: G_HYBRID_MAP, numZoomLevels: 20} + ); + map.addLayer(ghyb); + + alert("satelite"); + var gsat = new OpenLayers.Layer.Google( + "Google Satellite", + {type: G_SATELLITE_MAP, numZoomLevels: 22} + ); + map.addLayer(gsat); + + alert("default"); + var gmap = new OpenLayers.Layer.Google( + "Google Streets", // the default + {numZoomLevels: 20} + ); + map.addLayer(gmap); + var baseLayer = new OpenLayers.Layer.Image( diff --git a/pandora_console/include/javascript/openlayers.pandora.js b/pandora_console/include/javascript/openlayers.pandora.js index 60d2383150..63f29f5251 100755 --- a/pandora_console/include/javascript/openlayers.pandora.js +++ b/pandora_console/include/javascript/openlayers.pandora.js @@ -82,8 +82,40 @@ function js_printMap(id_div, initial_zoom, num_levels_zoom, center_latitude, cen 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, 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} + ); + map.addLayer(ghyb); + break; + case 'G_SATELLITE_MAP': + var gsat = new OpenLayers.Layer.Google( + "Google Satellite", + {type: G_SATELLITE_MAP, numZoomLevels: 22} + ); + map.addLayer(gsat); + break; + default: + var gmap = new OpenLayers.Layer.Google( + "Google Streets", // the default + {numZoomLevels: 20} + ); + map.addLayer(gmap); + break; + } + break; case 'Static_Image': - console.log(objBaseLayers); var baseLayer = new OpenLayers.Layer.Image( objBaseLayers[baselayerIndex]['name'], @@ -96,6 +128,8 @@ function js_printMap(id_div, initial_zoom, num_levels_zoom, center_latitude, cen {numZoomLevels: num_levels_zoom}); map.addLayer(baseLayer); break; + default: + alert('connection type invalid'); } } }