Subversion Repositories Applications.papyrus

Rev

Rev 1467 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1467 Rev 1549
Line 17... Line 17...
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: carto_google.php,v 1.2 2007-06-25 09:59:03 alexandre_tb Exp $
22
// CVS : $Id: carto_google.php,v 1.3 2007-08-27 12:35:13 alexandre_tb Exp $
23
/**
23
/**
24
* Cartographie google du bottin
24
* Cartographie google du bottin
25
*
25
*
26
*@package bottin
26
*@package bottin
27
//Auteur original :
27
//Auteur original :
28
*@author        Alexandre Granier <alexandre@tela-botanica.org>
28
*@author        Alexandre Granier <alexandre@tela-botanica.org>
29
//Autres auteurs :
29
//Autres auteurs :
30
*@copyright     Tela-Botanica 2000-2007
30
*@copyright     Tela-Botanica 2000-2007
31
*@version       $Revision: 1.2 $ $Date: 2007-06-25 09:59:03 $
31
*@version       $Revision: 1.3 $ $Date: 2007-08-27 12:35:13 $
32
// +------------------------------------------------------------------------------------------------------+
32
// +------------------------------------------------------------------------------------------------------+
33
*/
33
*/
Line 34... Line 34...
34
 
34
 
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
Line 43... Line 43...
43
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php' ;	
43
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php' ;	
44
} else {
44
} else {
45
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.php';
45
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.php';
46
}
46
}
Line 47... Line 47...
47
 
47
 
48
$GLOBALS['ins_config']['ic_google_key'] = 'http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAh5MiVKCtb2JEli5I8GRSIhRbQSKaqiLzq_1FqOv3C6TjQ0qw7BS-0YnGUkxsLmj6a2a1z7YsKC-pYg';
48
$GLOBALS['ins_config']['ic_google_key'] = 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.INS_GOOGLE_KEY;
Line 49... Line 49...
49
GEN_stockerFichierScript('googleMapScript', $GLOBALS['ins_config']['ic_google_key']);
49
GEN_stockerFichierScript('googleMapScript', $GLOBALS['ins_config']['ic_google_key']);
Line 50... Line 50...
50
 
50
 
51
 
51
 
Line -... Line 52...
-
 
52
 
-
 
53
// requete sur l annuaire pour recuperer des coordoonnees
-
 
54
 
-
 
55
$requete = 'select * from annuaire where a_est_structure=1';
52
 
56
$resultat = $GLOBALS['ins_db']->query ($requete);
53
// requete sur l annuaire pour recuperer des coordoonnees
57
 
54
 
58
if (DB::isError ($resultat)) {
55
$requete = 'select * from annuaire where a_est_structure=1';
59
	echo $resultat->getMessage().'<br />'.$resultat->getDebugInfo();
56
$resultat = $GLOBALS['ins_db']->query ($requete);
60
}
57
 
61
/*
Line 58... Line 62...
58
if ($resultat->numRows() != 0) {
62
if ($resultat->numRows() != 0) {
-
 
63
	$script_marker = '';
-
 
64
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
65
		$id_marker = $ligne['a_id'];
-
 
66
		$script_marker .= "\t".'point = new GLatLng('.$ligne['a_latitude'].','.$ligne['a_longitude'].');'."\n"
-
 
67
				."\t".'map.addOverlay(createMarker(point, \''.preg_replace ('/\n/', '', info ($ligne['a_id'], 'info')).'\'));'."\n";
-
 
68
				
-
 
69
	}
-
 
70
}*/
-
 
71
$donnees = array();
-
 
72
$script_marker = '';
-
 
73
if ($resultat->numRows() != 0) {
-
 
74
	$script_marker = '';
-
 
75
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
76
		if ($ligne['a_latitude'] == 0 && $ligne['a_longitude'] == 0) continue;
-
 
77
		$cle = $ligne['a_latitude'].'-'.$ligne['a_longitude'];
-
 
78
		$donnees[$cle][] = $ligne; 
-
 
79
	}
-
 
80
	foreach ($donnees as $valeur) {
-
 
81
		// cas un : une seule entree pour le point de coordonnees
-
 
82
		if (count ($valeur) == 1) {
-
 
83
			$chaine = $valeur[0];
-
 
84
			$script_marker .= "\t".'point = new GLatLng('.$chaine['a_latitude'].','.$chaine['a_longitude'].');'."\n"
-
 
85
				."\t".'map.addOverlay(createMarker(point, \''.
-
 
86
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
-
 
87
					str_replace ("'", "\'", info($chaine['a_id'], 'info')))).'\'));'."\n";
-
 
88
		} else { // Cas 2 plusieurs entrees
-
 
89
			$tableau_id = array();
-
 
90
			$script_marker .= "\t".'point = new GLatLng('.$val['a_latitude'].','.$val['a_longitude'].');'."\n"
-
 
91
				."\t".'map.addOverlay(createMarker(point, \'';
-
 
92
			foreach ($valeur as $val) {
-
 
93
				$script_marker .= preg_replace ('/\n/', '', str_replace ("\r\n", '', 
59
	$script_marker = '';
94
					str_replace ("'", "\'", info($val['a_id'], 'info'))));
Line 60... Line 95...
60
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
95
			}
61
		$id_marker = $ligne['a_id'];
96
			$script_marker .= '\'));'."\n";
62
		$script_marker .= "\t".'point = new GLatLng('.$ligne['a_latitude'].','.$ligne['a_longitude'].');'."\n"
97
		}	
