Subversion Repositories Applications.papyrus

Rev

Rev 1605 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1605 Rev 1628
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.5 2007-09-18 08:38:54 alexandre_tb Exp $
22
// CVS : $Id: carto_google.php,v 1.6 2007-10-01 12:18:29 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.5 $ $Date: 2007-09-18 08:38:54 $
31
*@version       $Revision: 1.6 $ $Date: 2007-10-01 12:18:29 $
32
// +------------------------------------------------------------------------------------------------------+
32
// +------------------------------------------------------------------------------------------------------+
33
*/
33
*/
Line 34... Line 34...
34
 
34
 
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
Line 52... Line 52...
52
$GLOBALS['ins_config']['ic_google_key'] = 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.INS_GOOGLE_KEY;
52
$GLOBALS['ins_config']['ic_google_key'] = 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.INS_GOOGLE_KEY;
53
GEN_stockerFichierScript('googleMapScript', $GLOBALS['ins_config']['ic_google_key']);
53
GEN_stockerFichierScript('googleMapScript', $GLOBALS['ins_config']['ic_google_key']);
Line 54... Line -...
54
 
-
 
Line 55... Line 54...
55
 
54
 
56
 
-
 
Line 57... Line -...
57
// requete sur l annuaire pour recuperer des coordoonnees
-
 
58
 
-
 
59
$requete = 'select * from annuaire where a_est_structure=1';
-
 
60
$resultat = $GLOBALS['ins_db']->query ($requete);
-
 
61
 
-
 
62
if (DB::isError ($resultat)) {
-
 
63
	echo $resultat->getMessage().'<br />'.$resultat->getDebugInfo();
-
 
64
}
-
 
65
/*
-
 
66
if ($resultat->numRows() != 0) {
-
 
67
	$script_marker = '';
-
 
68
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
69
		$id_marker = $ligne['a_id'];
-
 
70
		$script_marker .= "\t".'point = new GLatLng('.$ligne['a_latitude'].','.$ligne['a_longitude'].');'."\n"
55
 
71
				."\t".'map.addOverlay(createMarker(point, \''.preg_replace ('/\n/', '', info ($ligne['a_id'], 'info')).'\'));'."\n";
-
 
72
				
-
 
73
	}
-
 
74
}*/
-
 
75
$donnees = array();
-
 
76
$script_marker = '';
-
 
77
if ($resultat->numRows() != 0) {
-
 
78
	$script_marker = '';
-
 
79
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
80
		if ($ligne['a_latitude'] == 0 && $ligne['a_longitude'] == 0) continue;
-
 
81
		$cle = $ligne['a_latitude'].'-'.$ligne['a_longitude'];
-
 
82
		$donnees[$cle][] = $ligne; 
-
 
83
	}
-
 
84
	foreach ($donnees as $valeur) {
-
 
85
		// cas un : une seule entree pour le point de coordonnees
-
 
86
		if (count ($valeur) == 1) {
-
 
87
			$chaine = $valeur[0];
-
 
88
			$script_marker .= "\t".'point = new GLatLng('.$chaine['a_latitude'].','.$chaine['a_longitude'].');'."\n"
-
 
89
				."\t".'map.addOverlay(createMarker(point, \''.
-
 
90
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
-
 
91
					str_replace ("'", "\'", info($chaine['a_id'], 'info')))).'\'));'."\n";
-
 
92
		} else { // Cas 2 plusieurs entrees
-
 
93
			$tableau_id = array();
-
 
94
			$script_marker .= "\t".'point = new GLatLng('.$val['a_latitude'].','.$val['a_longitude'].');'."\n"
-
 
95
				."\t".'map.addOverlay(createMarker(point, \'';
-
 
96
			foreach ($valeur as $val) {
-
 
97
				$script_marker .= preg_replace ('/\n/', '', str_replace ("\r\n", '', 
-
 
98
					str_replace ("'", "\'", info($val['a_id'], 'info'))));
-
 
99
			}
-
 
100
			$script_marker .= '\'));'."\n";
-
 
101
		}	
-
 
102
	}
-
 
103
} else {
-
 
104
	$script_marker = '';
-
 
105
}
-
 
106
 
-
 
107
$script = '
-
 
108
    // Variables globales
-
 
109
    var map = null;
