Subversion Repositories Applications.bazar

Rev

Rev 274 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 274 Rev 283
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: bazar.carte_google.php,v 1.3 2007-07-04 10:08:41 alexandre_tb Exp $
22
// CVS : $Id: bazar.carte_google.php,v 1.4 2007-08-27 12:27:34 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-2007
29
*@copyright     Tela-Botanica 2000-2007
30
*@version       $Revision: 1.3 $
30
*@version       $Revision: 1.4 $
31
// +------------------------------------------------------------------------------------------------------+
31
// +------------------------------------------------------------------------------------------------------+
32
*/
32
*/
Line 33... Line 33...
33
 
33
 
34
// +------------------------------------------------------------------------------------------------------+
34
// +------------------------------------------------------------------------------------------------------+
Line 38... Line 38...
38
 
38
 
39
include_once 'configuration/baz_config.inc.php';
39
include_once 'configuration/baz_config.inc.php';
40
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
40
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
Line 41... Line 41...
41
// Inclusion d'une classe personnalise si elle existe
41
// Inclusion d'une classe personnalise si elle existe
Line -... Line 42...
-
 
42
 
-
 
43
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.BAZ_GOOGLE_KEY);
-
 
44
 
42
 
45
if (defined('PAP_VERSION')) { //si on est dans Papyrus
Line 43... Line 46...
43
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAh5MiVKCtb2JEli5I8GRSIhRbQSKaqiLzq_1FqOv3C6TjQ0qw7BS-0YnGUkxsLmj6a2a1z7YsKC-pYg');
46
	GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
Line 44... Line 47...
44
 
47
}
45
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
48
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
46
 
49
 
47
// requete sur le bazar pour recuperer les evenements
50
// requete sur le bazar pour recuperer les evenements
48
 
51
 
Line -... Line 52...
-
 
52
$requete = 'select * from bazar_fiche where ';
-
 
53
if ($GLOBALS['_BAZAR_']['id_typeannonce'] != '') $requete .= 'bf_ce_nature in ('.$GLOBALS['_BAZAR_']['id_typeannonce'].') and ' ;
-
 
54
$requete .= ' ((bf_date_debut_validite_fiche<=now() and bf_date_fin_validite_fiche>=now()) or bf_date_fin_validite_fiche="0000-00-00")'.
-
 
55
			' and bf_statut_fiche=1';
-
 
56
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
-
 
57
 
-
 
58
if (DB::isError($resultat)) {
-
 
59
	BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete;
-
 
60
}
-
 
61
 
49
$requete = 'select * from bazar_fiche where ';
62
// Le code complique avec ces 2 tableaux sert
50
if ($GLOBALS['_BAZAR_']['id_typeannonce'] != '') $requete .= 'bf_ce_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'] ;
63
// a ne pas mettre 2 points aux memes coordonnees
51
$requete .= ' and bf_date_debut_validite_fiche<=now() and '.
64
// car dans ce cas la seul le second serait visible
-
 
65
 
52
			'bf_date_fin_validite_fiche>=now() and bf_statut_fiche=1';
66
$donnees = array();
-
 
67
 
-
 
68
if ($resultat->numRows() != 0) {
-
 
69
	$script_marker = '';
-
 
70
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
71
		if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
-
 
72
		$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
53
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
73
		$donnees[$cle][] = $ligne; 
54
 
74
	}
-
 
