Rev 468 | Rev 476 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?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 ----------------------------------------------------------------------------------------+
*/