-
 
110
	var lat = document.getElementById("latitude");
-
 
111
    var lon = document.getElementById("longitude");
-
 
112
    // Pour gerer la taille  
-
 
113
    var winW = 630, winH = 560;
-
 
114
    var deltaH = 220;
-
 
115
    var deltaW = 300;
-
 
116
        function setWinHW() {
56
 
117
	if (window.innerHeight) {
-
 
118
	    winW = window.innerWidth  - deltaW;
-
 
119
	    winH = window.innerHeight - deltaH;
-
 
120
        } else {
-
 
121
	    winW = document.documentElement.offsetWidth  - 20 - deltaW;
-
 
122
	    winH = document.documentElement.offsetHeight - 20 - deltaH ; 
-
 
123
        }
-
 
124
        
-
 
125
	var me = document.getElementById("map");
-
 
126
	if (me != null) {
-
 
127
	    me.style.width= \'\' + winW + \'px\';
-
 
128
	    me.style.height= \'\' + winH + \'px\';
-
 
129
        }
-
 
130
    }
-
 
131
 
-
 
132
    window.onresize = function () {
-
 
133
	setWinHW();
57
 
134
	if (map)  map.checkResize();
-
 
135
    }	
-
 
136
    
-
 
137
    function createMarker(point, chaine) {
-
 
138
	  	var icon = new GIcon();
-
 
139
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
-
 
140
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
-
 
141
		icon.iconSize = new GSize(20, 34);
-
 
142
		icon.shadowSize = new GSize(37, 34);
-
 
143
		icon.iconAnchor = new GPoint(6, 34);
-
 
144
		icon.infoWindowAnchor = new GPoint(5, 1);
-
 
145
 
-
 
146
	    var marker = new GMarker(point, icon);
-
 
147
	  	GEvent.addListener(marker, "click", function() {
-
 
148
	    	marker.openInfoWindowHtml(chaine);
-
 
149
	  	});
58
include_once INS_CHEMIN_APPLI.'squelettes/donnees_googlemap.php';
150
	  	return marker;
-
 
151
	}
-
 
152
    function load() {
-
 
153
    if (GBrowserIsCompatible()) {
-
 
154
      setWinHW();
-
 
155
      map = new GMap2(document.getElementById("map"));
-
 
156
      map.addControl(new GSmallMapControl());
-
 
157
	  map.addControl(new GMapTypeControl());
-
 
158
	  map.addControl(new GScaleControl());
-
 
159
	  map.enableContinuousZoom();
-
 
160
	
-
 
161
	  // On centre la carte
-
 
162
	  center = new GLatLng('.INS_GOOGLE_CENTRE_LAT.', '.INS_GOOGLE_CENTRE_LON.');
-
 
163
      map.setCenter(center, '.INS_GOOGLE_ALTITUDE.');
-
 
164
	   map.setMapType(G_HYBRID_MAP);
-
 
165
      ' .
-
 
166
      $script_marker.'
-
 
167
    }
59
 
Line 168... Line 60...
168
	};
60
ob_start();
169
	// Creates a marker at the given point with the given number label
61
include INS_CHEMIN_APPLI.'squelettes/script_googlemap.tpl.js';
170
	
62
$script = ob_get_contents();
Line 182... Line 74...
182
}
74
}
Line 183... Line 75...
183
 
75
 
184
/* +--Fin du code ----------------------------------------------------------------------------------------+
76
/* +--Fin du code ----------------------------------------------------------------------------------------+
185
*
77
*
-
 
78
* $Log: not supported by cvs2svn $
-
 
79
* Revision 1.5  2007-09-18 08:38:54  alexandre_tb
-
 
80
* ajout de la globale $GLOBALS['type_inscription'] pour indiquer quelle inscription on cartographie
186
* $Log: not supported by cvs2svn $
81
*
187
* Revision 1.4  2007-09-06 08:29:22  alexandre_tb
82
* Revision 1.4  2007-09-06 08:29:22  alexandre_tb
188
* utilisation de constantes pour centrer la carte
83
* utilisation de constantes pour centrer la carte
189
*
84
*
190
* Revision 1.3  2007-08-27 12:35:13  alexandre_tb
85
* Revision 1.3  2007-08-27 12:35:13  alexandre_tb