75
	foreach ($donnees as $valeur) {
55
if ($resultat->numRows() != 0) {
76
		// cas un : une seule entree pour le point de coordonnees
-
 
77
		if (count ($valeur) == 1) {
-
 
78
			$chaine = $valeur[0];
-
 
79
			$script_marker .= "\t".'point = new GLatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n"
-
 
80
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
-
 
81
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
-
 
82
					str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\'));'."\n";
-
 
83
		} else { // Cas 2 plusieurs entrees
-
 
84
			$tableau_id = array();
-
 
85
			foreach ($valeur as $val) {
-
 
86
				array_push ($tableau_id, $val['bf_id_fiche']);
56
	$script_marker = '';
87
			}
57
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
88
			$script_marker .= "\t".'point = new GLatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n"
58
		$id_marker = $ligne['bf_id_fiche'];
89
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
59
		$script_marker .= "\t".'point = new GLatLng('.$ligne['bf_latitude'].','.$ligne['bf_longitude'].');'."\n"
90
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
Line 68... Line 99...
68
    // Variables globales
99
    // Variables globales
69
    var map = null;
100
    var map = null;
70
	var lat = document.getElementById("latitude");
101
	var lat = document.getElementById("latitude");
71
    var lon = document.getElementById("longitude");
102
    var lon = document.getElementById("longitude");
72
    // Pour gerer la taille  
103
    // Pour gerer la taille  
73
    var winW = 630, winH = 460;
104
    var winW = 630, winH = 560;
74
    var deltaH = 320;
105
    var deltaH = 220;
75
    var deltaW = 320;
106
    var deltaW = 270;
Line 76... Line 107...
76
    
107
    
77
    function setWinHW() {
108
    function setWinHW() {
78
	if (window.innerHeight) {
109
	if (window.innerHeight) {
79
	    winW = window.innerWidth  - deltaW;
110
	    winW = window.innerWidth  - deltaW;
Line 94... Line 125...
94
	setWinHW();
125
	setWinHW();
95
	if (map)  map.checkResize();
126
	if (map)  map.checkResize();
96
    }
127
    }
Line 97... Line 128...
97
    
128
    
-
 
129
    function createMarker(point, chaine) {
-
 
130
	  	var icon = new GIcon();
-
 
131
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
-
 
132
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
-
 
133
		icon.iconSize = new GSize(20, 34);
-
 
134
		icon.shadowSize = new GSize(37, 34);
-
 
135
		icon.iconAnchor = new GPoint(6, 34);
98
    function createMarker(point, chaine) {
136
		icon.infoWindowAnchor = new GPoint(5, 1);
99
	  	var marker = new GMarker(point);
137
	  	var marker = new GMarker(point, icon);
100
	  	GEvent.addListener(marker, "click", function() {
138
	  	GEvent.addListener(marker, "click", function() {
101
	    	marker.openInfoWindowHtml(chaine);
139
	    	marker.openInfoWindowHtml(chaine);
102
	  	});
140
	  	});
103
	  	return marker;
141
	  	return marker;
Line 112... Line 150...
112
	  map.enableContinuousZoom();
150
	  map.enableContinuousZoom();
Line 113... Line 151...
113
	
151
	
114
	  // On centre la carte sur le languedoc roussillon
152
	  // On centre la carte sur le languedoc roussillon
115
	  center = new GLatLng(43.84245116699036, 3.768310546875);
153
	  center = new GLatLng(43.84245116699036, 3.768310546875);
116
      map.setCenter(center, 7);
-
 
-
 
154
      map.setCenter(center, 7);
117
	  
155
	  map.setMapType(G_HYBRID_MAP);
118
      ' .
156
      ' .
119
      $script_marker.'
157
      $script_marker.'
120
    }
158
    }
121
	};
159
	};
Line 136... Line 174...
136
 
174
 
137
 
175
 
138
/* +--Fin du code ----------------------------------------------------------------------------------------+
176
/* +--Fin du code ----------------------------------------------------------------------------------------+
-
 
177
*
-
 
178
* $Log: not supported by cvs2svn $
-
 
179
* Revision 1.3  2007-07-04 10:08:41  alexandre_tb
139
*
180
* Appel du template carte_google
140
* $Log: not supported by cvs2svn $
181
*
141
* Revision 1.2  2007-06-13 10:02:47  alexandre_tb
182
* Revision 1.2  2007-06-13 10:02:47  alexandre_tb
142
* le carte s adapte a la taille du conteneur
183
* le carte s adapte a la taille du conteneur
143
*
184
*