Subversion Repositories Applications.papyrus

Rev

Rev 1467 | Go to most recent revision | Details | Compare with Previous | 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
// +------------------------------------------------------------------------------------------------------+
1549 alexandre_ 22
// CVS : $Id: carto_google.php,v 1.3 2007-08-27 12:35:13 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
1549 alexandre_ 31
*@version       $Revision: 1.3 $ $Date: 2007-08-27 12:35:13 $
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';
41
// Inclusion d'une classe personnalise si elle existe
42
if (file_exists (INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php')) {
43
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php' ;
44
} else {
45
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.php';
46
}
47
 
1549 alexandre_ 48
$GLOBALS['ins_config']['ic_google_key'] = 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.INS_GOOGLE_KEY;
1427 alexandre_ 49
GEN_stockerFichierScript('googleMapScript', $GLOBALS['ins_config']['ic_google_key']);
50
 
51
 
52
 
53
// requete sur l annuaire pour recuperer des coordoonnees
54
 
55
$requete = 'select * from annuaire where a_est_structure=1';
56
$resultat = $GLOBALS['ins_db']->query ($requete);
57
 
1549 alexandre_ 58
if (DB::isError ($resultat)) {
59
	echo $resultat->getMessage().'<br />'.$resultat->getDebugInfo();
60
}
61
/*
1427 alexandre_ 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"
1467 alexandre_ 67
				."\t".'map.addOverlay(createMarker(point, \''.preg_replace ('/\n/', '', info ($ligne['a_id'], 'info')).'\'));'."\n";
1427 alexandre_ 68
 
69
	}
1549 alexandre_ 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", '',
94
					str_replace ("'", "\'", info($val['a_id'], 'info'))));
95
			}
96
			$script_marker .= '\'));'."\n";
97
		}
98
	}
99
} else {
100
	$script_marker = '';
1427 alexandre_ 101
}
102
 
103
$script = '
104
    // Variables globales
105
    var map = null;
106
	var lat = document.getElementById("latitude");
107
    var lon = document.getElementById("longitude");
1549 alexandre_ 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\';
124
	    me.style.height= \'\' + winH + \'px\';
125
        }
126
    }
127
 
128
    window.onresize = function () {
129
	setWinHW();
130
	if (map)  map.checkResize();
131
    }
1427 alexandre_ 132
 
133
    function createMarker(point, chaine) {
1549 alexandre_ 134
	  	var icon = new GIcon();
135
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
136
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
137
		icon.iconSize = new GSize(20, 34);
138
		icon.shadowSize = new GSize(37, 34);
139
		icon.iconAnchor = new GPoint(6, 34);
140
		icon.infoWindowAnchor = new GPoint(5, 1);
141
 
142
	    var marker = new GMarker(point, icon);
1427 alexandre_ 143
	  	GEvent.addListener(marker, "click", function() {
144
	    	marker.openInfoWindowHtml(chaine);
145
	  	});
146
	  	return marker;
147
	}
148
    function load() {
149
    if (GBrowserIsCompatible()) {
1549 alexandre_ 150
      setWinHW();
1427 alexandre_ 151
      map = new GMap2(document.getElementById("map"));
152
      map.addControl(new GSmallMapControl());
153
	  map.addControl(new GMapTypeControl());
154
	  map.addControl(new GScaleControl());
155
	  map.enableContinuousZoom();
156
 
157
	  // On centre la carte sur le languedoc roussillon
158
	  center = new GLatLng(43.84245116699036, 3.768310546875);
159
      map.setCenter(center, 7);
1549 alexandre_ 160
	   map.setMapType(G_HYBRID_MAP);
1427 alexandre_ 161
      ' .
162
      $script_marker.'
163
    }
164
	};
165
	// Creates a marker at the given point with the given number label
166
 
167
';
168
GEN_stockerCodeScript($script);
169
 
170
function afficherContenuCorps() {
1549 alexandre_ 171
	// Appel du template
172
	include_once INS_CHEMIN_APPLI.'bibliotheque/bottin.class.php';
173
	$template = inscription::getTemplate(INS_TEMPLATE_CARTO_GOOGLE_ACCUEIL, 1);
174
	$carte = '<div id="map" style="width: 600px; height: 450px"></div>';
175
	$res = str_replace ('{CARTE}', $carte, $template);
1427 alexandre_ 176
 
177
	return $res;
178
}
179
 
180
/* +--Fin du code ----------------------------------------------------------------------------------------+
181
*
182
* $Log: not supported by cvs2svn $
1549 alexandre_ 183
* Revision 1.2  2007-06-25 09:59:03  alexandre_tb
184
* ajout de carte_google, mise en place des templates avec api/formulaire, configuration de multiples inscriptions, ajout de modele pour les mails
185
*
1467 alexandre_ 186
* Revision 1.1  2007-06-01 13:39:14  alexandre_tb
187
* version initiale
188
*
1427 alexandre_ 189
* +-- Fin du code ----------------------------------------------------------------------------------------+
190
*/