From 8ab93583b82ea575a2dd31135f7a73a63e09bce9 Mon Sep 17 00:00:00 2001
From: zarzuelo <zarzuelo@gmail.com>
Date: Wed, 12 May 2010 08:52:25 +0000
Subject: [PATCH] 2010-05-12  Sergio Martin <sergio.martin@artica.es>

	* include/functions_gis.php: Fixed the maps of
	type Googlemaps in agent view for bug: 2993745



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2704 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                 |  5 ++++
 pandora_console/include/functions_gis.php | 35 +++++++++++++++++++++--
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 695a1ad512..1db0e20a92 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-12  Sergio Martin <sergio.martin@artica.es>
+
+	* include/functions_gis.php: Fixed the maps of
+	type Googlemaps in agent view for bug: 2993745
+
 2010-05-11  Ramon Novoa  <rnovoa@artica.es>
 
 	* operation/agentes/stat_win.php: Pass the start date to min, max and
diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php
index 85d8f85e54..ed00624d74 100644
--- a/pandora_console/include/functions_gis.php
+++ b/pandora_console/include/functions_gis.php
@@ -817,12 +817,41 @@ function getAgentMap($agent_id, $heigth, $width, $show_history = false, $centerI
 	
 	$agent_name = get_agent_name($agent_id);
 	
-	$conectionData = json_decode($defaultMap['conection_data'], true);
-	$baselayers[0]['url'] = $conectionData['url'];
 	$baselayers[0]['name'] = $defaultMap['conection_name'];
-	$baselayers[0]['typeBaseLayer'] = $conectionData['type'];
 	$baselayers[0]['num_zoom_levels'] = $defaultMap['num_zoom_levels'];
+
+	$conectionData = json_decode($defaultMap['conection_data'], true);
+	$baselayers[0]['typeBaseLayer'] = $conectionData['type'];
 	$controls = array('PanZoomBar', 'ScaleLine', 'Navigation', 'MousePosition');
+	$gmap_layer = false;
+
+	switch ($conectionData['type']) {
+		case 'OSM':
+			$baselayers[0]['url'] = $conectionData['url'];
+			break;
+		case 'Gmap':
+			$baselayers[0]['gmap_type'] = $conectionData['gmap_type'];
+			$baselayers[0]['gmap_key'] = $conectionData['gmap_key'];
+			$gmap_key = $conectionData['gmap_key'];
+			// Onece a Gmap base layer is found we mark it to import the API
+			$gmap_layer = true;
+			break;
+		case 'Static_Image':
+			$baselayers[0]['url'] = $conectionData['url'];
+			$baselayers[0]['bb_left'] = $conectionData['bb_left'];
+			$baselayers[0]['bb_right'] = $conectionData['bb_right'];
+			$baselayers[0]['bb_bottom'] = $conectionData['bb_bottom'];
+			$baselayers[0]['bb_top'] = $conectionData['bb_top'];
+			$baselayers[0]['image_width'] = $conectionData['image_width'];
+			$baselayers[0]['image_height'] = $conectionData['image_height'];
+			break;
+	}
+	
+	if ($gmap_layer === true) {
+		?>
+			<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=<?php echo $gmap_key ?>" ></script>
+		<?php
+	}
 	
 	printMap($agent_name."_agent_map", $defaultMap['zoom_level'],
 		$defaultMap['initial_latitude'],