Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1427 alexandre_ 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
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                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
1572 alexandre_ 22
// CVS : $Id: carto_google.php,v 1.4 2007-09-06 08:29:22 alexandre_tb Exp $
1427 alexandre_ 23
/**
24
* Cartographie google du bottin
25
*
26
*@package bottin
27
//Auteur original :
28
*@author        Alexandre Granier <alexandre@tela-botanica.org>
29
//Autres auteurs :
30
*@copyright     Tela-Botanica 2000-2007
1572 alexandre_ 31
*@version       $Revision: 1.4 $ $Date: 2007-09-06 08:29:22 $
1427 alexandre_ 32
// +------------------------------------------------------------------------------------------------------+
33
*/
34
 
35
// +------------------------------------------------------------------------------------------------------+
36
// |                                            ENTETE du PROGRAMME                                       |
37
// +------------------------------------------------------------------------------------------------------+
38
 
39
include_once 'configuration/bottin.config.inc.php';
40
include_once INS_CHEMIN_APPLI.'bibliotheque/bottin.fonct.php';
1572 alexandre_ 41
include_once INS_CHEMIN_APPLI.'bibliotheque/bottin.class.php';
1427 alexandre_ 42
// Inclusion d'une classe personnalise si elle existe
43
if (file_exists (INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php')) {
44
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php' ;
45
} else {
46
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.php';
47
}
48
 
1572 alexandre_ 49
$GLOBALS ['ins_config'] = inscription::getConfig();
50
$GLOBALS ['ins_config']['ic_inscription_template'] = inscription::getTemplate(INS_TEMPLATE_FORMULAIRE,
51
    									$GLOBALS['ins_config']['ic_id_inscription']);
1549 alexandre_ 52
$GLOBALS['ins_config']['ic_google_key'] = 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.INS_GOOGLE_KEY;
1427 alexandre_ 53
GEN_stockerFichierScript('googleMapScript', $GLOBALS['ins_config']['ic_google_key']);
54
 
55
 
56
 
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
 
1549 alexandre_ 62
if (DB::isError ($resultat)) {
63
	echo $resultat->getMessage().'<br />'.$resultat->getDebugInfo();
64
}
65
/*
1427 alexandre_ 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"
1467 alexandre_ 71
				."\t".'map.addOverlay(createMarker(point, \''.preg_replace ('/\n/', '', info ($ligne['a_id'], 'info')).'\'));'."\n";
1427 alexandre_ 72
 
73
	}
1549 alexandre_ 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 = '';
1427 alexandre_ 105
}
106
 
107
$script = '
108
    // Variables globales
109
    var map = null;
110
	var lat = document.getElementById("latitude");
111
    var lon = document.getElementById("longitude");
1549 alexandre_ 112
    // Pour gerer la taille
113
    var winW = 630, winH = 560;
114
    var deltaH = 220;
115
    var deltaW = 300;
116
        function setWinHW() {
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();
134
	if (map)  map.checkResize();
135
    }
1427 alexandre_ 136
 
137
    function createMarker(point, chaine) {
1549 alexandre_ 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);
1427 alexandre_ 147
	  	GEvent.addListener(marker, "click", function() {
148
	    	marker.openInfoWindowHtml(chaine);
149
	  	});
150
	  	return marker;
151
	}
152
    function load() {
153
    if (GBrowserIsCompatible()) {
1549 alexandre_ 154
      setWinHW();
1427 alexandre_ 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
 
1572 alexandre_ 161
	  // On centre la carte
162
	  center = new GLatLng('.INS_GOOGLE_CENTRE_LAT.', '.INS_GOOGLE_CENTRE_LON.');
163
      map.setCenter(center, '.INS_GOOGLE_ALTITUDE.');
1549 alexandre_ 164
	   map.setMapType(G_HYBRID_MAP);
1427 alexandre_ 165
      ' .
166
      $script_marker.'
167
    }
168
	};
169
	// Creates a marker at the given point with the given number label
170
 
171
';
172
GEN_stockerCodeScript($script);
173
 
174
function afficherContenuCorps() {
1549 alexandre_ 175
	// Appel du template
176
	include_once INS_CHEMIN_APPLI.'bibliotheque/bottin.class.php';
177
	$template = inscription::getTemplate(INS_TEMPLATE_CARTO_GOOGLE_ACCUEIL, 1);
178
	$carte = '<div id="map" style="width: 600px; height: 450px"></div>';
179
	$res = str_replace ('{CARTE}', $carte, $template);
1427 alexandre_ 180
 
181
	return $res;
182
}
183
 
184
/* +--Fin du code ----------------------------------------------------------------------------------------+
185
*
186
* $Log: not supported by cvs2svn $
1572 alexandre_ 187
* Revision 1.3  2007-08-27 12:35:13  alexandre_tb
188
* mise en place d un icone personnalise
189
* et de l affichage de plusieurs donnees sur un meme point
190
*
1549 alexandre_ 191
* Revision 1.2  2007-06-25 09:59:03  alexandre_tb
192
* ajout de carte_google, mise en place des templates avec api/formulaire, configuration de multiples inscriptions, ajout de modele pour les mails
193
*
1467 alexandre_ 194
* Revision 1.1  2007-06-01 13:39:14  alexandre_tb
195
* version initiale
196
*
1427 alexandre_ 197
* +-- Fin du code ----------------------------------------------------------------------------------------+
198
*/