386 |
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 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// CVS : $Id: carte_google.php,v 1.1.2.1 2008-04-16 12:35:25 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-Botanica 2000-2008
|
|
|
30 |
*@version $Revision: 1.1.2.1 $
|
|
|
31 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
32 |
*/
|
|
|
33 |
|
|
|
34 |
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
class Bazar_carte_google extends PEAR {
|
|
|
38 |
|
|
|
39 |
var $option = array();
|
|
|
40 |
|
|
|
41 |
function Bazar_carte_google($options) {
|
|
|
42 |
$this->options = $options;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
function toHTML($valeur) {
|
|
|
46 |
if ($GLOBALS['pas_de_carte']) return;
|
|
|
47 |
$html = '';
|
|
|
48 |
$val = $this->options['nom_bdd'];
|
|
|
49 |
$script = '
|
|
|
50 |
// Variables globales
|
416 |
jpm |
51 |
// cette fonction peut déjà être présente
|
|
|
52 |
if (typeof(addListener) != \'function\') {
|
|
|
53 |
// fonction portable pour ajout de listeners
|
|
|
54 |
function addListener(element, baseName, handler)
|
|
|
55 |
{
|
|
|
56 |
if (element.addEventListener) {
|
|
|
57 |
element.addEventListener(baseName, handler, false) ;
|
|
|
58 |
} else if (element.attachEvent) {
|
|
|
59 |
element.attachEvent(\'on\'+baseName, handler) ;
|
|
|
60 |
}
|
|
|
61 |
}
|
|
|
62 |
}
|
386 |
alexandre_ |
63 |
var map = null;
|
416 |
jpm |
64 |
addListener(window,\'load\',loadMap) ;
|
386 |
alexandre_ |
65 |
var geocoder = null;
|
|
|
66 |
var lat = document.getElementById("latitude");
|
|
|
67 |
var lon = document.getElementById("longitude");
|
|
|
68 |
|
|
|
69 |
function load() {
|
|
|
70 |
if (GBrowserIsCompatible()) {
|
|
|
71 |
|
|
|
72 |
map = new GMap2(document.getElementById("map"), G_HYBRID_MAP);
|
|
|
73 |
|
|
|
74 |
map.addControl(new GSmallMapControl());
|
|
|
75 |
map.addControl(new GMapTypeControl());
|
|
|
76 |
map.addControl(new GScaleControl());
|
|
|
77 |
map.enableContinuousZoom();
|
|
|
78 |
|
|
|
79 |
// On centre la carte sur le marqueur
|
|
|
80 |
center = new GLatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
|
|
|
81 |
map.setCenter(center, 7);map.setMapType(G_HYBRID_MAP);
|
|
|
82 |
point = new GLatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
|
|
|
83 |
marker = new GMarker(point, {draggable: true});
|
|
|
84 |
map.addOverlay(marker);
|
|
|
85 |
}
|
|
|
86 |
};' ;
|
|
|
87 |
GEN_stockerCodeScript($script);
|
|
|
88 |
GEN_stockerFichierScript('googleMapScript', $this->options['nom_bdd']);
|
|
|
89 |
// On ajoute l attribut load a la balise body
|
416 |
jpm |
90 |
//GEN_AttributsBody('onload', 'load()');
|
386 |
alexandre_ |
91 |
$html = '<div id="map" style="width: 400px; height: 300px"></div>';
|
|
|
92 |
return $html;
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
97 |
*
|
|
|
98 |
* $Log: not supported by cvs2svn $
|
|
|
99 |
*
|
|
|
100 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
101 |
*/
|
|
|
102 |
?>
|