469 |
mathias |
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 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// CVS : $Id: bazar.carte_google.php,v 1.9 2008-10-29 15:51:36 alexandre_tb Exp $
|
|
|
23 |
/**
|
|
|
24 |
*
|
|
|
25 |
*@package bazar
|
|
|
26 |
//Auteur original :
|
|
|
27 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
|
|
28 |
//Autres auteurs :
|
|
|
29 |
*@copyright Tela-Satanica 2000-2007
|
|
|
30 |
*@version $Revision: 1.9 $
|
|
|
31 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
32 |
*/
|
|
|
33 |
|
|
|
34 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
35 |
// | ENTETE du PROGRAMME |
|
|
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
include_once 'configuration/baz_config.inc.php';
|
|
|
40 |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
|
|
|
41 |
// Inclusion d'une classe personnalise si elle existe
|
|
|
42 |
|
|
|
43 |
// Le fichier de script de google map
|
479 |
mathias |
44 |
//GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&v=2&key='.BAZ_GOOGLE_KEY);
|
|
|
45 |
GEN_stockerFichierScript('googleMapScript', "http://maps.googleapis.com/maps/api/js?sensor=false&key=".BAZ_GOOGLE_KEY);
|
469 |
mathias |
46 |
|
|
|
47 |
// Le fichier jquery pour le date picker
|
|
|
48 |
//GEN_stockerFichierScript('jquery', 'api/js/jquery/jquery.js');
|
|
|
49 |
//GEN_stockerFichierScript('jquery', 'http://code.jquery.com/jquery-latest.js');
|
|
|
50 |
GEN_stockerFichierScript('jquery_date_picker', 'api/js/jquery/ui.datepicker.js');
|
|
|
51 |
GEN_stockerFichierScript('jquery_date_picker_fr', 'api/js/jquery/ui.datepicker-fr.js');
|
|
|
52 |
|
|
|
53 |
GEN_stockerStyleExterne( 'jquery_date_picker_style', 'api/js/jquery/ui.datepicker.css');
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
if (defined('PAP_VERSION')) { //si on est dans Papyrus
|
479 |
mathias |
57 |
GEN_stockerStyleExterne( 'bazar_interne', 'reseau/bazar/bazar.interne.css');
|
469 |
mathias |
58 |
}
|
|
|
59 |
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
|
|
|
60 |
$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
|
|
|
61 |
// requete sur le bazar pour recuperer les evenements
|
|
|
62 |
|
|
|
63 |
$requete_where = '';
|
|
|
64 |
foreach ($_POST as $cle => $valeur) {
|
|
|
65 |
if (preg_match ('/bazar_filtre_([0-9]+)/', $cle, $sousmotif)) {
|
|
|
66 |
$variable = $sousmotif[0] ;
|
|
|
67 |
if ($_POST[$variable] != '*') {
|
|
|
68 |
$requete_where = ' and bfvl_ce_liste="'.$sousmotif[1].'" and bfvl_valeur="'.$_POST[$variable].'" ';
|
|
|
69 |
} else {
|
|
|
70 |
$requete_where = ' and bfvl_ce_liste="'.$sousmotif[1].'" ';
|
|
|
71 |
}
|
|
|
72 |
} else {
|
|
|
73 |
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
if (isset($_POST['date_debut']) && $_POST['date_debut'] != '') {
|
|
|
78 |
|
|
|
79 |
$requete_date = '((bf_date_debut_evenement <= "'.date('Y-m-d', strtotime($_POST['date_fin'])).'" and bf_date_debut_evenement >="'.date('Y-m-d', strtotime($_POST['date_debut'])).'" )' .
|
|
|
80 |
' or (bf_date_fin_evenement >="'.date('Y-m-d', strtotime($_POST['date_debut'])).'" and bf_date_fin_evenement <="'.date('Y-m-d', strtotime($_POST['date_fin'])).'")' .
|
|
|
81 |
' or bf_date_debut_evenement <= "'.date('Y-m-d', strtotime($_POST['date_debut'])).'" and bf_date_fin_evenement >= "'.date('Y-m-d', strtotime($_POST['date_fin'])).'") ';
|
|
|
82 |
} else {
|
|
|
83 |
$requete_date = '((bf_date_debut_validite_fiche <= now( ) AND bf_date_fin_validite_fiche >= now( ))
|
|
|
84 |
OR (bf_date_fin_validite_fiche = "0000-00-00" AND date_add( bf_date_fin_evenement, INTERVAL 15 DAY ) > now( )) )';
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
$requete = 'SELECT blv_label,blv_valeur, bazar_fiche.*'.
|
|
|
88 |
' FROM bazar_fiche, bazar_fiche_valeur_liste , bazar_liste_valeurs'.
|
|
|
89 |
' WHERE bf_statut_fiche =1 and bf_id_fiche=bfvl_ce_fiche'.
|
|
|
90 |
' and bfvl_ce_liste=blv_ce_liste and bfvl_ce_liste=31 and bfvl_valeur=blv_valeur '.$requete_where.' and '.
|
|
|
91 |
$requete_date;
|
|
|
92 |
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
|
|
|
93 |
|
|
|
94 |
if (DB::isError($resultat)) {
|
|
|
95 |
return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete;
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
// Le code complique avec ces 2 tableaux sert
|
|
|
99 |
// a ne pas mettre 2 points aux memes coordonnees
|
|
|
100 |
// car dans ce cas la seul le second serait visible
|
|
|
101 |
|
|
|
102 |
$donnees = array();
|
|
|
103 |
|
|
|
104 |
if ($resultat->numRows() != 0) {
|
|
|
105 |
$script_marker = '';
|
|
|
106 |
$couleur_drapeau = array ( 1 => 'bleu', 2 => 'vert', 3 => 'orange', 4 => 'rose');
|
479 |
mathias |
107 |
|
469 |
mathias |
108 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
|
|
109 |
if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
|
|
|
110 |
$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
|
|
|
111 |
$donnees[$cle][] = $ligne;
|
|
|
112 |
}
|
479 |
mathias |
113 |
|
469 |
mathias |
114 |
foreach ($donnees as $valeur) {
|
|
|
115 |
// cas un : une seule entree pour le point de coordonnees
|
|
|
116 |
if (count ($valeur) == 1) {
|
|
|
117 |
$chaine = $valeur[0];
|
479 |
mathias |
118 |
|
|
|
119 |
$script_marker .= 'var icon = {' .
|
|
|
120 |
'url: "reseau/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png",
|
|
|
121 |
size: new google.maps.Size(16,16),
|
|
|
122 |
anchor: new google.maps.Point(6,16)'
|
|
|
123 |
. '};' . "\n";
|
|
|
124 |
|
|
|
125 |
$script_marker .= "\t".'point = new google.maps.LatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n"
|
|
|
126 |
."\t".'createMarker(point, \''.'<div class="BAZ_cadre_map">'.
|
469 |
mathias |
127 |
preg_replace ('/\n/', '', str_replace ("\r\n", '',
|
479 |
mathias |
128 |
str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\',icon, new google.maps.Size(5,1));'."\n";
|
|
|
129 |
|
469 |
mathias |
130 |
} else { // Cas 2 plusieurs entrees
|
|
|
131 |
$tableau_id = array();
|
|
|
132 |
foreach ($valeur as $val) {
|
|
|
133 |
array_push ($tableau_id, $val['bf_id_fiche']);
|
|
|
134 |
}
|
479 |
mathias |
135 |
|
|
|
136 |
$script_marker .= 'var icon = {' .
|
|
|
137 |
'url: "reseau/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png",
|
|
|
138 |
size: new google.maps.Size(16,16),
|
|
|
139 |
anchor: new google.maps.Point(6,3)'
|
|
|
140 |
. '};' . "\n";
|
|
|
141 |
|
|
|
142 |
$script_marker .= "\t".'point = new google.maps.LatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n"
|
|
|
143 |
."\t".'createMarker(point, \''.'<div class="BAZ_cadre_map">'.
|
469 |
mathias |
144 |
preg_replace ('/\n/', '', str_replace ("\r\n", '',
|
479 |
mathias |
145 |
str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\', icon, new google.maps.Size(5,1));'."\n";
|
|
|
146 |
}
|
469 |
mathias |
147 |
}
|
|
|
148 |
} else {
|
|
|
149 |
$script_marker = '';
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
$script = ' // Variables globales
|
|
|
153 |
var map = null;
|
479 |
mathias |
154 |
// cette fonction peut d�j� �tre pr�sente
|
469 |
mathias |
155 |
if (typeof(addListener) != \'function\') {
|
|
|
156 |
// fonction portable pour ajout de listeners
|
|
|
157 |
function addListener(element, baseName, handler)
|
|
|
158 |
{
|
|
|
159 |
if (element.addEventListener) {
|
|
|
160 |
element.addEventListener(baseName, handler, false) ;
|
|
|
161 |
} else if (element.attachEvent) {
|
|
|
162 |
element.attachEvent(\'on\'+baseName, handler) ;
|
|
|
163 |
}
|
|
|
164 |
}
|
|
|
165 |
}
|
|
|
166 |
addListener(window,\'load\',loadMap) ;';
|
479 |
mathias |
167 |
|
469 |
mathias |
168 |
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
|
|
|
169 |
// Pour gerer la taille
|
|
|
170 |
var winW = 630, winH = 560;
|
|
|
171 |
var deltaH = 220;
|
|
|
172 |
var deltaW = 270;
|
|
|
173 |
|
|
|
174 |
function setWinHW() {
|
|
|
175 |
if (window.innerHeight) {
|
479 |
mathias |
176 |
winW = window.innerWidth - deltaW;
|
|
|
177 |
winH = window.innerHeight - deltaH;
|
469 |
mathias |
178 |
} else {
|
479 |
mathias |
179 |
winW = document.documentElement.offsetWidth - 20 - deltaW;
|
|
|
180 |
winH = document.documentElement.offsetHeight - 20 - deltaH ;
|
469 |
mathias |
181 |
}
|
|
|
182 |
|
|
|
183 |
var me = document.getElementById("map");
|
|
|
184 |
if (me != null) {
|
|
|
185 |
me.style.width= \'\' + winW + \'px\';
|
|
|
186 |
me.style.height= \'\' + winH + \'px\';
|
|
|
187 |
}
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
window.onresize = function () {
|
|
|
191 |
setWinHW();
|
|
|
192 |
if (map) map.checkResize();
|
|
|
193 |
}';
|
|
|
194 |
$script .= '
|
|
|
195 |
|
479 |
mathias |
196 |
function createMarker(point, chaine, icon, offset) {
|
|
|
197 |
var marker = new google.maps.Marker({
|
|
|
198 |
position: point,
|
|
|
199 |
map: map,
|
|
|
200 |
icon: icon
|
|
|
201 |
});
|
|
|
202 |
google.maps.event.addListener(marker, "click", function() {
|
|
|
203 |
var infowindow = new google.maps.InfoWindow({
|
|
|
204 |
content: chaine,
|
|
|
205 |
pixelOffset: offset
|
|
|
206 |
});
|
|
|
207 |
infowindow.open(map, marker);
|
|
|
208 |
});
|
469 |
mathias |
209 |
|
|
|
210 |
return marker;
|
|
|
211 |
}
|
|
|
212 |
function loadMap() {';
|
|
|
213 |
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
|
|
|
214 |
setWinHW();';
|
|
|
215 |
$script .= '
|
479 |
mathias |
216 |
var optionsGoogleMapsv3 = {
|
|
|
217 |
// On centre la carte sur le languedoc roussillon
|
|
|
218 |
center: new google.maps.LatLng(' . BAZ_GOOGLE_CENTRE_LAT . ', ' . BAZ_GOOGLE_CENTRE_LON . '),
|
|
|
219 |
zoom: ' . BAZ_GOOGLE_ALTITUDE . ',
|
|
|
220 |
mapTypeId: "OSM",
|
|
|
221 |
mapTypeControlOptions: {
|
|
|
222 |
mapTypeIds: ["OSM",
|
|
|
223 |
google.maps.MapTypeId.ROADMAP,
|
|
|
224 |
google.maps.MapTypeId.HYBRID,
|
|
|
225 |
google.maps.MapTypeId.SATELLITE,
|
|
|
226 |
google.maps.MapTypeId.TERRAIN]
|
|
|
227 |
},
|
|
|
228 |
mapTypeControl: true,
|
|
|
229 |
scaleControl: true
|
|
|
230 |
};
|
469 |
mathias |
231 |
|
479 |
mathias |
232 |
map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
|
|
|
233 |
map.mapTypes.set("OSM", new google.maps.ImageMapType({
|
|
|
234 |
getTileUrl: function(coord, zoom) {
|
|
|
235 |
return "http://osm.tela-botanica.org/tile/" + // cache de tuiles avec nginx
|
|
|
236 |
zoom + "/" + coord.x + "/" + coord.y + ".png";
|
|
|
237 |
},
|
|
|
238 |
tileSize: new google.maps.Size(256, 256),
|
|
|
239 |
isPng: true,
|
|
|
240 |
alt: "OpenStreetMap",
|
|
|
241 |
name: "OSM",
|
|
|
242 |
maxZoom: 19
|
490 |
mathias |
243 |
}));
|
479 |
mathias |
244 |
|
490 |
mathias |
245 |
var mention = \'<div id="origine-donnees">Tuiles : <a href="http://www.openstreetmap.fr" target="_blank">OsmFr</a><br/>\';
|
|
|
246 |
mention += \'Carte : <a href="http://www.openstreetmap.org/copyright" target="_blank">© les contributeurs d\\\'OpenStreetMap</a></div>\';
|
|
|
247 |
$("#map").append(mention);
|
|
|
248 |
|
|
|
249 |
// ecouteur sur changement de fond
|
|
|
250 |
google.maps.event.addListener( map, \'maptypeid_changed\', function() {
|
|
|
251 |
if (map.getMapTypeId() == "OSM") {
|
|
|
252 |
$("#origine-donnees").show();
|
|
|
253 |
} else {
|
|
|
254 |
$("#origine-donnees").hide();
|
|
|
255 |
}
|
|
|
256 |
});';
|
|
|
257 |
|
479 |
mathias |
258 |
if (BAZ_GOOGLE_FOND_KML != '') {
|
|
|
259 |
$script .= 'geoXml = new google.maps.KmlLayer(' . BAZ_GOOGLE_FOND_KML . ');';
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
$script .= $script_marker;
|
|
|
263 |
if (BAZ_GOOGLE_FOND_KML != '') {
|
|
|
264 |
$script .= 'geoXml.setMap(map);';
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
$script .= '};';
|
|
|
268 |
|
469 |
mathias |
269 |
GEN_stockerCodeScript($script);
|
|
|
270 |
// On ajoute l attribut load a la balise body
|
|
|
271 |
//GEN_AttributsBody('onload', 'load()');
|
|
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
function afficherContenuCorps() {
|
|
|
276 |
|
|
|
277 |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
|
|
|
278 |
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
|
|
|
279 |
$html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
|
|
|
280 |
if (PEAR::isError($html)) return $html->getMessage();
|
|
|
281 |
|
|
|
282 |
// nettoyage url
|
|
|
283 |
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ID_FICHE) ;
|
|
|
284 |
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION) ;
|
|
|
285 |
$html = bazar::getFormulaireFiltre($html) ;
|
|
|
286 |
|
|
|
287 |
$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR.
|
|
|
288 |
'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html);
|
|
|
289 |
|
|
|
290 |
return $res;
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
|
|
|
294 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
295 |
*
|
|
|
296 |
* $Log: not supported by cvs2svn $
|
|
|
297 |
* Revision 1.5.2.3 2008-01-29 09:41:11 alexandre_tb
|
|
|
298 |
* utilisation des constantes BAZ_GOOGLE_FOND_KML
|
|
|
299 |
*
|
|
|
300 |
* Revision 1.5.2.2 2007-12-14 09:57:15 alexandre_tb
|
|
|
301 |
* utilisation des constantes de la carte google
|
|
|
302 |
*
|
|
|
303 |
* Revision 1.5.2.1 2007-12-04 16:19:32 jp_milcent
|
|
|
304 |
* Ajout de la prise en charge de l'applette body_attributs
|
|
|
305 |
*
|
|
|
306 |
* Revision 1.5 2007-10-01 12:07:03 alexandre_tb
|
|
|
307 |
* utilisation de constantes du fichier de conf pour centrer la carte
|
|
|
308 |
*
|
|
|
309 |
* Revision 1.4 2007-08-27 12:27:34 alexandre_tb
|
|
|
310 |
* mise en place d un icone personnalise
|
|
|
311 |
* et de l affichage de plusieurs donnees sur un meme point
|
|
|
312 |
*
|
|
|
313 |
* Revision 1.3 2007-07-04 10:08:41 alexandre_tb
|
|
|
314 |
* Appel du template carte_google
|
|
|
315 |
*
|
|
|
316 |
* Revision 1.2 2007-06-13 10:02:47 alexandre_tb
|
|
|
317 |
* le carte s adapte a la taille du conteneur
|
|
|
318 |
*
|
|
|
319 |
* Revision 1.1 2007-06-04 15:26:57 alexandre_tb
|
|
|
320 |
* version initiale
|
|
|
321 |
*
|
|
|
322 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
479 |
mathias |
323 |
*/
|