63
				."\t".'map.addOverlay(createMarker(point, \''.preg_replace ('/\n/', '', info ($ligne['a_id'], 'info')).'\'));'."\n";
98
	}
64
				
99
} else {
-
 
100
	$script_marker = '';
-
 
101
}
-
 
102
 
-
 
103
$script = '
-
 
104
    // Variables globales
-
 
105
    var map = null;
-
 
106
	var lat = document.getElementById("latitude");
-
 
107
    var lon = document.getElementById("longitude");
-
 
108
    // Pour gerer la taille  
-
 
109
    var winW = 630, winH = 560;
-
 
110
    var deltaH = 220;
-
 
111
    var deltaW = 300;
-
 
112
        function setWinHW() {
-
 
113
	if (window.innerHeight) {
-
 
114
	    winW = window.innerWidth  - deltaW;
-
 
115
	    winH = window.innerHeight - deltaH;
-
 
116
        } else {
-
 
117
	    winW = document.documentElement.offsetWidth  - 20 - deltaW;
-
 
118
	    winH = document.documentElement.offsetHeight - 20 - deltaH ; 
-
 
119
        }
-
 
120
        
-
 
121
	var me = document.getElementById("map");
-
 
122
	if (me != null) {
-
 
123
	    me.style.width= \'\' + winW + \'px\';
Line 65... Line 124...
65
	}
124
	    me.style.height= \'\' + winH + \'px\';
-
 
125
        }
-
 
126
    }
-
 
127
 
-
 
128
    window.onresize = function () {
-
 
129
	setWinHW();
-
 
130
	if (map)  map.checkResize();
-
 
131
    }	
-
 
132
    
66
}
133
    function createMarker(point, chaine) {
67
 
134
	  	var icon = new GIcon();
68
$script = '
135
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
69
    // Variables globales
136
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
70
    var map = null;
137
		icon.iconSize = new GSize(20, 34);
71
	var lat = document.getElementById("latitude");
138
		icon.shadowSize = new GSize(37, 34);
72
    var lon = document.getElementById("longitude");
139
		icon.iconAnchor = new GPoint(6, 34);
73
    
140
		icon.infoWindowAnchor = new GPoint(5, 1);
-
 
141
 
74
    function createMarker(point, chaine) {
142
	    var marker = new GMarker(point, icon);
75
	  	var marker = new GMarker(point);
143
	  	GEvent.addListener(marker, "click", function() {
76
	  	GEvent.addListener(marker, "click", function() {
144
	    	marker.openInfoWindowHtml(chaine);
77
	    	marker.openInfoWindowHtml(chaine);
145
	  	});
78
	  	});
146
	  	return marker;
Line 79... Line 147...
79
	  	return marker;
147
	}
80
	}
148
    function load() {
81
    function load() {
149
    if (GBrowserIsCompatible()) {
82
    if (GBrowserIsCompatible()) {
-
 
-
 
150
      setWinHW();
83
      map = new GMap2(document.getElementById("map"));
151
      map = new GMap2(document.getElementById("map"));
84
      map.addControl(new GSmallMapControl());
152
      map.addControl(new GSmallMapControl());
85
	  map.addControl(new GMapTypeControl());
153
	  map.addControl(new GMapTypeControl());
86
	  map.addControl(new GScaleControl());
154
	  map.addControl(new GScaleControl());
87
	  map.enableContinuousZoom();
155
	  map.enableContinuousZoom();
Line 88... Line 156...
88
	
156
	
89
	  // On centre la carte sur le languedoc roussillon
157
	  // On centre la carte sur le languedoc roussillon
Line 90... Line 158...
90
	  center = new GLatLng(43.84245116699036, 3.768310546875);
158
	  center = new GLatLng(43.84245116699036, 3.768310546875);
-
 
159
      map.setCenter(center, 7);
-
 
160
	   map.setMapType(G_HYBRID_MAP);
-
 
161
      ' .
-
 
162
      $script_marker.'
-
 
163
    }
Line 91... Line -...
91
      map.setCenter(center, 7);
-
 
92
	  
164
	};
93
      ' .
165
	// Creates a marker at the given point with the given number label
Line 94... Line 166...
94
      $script_marker.'
166
	
95
    }
167
';
96
	};
168
GEN_stockerCodeScript($script);
-
 
169
 
-
 
170
function afficherContenuCorps() {
-
 
171
	// Appel du template
97
	// Creates a marker at the given point with the given number label
172
	include_once INS_CHEMIN_APPLI.'bibliotheque/bottin.class.php';
98
	
173
	$template = inscription::getTemplate(INS_TEMPLATE_CARTO_GOOGLE_ACCUEIL, 1);
99
';
174
	$carte = '<div id="map" style="width: 600px; height: 450px"></div>';
100
GEN_stockerCodeScript($script);
175
	$res = str_replace ('{CARTE}', $carte, $template);
101
 
176
	
102
function afficherContenuCorps() {
177
	return $res;