Subversion Repositories Applications.bazar

Rev

Rev 479 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
468 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: 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
		unset ($options['nom_bdd']); // fout la merde avec google maps v2
43
		$this->options = $options;
44
	}
45
 
46
	function toHTML($valeur) {
47
		if ($GLOBALS['pas_de_carte']) return;
48
		$html = '';
49
		$val = $this->options['nom_bdd'];
50
    	$script = '
51
    // Variables globales
479 mathias 52
    // cette fonction peut d�j� �tre pr�sente
468 mathias 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) ;
61
			}
62
		}
63
	}
64
    var map = null;
65
    addListener(window,\'load\',loadMap) ;
66
	var geocoder = null;
67
	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,
479 mathias 76
		mapTypeId: "OSM",
77
		mapTypeControlOptions: {
78
			mapTypeIds: ["OSM",
79
				google.maps.MapTypeId.ROADMAP,
80
				google.maps.MapTypeId.HYBRID,
81
				google.maps.MapTypeId.SATELLITE,
82
				google.maps.MapTypeId.TERRAIN]
83
		},
468 mathias 84
		mapTypeControl: true,
85
		scaleControl: true
86
	};
479 mathias 87
	map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
88
	map.mapTypes.set("OSM", new google.maps.ImageMapType({
89
		getTileUrl: function(coord, zoom) {
90
 			return "http://osm.tela-botanica.org/tile/" + // cache de tuiles avec nginx
91
 			zoom + "/" + coord.x + "/" + coord.y + ".png";
92
 		},
93
 		tileSize: new google.maps.Size(256, 256),
94
 		isPng: true,
95
 		alt: "OpenStreetMap",
96
 		name: "OSM",
97
		maxZoom: 19
98
	}));
468 mathias 99
 
100
	marker = new google.maps.Marker({
101
	position: point,
102
		map: map
103
	});
490 mathias 104
 
105
	var mention = \'<div id="origine-donnees">Tuiles : <a href="http://www.openstreetmap.fr" target="_blank">OsmFr</a><br/>\';
106
	mention += \'Carte : <a href="http://www.openstreetmap.org/copyright" target="_blank">© les contributeurs d\\\'OpenStreetMap</a></div>\';
107
	$("#map").append(mention);
108
 
109
	// ecouteur sur changement de fond
110
	google.maps.event.addListener( map, \'maptypeid_changed\', function() {
111
		if (map.getMapTypeId() == "OSM") {
112
			$("#origine-donnees").show();
113
		} else {
114
			$("#origine-donnees").hide();
115
		}
116
	});
468 mathias 117
};' ;
118
    	GEN_stockerCodeScript($script);
119
    	//GEN_stockerFichierScript('googleMapScript', $this->options['nom_bdd']);
120
    	GEN_stockerFichierScript('googleMapScript', "http://maps.googleapis.com/maps/api/js?sensor=false&key=".BAZ_GOOGLE_KEY);
121
    	// On ajoute l attribut load a la balise body
122
		//GEN_AttributsBody('onload', 'load()');
490 mathias 123
		$html = '<div id="map" style="width: 600px; height: 300px"></div>';
468 mathias 124
		return $html;
125
	}
126
}
127
 
128
/* +--Fin du code ----------------------------------------------------------------------------------------+
129
*
130
* $Log: not supported by cvs2svn $
131
*
132
* +-- Fin du code ----------------------------------------------------------------------------------------+
133
*/
134
?>