Subversion Repositories Applications.bazar

Compare Revisions

Ignore whitespace Rev 476 → Rev 477

/branches/v3.1-blanche-neige/bazar.carte_google.php
41,7 → 41,8
// Inclusion d'une classe personnalise si elle existe
 
// 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.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');
103,44 → 104,46
if ($resultat->numRows() != 0) {
$script_marker = '';
$couleur_drapeau = array ( 1 => 'bleu', 2 => 'vert', 3 => 'orange', 4 => 'rose');
 
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
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 = new GIcon(G_DEFAULT_ICON);
icon.image = "reseau/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png";'."\n".'
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(16, 16);
icon.shadowSize = new GSize(16, 16);
icon.iconAnchor = new GPoint(6, 16);
icon.infoWindowAnchor = new GPoint(5, 1);'."\n";
$script_marker .= "\t".'point = new GLatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n"
."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
 
$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));'."\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 = new GIcon();
icon.image = "http://www.tela-botanica.org/reseau/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png";
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(16, 16);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(6, 34);
icon.infoWindowAnchor = new GPoint(5, 1);';
$script_marker .= "\t".'point = new GLatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n"
."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
 
$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));'."\n";
}
str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\', icon, new google.maps.Size(5,1));'."\n";
}
}
} else {
$script_marker = '';
161,6 → 164,7
}
}
addListener(window,\'load\',loadMap) ;';
 
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
// Pour gerer la taille
var winW = 630, winH = 560;
169,11 → 173,11
 
function setWinHW() {
if (window.innerHeight) {
winW = window.innerWidth - deltaW;
winH = window.innerHeight - deltaH;
winW = window.innerWidth - deltaW;
winH = window.innerHeight - deltaH;
} else {
winW = document.documentElement.offsetWidth - 20 - deltaW;
winH = document.documentElement.offsetHeight - 20 - deltaH ;
winW = document.documentElement.offsetWidth - 20 - deltaW;
winH = document.documentElement.offsetHeight - 20 - deltaH ;
}
 
var me = document.getElementById("map");
189,12 → 193,20
}';
$script .= '
function createMarker(point, chaine, icon) {
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);
});
 
var marker = new GMarker(point, icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(chaine);
});
return marker;
}
function loadMap() {';
201,30 → 213,46
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
setWinHW();';
$script .= '
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.enableContinuousZoom();
// On centre la carte sur le languedoc roussillon
center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
map.setMapType(G_HYBRID_MAP);' ;
if (BAZ_GOOGLE_FOND_KML != '') {
$script .= 'var geoXml = new GGeoXml("'.BAZ_GOOGLE_FOND_KML.'");';
}
$script .= $script_marker;
if (BAZ_GOOGLE_FOND_KML != '') {
$script .= 'map.addOverlay(geoXml);';
}
$script .= '
}
};
';
var optionsGoogleMapsv3 = {
// On centre la carte sur le languedoc roussillon
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
};
 
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
}));';
 
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()');
279,4 → 307,4
* version initiale
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
*/