Subversion Repositories Applications.bazar

Compare Revisions

Ignore whitespace Rev 467 → Rev 468

/trunk/bibliotheque/bazar.fonct.google.php
1,132 → 1,162
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | 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.fonct.google.php,v 1.1 2007-06-04 15:24:00 alexandre_tb Exp $
/**
* Formulaire
*
* Les fonctions et script specifique a un carto google
*
*@package bazar
//Auteur original :
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
$script = '
// Variables globales
var map = null;
var geocoder = null;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
function load() {
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(43.84245116699036, 3.768310546875);
map.setCenter(center, 7);
//marker = new GMarker(center, {draggable: true}) ;
GEvent.addListener(map, "click", function(marker, point) {
if (marker) {
map.removeOverlay(marker);
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
lat.value = "";
lon.value = "";
} else {
// On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
marker = new GMarker(point, {draggable: true}) ;
GEvent.addListener(marker, "dragend", function () {
coordMarker = marker.getPoint() ;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
lat.value = coordMarker.lat();
lon.value = coordMarker.lng();
});
map.addOverlay(marker);
setLatLonForm(marker);
}
});' ;
if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
$script .= '
point = new GLatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
marker = new GMarker(point, {draggable: true});
map.addOverlay(marker);' ;
}
$script .= 'geocoder = new GClientGeocoder();
}
};
function showAddress() {
var adresse = document.getElementById("bf_adresse").value ;
var ville = document.getElementById("bf_ville").value ;
var cp = document.getElementById("bf_cp_lieu_evenement").value ;
var selectIndex = document.getElementById("liste30").selectedIndex;
var pays = document.getElementById("liste30").options[selectIndex].text ;
var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point, {draggable: true});
GEvent.addListener(marker, "dragend", function () {
coordMarker = marker.getPoint() ;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
lat.value = coordMarker.lat();
lon.value = coordMarker.lng();
});
 
map.addOverlay(marker);
setLatLonForm(marker)
marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
}
}
);
}
}
function setLatLonForm(marker) {
coordMarker = marker.getPoint() ;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
lat.value = coordMarker.lat();
lon.value = coordMarker.lng();
}
';
 
/*
* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | 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.fonct.google.php,v 1.1 2007-06-04 15:24:00 alexandre_tb Exp $
/**
* Formulaire
*
* Les fonctions et script specifique a un carto google
*
*@package bazar
//Auteur original :
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
$script = '
// Variables globales
var map = null;
var geocoder = null;
var marker = null;
var flat = null;
var flon = null;
 
// cette fonction peut d�j� �tre pr�sente
// 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) ;
function loadMap() {
flat = document.getElementById("latitude");
flon = document.getElementById("longitude");
 
var optionsGoogleMapsv3 = {
// On centre la carte sur le languedoc roussillon
center: new google.maps.LatLng(43.84245116699036, 3.768310546875),
zoom: 7,
mapTypeId: google.maps.MapTypeId.G_HYBRID_MAP,
mapTypeControl: true,
scaleControl: true
};
map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
 
google.maps.event.addListener(map, "click", function(event) {
if (marker != null) {
marker.setMap(null);
marker = null;
}
// On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
marker = event.overlay;
marker = new google.maps.Marker({
position: event.latLng,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
setLatLonForm(marker);
});';
if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
$script .= '
point = new google.maps.LatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
marker = new google.maps.Marker({
position: point,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
map.setCenter(point);
' ;
}
$script .= 'geocoder = new google.maps.Geocoder();
};
function showAddress() {
var adresse = document.getElementById("bf_adresse").value;
var ville = "";
if (document.getElementById("bf_ville")) {
ville = document.getElementById("bf_ville").value ;
}
var cp = document.getElementById("bf_cp_lieu_evenement").value ;
var pays;
if (document.getElementById("liste30")) {
var selectIndex = document.getElementById("liste30").selectedIndex;
pays = document.getElementById("liste30").options[selectIndex].text ;
} else {
pays = document.getElementById("bf_pays").value;
}
var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
if (geocoder) {
geocoder.geocode({
address: address
}, function(result, status) {
if (status != google.maps.GeocoderStatus.OK) {
alert(address + " not found");
} else {
marker.setMap(null);
marker = null;
//map.setCenter(point, 13);
map.fitBounds(result[0].geometry.viewport);
marker = new google.maps.Marker({
position: result[0].geometry.location,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
setLatLonForm(marker);
//marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
}
});
}
}
function setLatLonForm(marker) {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
}
';
 
 
 
/*
* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/