Subversion Repositories Applications.bazar

Rev

Rev 393 | Rev 479 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 393 Rev 468
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: carte_google.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
22
// CVS : $Id: carte_google.php,v 1.1.2.1 2008-04-16 12:35:25 alexandre_tb Exp $
23
/**
23
/**
24
* 
24
* 
25
*@package bazar
25
*@package bazar
26
//Auteur original :
26
//Auteur original :
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
28
//Autres auteurs :
28
//Autres auteurs :
29
*@copyright     Tela-Botanica 2000-2008
29
*@copyright     Tela-Botanica 2000-2008
30
*@version       $Revision: 1.2 $
30
*@version       $Revision: 1.1.2.1 $
31
// +------------------------------------------------------------------------------------------------------+
31
// +------------------------------------------------------------------------------------------------------+
32
*/
32
*/
Line 33... Line 33...
33
 
33
 
Line 37... Line 37...
37
class Bazar_carte_google extends PEAR {
37
class Bazar_carte_google extends PEAR {
Line 38... Line 38...
38
	
38
	
Line 39... Line 39...
39
	var $option = array();
39
	var $option = array();
-
 
40
	
40
	
41
	function Bazar_carte_google($options) {
41
	function Bazar_carte_google($options) {
42
		unset ($options['nom_bdd']); // fout la merde avec google maps v2
Line 42... Line 43...
42
		$this->options = $options;
43
		$this->options = $options;
43
	}
44
	}
44
	
45
	
45
	function toHTML($valeur) {
46
	function toHTML($valeur) {
46
		if ($GLOBALS['pas_de_carte']) return;
47
		if ($GLOBALS['pas_de_carte']) return;
47
		$html = '';
48
		$html = '';
-
 
49
		$val = $this->options['nom_bdd'];
-
 
50
    	$script = '
-
 
51
    // Variables globales
-
 
52
    // cette fonction peut déjà être présente
-
 
53
	if (typeof(addListener) != \'function\') {
-
 
54
		// fonction portable pour ajout de listeners
-
 
55
		function addListener(element, baseName, handler)
-
 
56
		{
-
 
57
			if (element.addEventListener) {
-
 
58
				element.addEventListener(baseName, handler, false) ;
-
 
59
			} else if (element.attachEvent) {
-
 
60
				element.attachEvent(\'on\'+baseName, handler) ;
48
		$val = $this->options['nom_bdd'];
61
			}
-
 
62
		}
49
    	$script = '
63
	}
50
    // Variables globales
64
    var map = null;
51
    var map = null;
65
    addListener(window,\'load\',loadMap) ;	
Line 52... Line 66...
52
	var geocoder = null;
66
	var geocoder = null;
-
 
67
	var lat = document.getElementById("latitude");
53
	var lat = document.getElementById("latitude");
68
    var lon = document.getElementById("longitude");
-
 
69
    
-
 
70
    function loadMap() {
-
 
71
	var point =  new google.maps.LatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
-
 
72
	var optionsGoogleMapsv3 = {
-
 
73
		// On centre la carte sur le languedoc roussillon
-
 
74
		center: point,
-
 
75
		zoom: 7,
-
 
76
		mapTypeId: google.maps.MapTypeId.G_HYBRID_MAP,
-
 
77
		mapTypeControl: true,
-
 
78
		scaleControl: true
-
 
79
	};
-
 
80
        map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
-
 
81
 
Line 54... Line -...
54
    var lon = document.getElementById("longitude");
-
 
55
    
-
 
56
    function load() {
-
 
57
    if (GBrowserIsCompatible()) {
-
 
58
	  
-
 
59
      map = new GMap2(document.getElementById("map"), G_HYBRID_MAP);
-
 
60
      
-
 
61
      map.addControl(new GSmallMapControl());
-
 
62
	  map.addControl(new GMapTypeControl());
-
 
63
	  map.addControl(new GScaleControl());
-
 
64
	  map.enableContinuousZoom();
-
 
65
	
-
 
66
	  // On centre la carte sur le marqueur
-
 
67
	  center = new GLatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
-
 
68
      map.setCenter(center, 7);map.setMapType(G_HYBRID_MAP);
82
	marker = new google.maps.Marker({
69
      point = new GLatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
83
	position: point,
70
	  marker = new GMarker(point, {draggable: true});
84
		map: map
-
 
85
	});
71
	  map.addOverlay(marker);
86
    
72
  }
87
};' ;
73
};' ;
88
    	GEN_stockerCodeScript($script);
74
    	GEN_stockerCodeScript($script);
89
    	//GEN_stockerFichierScript('googleMapScript', $this->options['nom_bdd']);
75
    	GEN_stockerFichierScript('googleMapScript', $this->options['nom_bdd']);
90
    	GEN_stockerFichierScript('googleMapScript', "http://maps.googleapis.com/maps/api/js?sensor=false&key=".BAZ_GOOGLE_KEY);
76
    	// On ajoute l attribut load a la balise body
91
    	// On ajoute l attribut load a la balise body
Line 77... Line 92...
77
		GEN_AttributsBody('onload', 'load()');
92
		//GEN_AttributsBody('onload', 'load()');
78
		$html = '<div id="map" style="width: 400px; height: 300px"></div>';
93
		$html = '<div id="map" style="width: 400px; height: 300px"></div>';
79
		return $html;
94
		return $html;
80
	}
-
 
81
}
-
 
82
 
-
 
83
/* +--Fin du code ----------------------------------------------------------------------------------------+
95
	}
84
*
96
}
85
* $Log: not supported by cvs2svn $
97
 
86
* Revision 1.1.2.1  2008-04-16 12:35:25  alexandre_tb
98
/* +--Fin du code ----------------------------------------------------------------------------------------+
87
* version initiale
99
*