19,7 → 19,7 |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: bazar.carte_google.php,v 1.2 2007-06-13 10:02:47 alexandre_tb Exp $ |
// CVS : $Id: bazar.carte_google.php,v 1.9 2008-10-29 15:51:36 alexandre_tb Exp $ |
/** |
* |
*@package bazar |
26,8 → 26,8 |
//Auteur original : |
*@author Alexandre GRANIER <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@copyright Tela-Botanica 2000-2007 |
*@version $Revision: 1.2 $ |
*@copyright Tela-Satanica 2000-2007 |
*@version $Revision: 1.9 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
40,39 → 40,136 |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php'; |
// Inclusion d'une classe personnalise si elle existe |
|
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAh5MiVKCtb2JEli5I8GRSIhRbQSKaqiLzq_1FqOv3C6TjQ0qw7BS-0YnGUkxsLmj6a2a1z7YsKC-pYg'); |
// Le fichier de script de google map |
//GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&v=2&key='.BAZ_GOOGLE_KEY); |
GEN_stockerFichierScript('googleMapScript', "http://maps.googleapis.com/maps/api/js?sensor=false&key=".BAZ_GOOGLE_KEY); |
|
// Le fichier jquery pour le date picker |
//GEN_stockerFichierScript('jquery', 'api/js/jquery/jquery.js'); |
//GEN_stockerFichierScript('jquery', 'http://code.jquery.com/jquery-latest.js'); |
GEN_stockerFichierScript('jquery_date_picker', 'api/js/jquery/ui.datepicker.js'); |
GEN_stockerFichierScript('jquery_date_picker_fr', 'api/js/jquery/ui.datepicker-fr.js'); |
|
GEN_stockerStyleExterne( 'jquery_date_picker_style', 'api/js/jquery/ui.datepicker.css'); |
|
|
if (defined('PAP_VERSION')) { //si on est dans Papyrus |
GEN_stockerStyleExterne( 'bazar_interne', 'reseau/bazar/bazar.interne.css'); |
} |
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature; |
|
$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature; |
// requete sur le bazar pour recuperer les evenements |
|
$requete = 'select * from bazar_fiche where '; |
if ($GLOBALS['_BAZAR_']['id_typeannonce'] != '') $requete .= 'bf_ce_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'] ; |
$requete .= ' and bf_date_debut_validite_fiche<=now() and '. |
'bf_date_fin_validite_fiche>=now() and bf_statut_fiche=1'; |
$requete_where = ''; |
foreach ($_POST as $cle => $valeur) { |
if (preg_match ('/bazar_filtre_([0-9]+)/', $cle, $sousmotif)) { |
$variable = $sousmotif[0] ; |
if ($_POST[$variable] != '*') { |
$requete_where = ' and bfvl_ce_liste="'.$sousmotif[1].'" and bfvl_valeur="'.$_POST[$variable].'" '; |
} else { |
$requete_where = ' and bfvl_ce_liste="'.$sousmotif[1].'" '; |
} |
} else { |
|
} |
} |
|
if (isset($_POST['date_debut']) && $_POST['date_debut'] != '') { |
|
$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'])).'" )' . |
' 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'])).'")' . |
' 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'])).'") '; |
} else { |
$requete_date = '((bf_date_debut_validite_fiche <= now( ) AND bf_date_fin_validite_fiche >= now( )) |
OR (bf_date_fin_validite_fiche = "0000-00-00" AND date_add( bf_date_fin_evenement, INTERVAL 15 DAY ) > now( )) )'; |
} |
|
$requete = 'SELECT blv_label,blv_valeur, bazar_fiche.*'. |
' FROM bazar_fiche, bazar_fiche_valeur_liste , bazar_liste_valeurs'. |
' WHERE bf_statut_fiche =1 and bf_id_fiche=bfvl_ce_fiche'. |
' and bfvl_ce_liste=blv_ce_liste and bfvl_ce_liste=31 and bfvl_valeur=blv_valeur '.$requete_where.' and '. |
$requete_date; |
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete); |
|
if (DB::isError($resultat)) { |
return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete; |
} |
|
// Le code complique avec ces 2 tableaux sert |
// a ne pas mettre 2 points aux memes coordonnees |
// car dans ce cas la seul le second serait visible |
|
$donnees = array(); |
|
if ($resultat->numRows() != 0) { |
$script_marker = ''; |
$couleur_drapeau = array ( 1 => 'bleu', 2 => 'vert', 3 => 'orange', 4 => 'rose'); |
|
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$id_marker = $ligne['bf_id_fiche']; |
$script_marker .= "\t".'point = new GLatLng('.$ligne['bf_latitude'].','.$ligne['bf_longitude'].');'."\n" |
."\t".'map.addOverlay(createMarker(point, \''. |
preg_replace ('/\n/', '', str_replace ("'", "\'", baz_voir_fiche(0, $ligne['bf_id_fiche']))).'\'));'."\n"; |
if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue; |
$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude']; |
$donnees[$cle][] = $ligne; |
} |
|
foreach ($donnees as $valeur) { |
// cas un : une seule entree pour le point de coordonnees |
if (count ($valeur) == 1) { |
$chaine = $valeur[0]; |
|
$script_marker .= 'var icon = {' . |
'url: "reseau/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png", |
size: new google.maps.Size(16,16), |
anchor: new google.maps.Point(6,16)' |
. '};' . "\n"; |
|
$script_marker .= "\t".'point = new google.maps.LatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n" |
."\t".'createMarker(point, \''.'<div class="BAZ_cadre_map">'. |
preg_replace ('/\n/', '', str_replace ("\r\n", '', |
str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\',icon, new google.maps.Size(5,1));'."\n"; |
|
} else { // Cas 2 plusieurs entrees |
$tableau_id = array(); |
foreach ($valeur as $val) { |
array_push ($tableau_id, $val['bf_id_fiche']); |
} |
|
$script_marker .= 'var icon = {' . |
'url: "reseau/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png", |
size: new google.maps.Size(16,16), |
anchor: new google.maps.Point(6,3)' |
. '};' . "\n"; |
|
$script_marker .= "\t".'point = new google.maps.LatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n" |
."\t".'createMarker(point, \''.'<div class="BAZ_cadre_map">'. |
preg_replace ('/\n/', '', str_replace ("\r\n", '', |
str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\', icon, new google.maps.Size(5,1));'."\n"; |
} |
} |
} else { |
$script_marker = ''; |
} |
|
$script = ' |
// Variables globales |
$script = ' // Variables globales |
var map = null; |
var lat = document.getElementById("latitude"); |
var lon = document.getElementById("longitude"); |
// cette fonction peut d�j� �tre pr�sente |
if (typeof(addListener) != \'function\') { |
// fonction portable pour ajout de listeners |
function addListener(element, baseName, handler) |
{ |
if (element.addEventListener) { |
element.addEventListener(baseName, handler, false) ; |
} else if (element.attachEvent) { |
element.attachEvent(\'on\'+baseName, handler) ; |
} |
} |
} |
addListener(window,\'load\',loadMap) ;'; |
|
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= ' |
// Pour gerer la taille |
var winW = 630, winH = 460; |
var deltaH = 320; |
var deltaW = 320; |
var winW = 630, winH = 560; |
var deltaH = 220; |
var deltaW = 270; |
|
function setWinHW() { |
if (window.innerHeight) { |
93,40 → 190,103 |
window.onresize = function () { |
setWinHW(); |
if (map) map.checkResize(); |
} |
}'; |
$script .= ' |
|
function createMarker(point, chaine) { |
var marker = new GMarker(point); |
GEvent.addListener(marker, "click", function() { |
marker.openInfoWindowHtml(chaine); |
function createMarker(point, chaine, icon, offset) { |
var marker = new google.maps.Marker({ |
position: point, |
map: map, |
icon: icon |
}); |
google.maps.event.addListener(marker, "click", function() { |
var infowindow = new google.maps.InfoWindow({ |
content: chaine, |
pixelOffset: offset |
}); |
infowindow.open(map, marker); |
}); |
|
return marker; |
} |
function load() { |
setWinHW(); |
if (GBrowserIsCompatible()) { |
map = new GMap2(document.getElementById("map")); |
map.addControl(new GSmallMapControl()); |
map.addControl(new GMapTypeControl()); |
map.addControl(new GScaleControl()); |
map.enableContinuousZoom(); |
|
function loadMap() {'; |
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= ' |
setWinHW();'; |
$script .= ' |
var optionsGoogleMapsv3 = { |
// On centre la carte sur le languedoc roussillon |
center = new GLatLng(43.84245116699036, 3.768310546875); |
map.setCenter(center, 7); |
center: new google.maps.LatLng(' . BAZ_GOOGLE_CENTRE_LAT . ', ' . BAZ_GOOGLE_CENTRE_LON . '), |
zoom: ' . BAZ_GOOGLE_ALTITUDE . ', |
mapTypeId: "OSM", |
mapTypeControlOptions: { |
mapTypeIds: ["OSM", |
google.maps.MapTypeId.ROADMAP, |
google.maps.MapTypeId.HYBRID, |
google.maps.MapTypeId.SATELLITE, |
google.maps.MapTypeId.TERRAIN] |
}, |
mapTypeControl: true, |
scaleControl: true |
}; |
|
' . |
$script_marker.' |
map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3); |
map.mapTypes.set("OSM", new google.maps.ImageMapType({ |
getTileUrl: function(coord, zoom) { |
return "http://osm.tela-botanica.org/tile/" + // cache de tuiles avec nginx |
zoom + "/" + coord.x + "/" + coord.y + ".png"; |
}, |
tileSize: new google.maps.Size(256, 256), |
isPng: true, |
alt: "OpenStreetMap", |
name: "OSM", |
maxZoom: 19 |
})); |
|
var mention = \'<div id="origine-donnees">Tuiles : <a href="http://www.openstreetmap.fr" target="_blank">OsmFr</a><br/>\'; |
mention += \'Carte : <a href="http://www.openstreetmap.org/copyright" target="_blank">© les contributeurs d\\\'OpenStreetMap</a></div>\'; |
$("#map").append(mention); |
|
// ecouteur sur changement de fond |
google.maps.event.addListener( map, \'maptypeid_changed\', function() { |
if (map.getMapTypeId() == "OSM") { |
$("#origine-donnees").show(); |
} else { |
$("#origine-donnees").hide(); |
} |
}; |
// Creates a marker at the given point with the given number label |
});'; |
|
'; |
if (BAZ_GOOGLE_FOND_KML != '') { |
$script .= 'geoXml = new google.maps.KmlLayer(' . BAZ_GOOGLE_FOND_KML . ');'; |
} |
|
$script .= $script_marker; |
if (BAZ_GOOGLE_FOND_KML != '') { |
$script .= 'geoXml.setMap(map);'; |
} |
|
$script .= '};'; |
|
GEN_stockerCodeScript($script); |
// On ajoute l attribut load a la balise body |
//GEN_AttributsBody('onload', 'load()'); |
|
|
|
function afficherContenuCorps() { |
|
$res = '<div id="map" style="width: 600px; height: 450px"></div>'; |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php'; |
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']); |
$html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']); |
if (PEAR::isError($html)) return $html->getMessage(); |
|
// nettoyage url |
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ID_FICHE) ; |
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION) ; |
$html = bazar::getFormulaireFiltre($html) ; |
|
$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR. |
'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html); |
|
return $res; |
} |
|
134,6 → 294,28 |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.5.2.3 2008-01-29 09:41:11 alexandre_tb |
* utilisation des constantes BAZ_GOOGLE_FOND_KML |
* |
* Revision 1.5.2.2 2007-12-14 09:57:15 alexandre_tb |
* utilisation des constantes de la carte google |
* |
* Revision 1.5.2.1 2007-12-04 16:19:32 jp_milcent |
* Ajout de la prise en charge de l'applette body_attributs |
* |
* Revision 1.5 2007-10-01 12:07:03 alexandre_tb |
* utilisation de constantes du fichier de conf pour centrer la carte |
* |
* Revision 1.4 2007-08-27 12:27:34 alexandre_tb |
* mise en place d un icone personnalise |
* et de l affichage de plusieurs donnees sur un meme point |
* |
* Revision 1.3 2007-07-04 10:08:41 alexandre_tb |
* Appel du template carte_google |
* |
* Revision 1.2 2007-06-13 10:02:47 alexandre_tb |
* le carte s adapte a la taille du conteneur |
* |
* Revision 1.1 2007-06-04 15:26:57 alexandre_tb |
* version initiale |
* |