1461 |
alexandre_ |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
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 |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
1510 |
alexandre_ |
22 |
// CVS : $Id: formulaire.fonct.google.php,v 1.2 2007-07-04 11:52:55 alexandre_tb Exp $
|
1461 |
alexandre_ |
23 |
/**
|
|
|
24 |
* Formulaire
|
|
|
25 |
*
|
|
|
26 |
* Les fonctions et script specifique a un carto google
|
|
|
27 |
*
|
|
|
28 |
*@package api/formulaire
|
|
|
29 |
//Auteur original :
|
|
|
30 |
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
|
|
|
31 |
*@copyright Tela-Botanica 2000-2007
|
1510 |
alexandre_ |
32 |
*@version $Revision: 1.2 $
|
1461 |
alexandre_ |
33 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
34 |
*/
|
|
|
35 |
|
|
|
36 |
$script = '
|
|
|
37 |
// Variables globales
|
|
|
38 |
var map = null;
|
|
|
39 |
var geocoder = null;
|
|
|
40 |
var lat = document.getElementById("latitude");
|
|
|
41 |
var lon = document.getElementById("longitude");
|
|
|
42 |
|
|
|
43 |
function load() {
|
|
|
44 |
if (GBrowserIsCompatible()) {
|
1510 |
alexandre_ |
45 |
|
|
|
46 |
map = new GMap2(document.getElementById("map"), G_HYBRID_MAP);
|
|
|
47 |
|
1461 |
alexandre_ |
48 |
map.addControl(new GSmallMapControl());
|
|
|
49 |
map.addControl(new GMapTypeControl());
|
|
|
50 |
map.addControl(new GScaleControl());
|
|
|
51 |
map.enableContinuousZoom();
|
|
|
52 |
|
|
|
53 |
// On centre la carte sur le languedoc roussillon
|
|
|
54 |
center = new GLatLng(43.84245116699036, 3.768310546875);
|
1510 |
alexandre_ |
55 |
map.setCenter(center, 7);map.setMapType(G_HYBRID_MAP);
|
1461 |
alexandre_ |
56 |
//marker = new GMarker(center, {draggable: true}) ;
|
|
|
57 |
GEvent.addListener(map, "click", function(marker, point) {
|
|
|
58 |
if (marker) {
|
|
|
59 |
map.removeOverlay(marker);
|
|
|
60 |
var lat = document.getElementById("latitude");
|
|
|
61 |
var lon = document.getElementById("longitude");
|
|
|
62 |
lat.value = "";
|
|
|
63 |
lon.value = "";
|
|
|
64 |
} else {
|
|
|
65 |
// On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
|
|
|
66 |
marker = new GMarker(point, {draggable: true}) ;
|
|
|
67 |
GEvent.addListener(marker, "dragend", function () {
|
|
|
68 |
coordMarker = marker.getPoint() ;
|
|
|
69 |
var lat = document.getElementById("latitude");
|
|
|
70 |
var lon = document.getElementById("longitude");
|
|
|
71 |
lat.value = coordMarker.lat();
|
|
|
72 |
lon.value = coordMarker.lng();
|
|
|
73 |
});
|
|
|
74 |
map.addOverlay(marker);
|
|
|
75 |
setLatLonForm(marker);
|
|
|
76 |
}
|
|
|
77 |
});' ;
|
|
|
78 |
if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
|
|
|
79 |
$script .= '
|
|
|
80 |
point = new GLatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
|
|
|
81 |
marker = new GMarker(point, {draggable: true});
|
|
|
82 |
map.addOverlay(marker);' ;
|
|
|
83 |
}
|
|
|
84 |
$script .= 'geocoder = new GClientGeocoder();
|
|
|
85 |
}
|
|
|
86 |
};
|
|
|
87 |
function showAddress() {
|
|
|
88 |
var adresse = document.getElementById("bf_adresse").value ;
|
|
|
89 |
var ville = document.getElementById("bf_ville").value ;
|
|
|
90 |
var cp = document.getElementById("bf_cp_lieu_evenement").value ;
|
1510 |
alexandre_ |
91 |
if (document.getElementById("liste30")) {
|
|
|
92 |
var selectIndex = document.getElementById("liste30").selectedIndex;
|
|
|
93 |
var pays = document.getElementById("liste30").options[selectIndex].text ;
|
|
|
94 |
} else {
|
|
|
95 |
var pays = document.getElementById("bf_pays").value;
|
|
|
96 |
}
|
1461 |
alexandre_ |
97 |
var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
|
|
|
98 |
if (geocoder) {
|
|
|
99 |
geocoder.getLatLng(
|
|
|
100 |
address,
|
|
|
101 |
function(point) {
|
|
|
102 |
if (!point) {
|
|
|
103 |
alert(address + " not found");
|
|
|
104 |
} else {
|
|
|
105 |
map.setCenter(point, 13);
|
|
|
106 |
var marker = new GMarker(point, {draggable: true});
|
|
|
107 |
GEvent.addListener(marker, "dragend", function () {
|
|
|
108 |
coordMarker = marker.getPoint() ;
|
|
|
109 |
var lat = document.getElementById("latitude");
|
|
|
110 |
var lon = document.getElementById("longitude");
|
|
|
111 |
lat.value = coordMarker.lat();
|
|
|
112 |
lon.value = coordMarker.lng();
|
|
|
113 |
});
|
|
|
114 |
|
|
|
115 |
map.addOverlay(marker);
|
|
|
116 |
setLatLonForm(marker)
|
|
|
117 |
marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
);
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
function setLatLonForm(marker) {
|
|
|
124 |
coordMarker = marker.getPoint() ;
|
|
|
125 |
var lat = document.getElementById("latitude");
|
|
|
126 |
var lon = document.getElementById("longitude");
|
|
|
127 |
lat.value = coordMarker.lat();
|
|
|
128 |
lon.value = coordMarker.lng();
|
|
|
129 |
}
|
|
|
130 |
';
|
|
|
131 |
|
|
|
132 |
/*
|
|
|
133 |
* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
134 |
*
|
|
|
135 |
* $Log: not supported by cvs2svn $
|
1510 |
alexandre_ |
136 |
* Revision 1.1 2007-06-25 09:52:36 alexandre_tb
|
|
|
137 |
* version intiale -- en cours
|
1461 |
alexandre_ |
138 |
*
|
1510 |
alexandre_ |
139 |
*
|
1461 |
alexandre_ |
140 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
141 |
*/
|