Subversion Repositories Applications.bazar

Rev

Rev 253 | Rev 479 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 253 Rev 468
Line 1... Line -...
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
// +------------------------------------------------------------------------------------------------------+
-
 
22
// CVS : $Id: bazar.fonct.google.php,v 1.1 2007-06-04 15:24:00 alexandre_tb Exp $
-
 
23
/**
-
 
24
* Formulaire
-
 
25
*
-
 
26
* Les fonctions et script specifique a un carto google
-
 
27
*
-
 
28
*@package bazar
-
 
29
//Auteur original :
-
 
30
*@author        Aleandre GRANIER <alexandre@tela-botanica.org>
-
 
31
*@copyright     Tela-Botanica 2000-2007
-
 
32
*@version       $Revision: 1.1 $
-
 
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()) {
-
 
45
      map = new GMap2(document.getElementById("map"));
-
 
46
      map.addControl(new GSmallMapControl());
-
 
47
	  map.addControl(new GMapTypeControl());
-
 
48
	  map.addControl(new GScaleControl());
-
 
49
	  map.enableContinuousZoom();
-
 
50
	
-
 
51
	  // On centre la carte sur le languedoc roussillon
-
 
52
	  center = new GLatLng(43.84245116699036, 3.768310546875);
-
 
53
      map.setCenter(center, 7);
-
 
54
	  //marker = new GMarker(center, {draggable: true}) ;
-
 
55
      GEvent.addListener(map, "click", function(marker, point) {
-
 
56
	    if (marker) {
-
 
57
	      map.removeOverlay(marker);
-
 
58
	      var lat = document.getElementById("latitude");
-
 
59
          var lon = document.getElementById("longitude");
-
 
60
	      lat.value = "";
-
 
61
          lon.value = "";
-
 
62
	    } else {
-
 
63
	      // On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
-
 
64
	      marker = new GMarker(point, {draggable: true}) ;
-
 
65
	      GEvent.addListener(marker, "dragend", function () {
-
 
66
            coordMarker = marker.getPoint() ;
-
 
67
            var lat = document.getElementById("latitude");
-
 
68
            var lon = document.getElementById("longitude");
-
 
69
            lat.value = coordMarker.lat();
-
 
70
            lon.value = coordMarker.lng();
-
 
71
          });
-
 
72
          map.addOverlay(marker);
-
 
73
          setLatLonForm(marker);
-
 
74
	    }
-
 
75
    });' ;
-
 
76
	if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
-
 
77
		$script .= '
-
 
78
				point = new GLatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
-
 
79
				marker = new GMarker(point, {draggable: true});
-
 
80
				map.addOverlay(marker);' ;
-
 
81
	} 
-
 
82
    $script .= 'geocoder = new GClientGeocoder();
-
 
83
  }
-
 
84
};
-
 
85
function showAddress() {
-
 
86
  var adresse = document.getElementById("bf_adresse").value ;
-
 
87
  var ville = document.getElementById("bf_ville").value ;
-
 
88
  var cp = document.getElementById("bf_cp_lieu_evenement").value ;
-
 
89
  var selectIndex = document.getElementById("liste30").selectedIndex;
-
 
90
  var pays = document.getElementById("liste30").options[selectIndex].text ;
-
 
91
  
-
 
92
  var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
-
 
93
  if (geocoder) {
-
 
94
    geocoder.getLatLng(
-
 
95
      address,
-
 
96
      function(point) {
-
 
97
        if (!point) {
-
 
98
          alert(address + " not found");
-
 
99
        } else {
-
 
100
          map.setCenter(point, 13);
-
 
101
          var marker = new GMarker(point, {draggable: true});
-
 
102
          GEvent.addListener(marker, "dragend", function () {
-
 
103
  coordMarker = marker.getPoint() ;
-
 
104
  var lat = document.getElementById("latitude");
-
 
105
  var lon = document.getElementById("longitude");
-
 
106
  lat.value = coordMarker.lat();
-
 
107
  lon.value = coordMarker.lng();
-
 
108
});
-
 
109
 
-
 
110
          map.addOverlay(marker);
-
 
111
          setLatLonForm(marker)
-
 
112
          marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
-
 
113
        }
-
 
114
      }
-
 
115
    );
-
 
116
  }
-
 
117
}
-
 
118
function setLatLonForm(marker) {
-
 
119
  coordMarker = marker.getPoint() ;
-
 
120
  var lat = document.getElementById("latitude");
-
 
121
  var lon = document.getElementById("longitude");
-
 
122
  lat.value = coordMarker.lat();
-
 
123
  lon.value = coordMarker.lng();
-
 
124
}
-
 
125
';
-
 
126
 
-
 
127
/*
-
 
128
* +--Fin du code ----------------------------------------------------------------------------------------+
-
 
129
*
-
 
130
* $Log: not supported by cvs2svn $
-
 
131
* +-- Fin du code ----------------------------------------------------------------------------------------+
-
 
132
*/
-
 
133
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
// +------------------------------------------------------------------------------------------------------+
-
 
22
// CVS : $Id: bazar.fonct.google.php,v 1.1 2007-06-04 15:24:00 alexandre_tb Exp $
-
 
23
/**
-
 
24
* Formulaire
-
 
25
*
-
 
26
* Les fonctions et script specifique a un carto google
-
 
27
*
-
 
28
*@package bazar
-
 
29
//Auteur original :
-
 
30
*@author        Aleandre GRANIER <alexandre@tela-botanica.org>
-
 
31
*@copyright     Tela-Botanica 2000-2007
-
 
32
*@version       $Revision: 1.1 $
-
 
33
// +------------------------------------------------------------------------------------------------------+
-
 
34
*/
-
 
35
 
-
 
36
$script = '
-
 
37
// Variables globales
-
 
38
    var map = null;
-
 
39
	var geocoder = null;
-
 
40
	var marker = null;
-
 
41
	var flat = null;
-
 
42
    var flon = null;
-
 
43
 
-
 
44
 // cette fonction peut d�j� �tre pr�sente
-
 
45
                // fonction portable pour ajout de listeners
-
 
46
                function addListener(element, baseName, handler)
-
 
47
                {
-
 
48
                        if (element.addEventListener) {
-
 
49
                                element.addEventListener(baseName, handler, false) ;
-
 
50
                        } else if (element.attachEvent) {
-
 
51
                                element.attachEvent(\'on\'+baseName, handler) ;
-
 
52
                        }
-
 
53
                }
-
 
54
    addListener(window,\'load\',loadMap) ;
-
 
55
    function loadMap() {
-
 
56
		flat = document.getElementById("latitude");
-
 
57
	    flon = document.getElementById("longitude");
-
 
58
 
-
 
59
		var optionsGoogleMapsv3 = {
-
 
60
			// On centre la carte sur le languedoc roussillon
-
 
61
			center: new google.maps.LatLng(43.84245116699036, 3.768310546875),
-
 
62
			zoom: 7,
-
 
63
			mapTypeId: google.maps.MapTypeId.G_HYBRID_MAP,
-
 
64
			mapTypeControl: true,
-
 
65
			scaleControl: true
-
 
66
		};
-
 
67
	    map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
-
 
68
 
-
 
69
	    google.maps.event.addListener(map, "click", function(event) {
-
 
70
			if (marker != null) {
-
 
71
				marker.setMap(null);
-
 
72
				marker = null;
-
 
73
	    	}
-
 
74
			// On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
-
 
75
			marker = event.overlay;
-
 
76
	      	marker = new google.maps.Marker({
-
 
77
				position: event.latLng,
-
 
78
				draggable: true,
-
 
79
				map: map
-
 
80
			});
-
 
81
	      	google.maps.event.addListener(marker, "dragend", function () {
-
 
82
            	coordMarker = marker.getPosition() ;
-
 
83
            	flat.value = coordMarker.lat();
-
 
84
            	flon.value = coordMarker.lng();
-
 
85
          	});
-
 
86
          	setLatLonForm(marker);
-
 
87
    	});';
-
 
88
		if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
-
 
89
			$script .= '
-
 
90
				point = new google.maps.LatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
-
 
91
				marker = new google.maps.Marker({
-
 
92
					position: point,
-
 
93
					draggable: true,
-
 
94
					map: map
-
 
95
				});
-
 
96
		      	google.maps.event.addListener(marker, "dragend", function () {
-
 
97
	            	coordMarker = marker.getPosition() ;
-
 
98
	            	flat.value = coordMarker.lat();
-
 
99
	            	flon.value = coordMarker.lng();
-
 
100
	          	});
-
 
101
			map.setCenter(point);
-
 
102
			' ;
-
 
103
		} 
-
 
104
	    $script .= 'geocoder = new google.maps.Geocoder();
-
 
105
	};
-
 
106
	function showAddress() {
-
 
107
		var adresse = document.getElementById("bf_adresse").value;
-
 
108
    	var ville = "";
-
 
109
	  	if (document.getElementById("bf_ville")) {
-
 
110
	  		ville = document.getElementById("bf_ville").value ;
-
 
111
	  	}
-
 
112
	  	var cp = document.getElementById("bf_cp_lieu_evenement").value ;
-
 
113
	    var pays;
-
 
114
	  	if (document.getElementById("liste30")) {
-
 
115
	  		var selectIndex = document.getElementById("liste30").selectedIndex;
-
 
116
	  		pays = document.getElementById("liste30").options[selectIndex].text ;
-
 
117
	  	} else {
-
 
118
	  		pays = document.getElementById("bf_pays").value;
-
 
119
	  	}
-
 
120
	  	var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
-
 
121
	  	if (geocoder) {
-
 
122
	    	geocoder.geocode({
-
 
123
	    		address: address
-
 
124
	    	}, function(result, status) {
-
 
125
	    		 if (status != google.maps.GeocoderStatus.OK) {
-
 
126
    				alert(address + " not found");
-
 
127
			} else {
-
 
128
			marker.setMap(null);
-
 
129
			marker = null;
-
 
130
			//map.setCenter(point, 13);
-
 
131
			map.fitBounds(result[0].geometry.viewport);
-
 
132
			marker = new google.maps.Marker({
-
 
133
				position: result[0].geometry.location,
-
 
134
				draggable: true,
-
 
135
				map: map
-
 
136
				});
-
 
137
			google.maps.event.addListener(marker, "dragend", function () {
-
 
138
					coordMarker = marker.getPosition() ;
-
 
139
					flat.value = coordMarker.lat();
-
 
140
					flon.value = coordMarker.lng();
-
 
141
				});
-
 
142
			setLatLonForm(marker);
-
 
143
			//marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
-
 
144
		}
-
 
145
      		});
-
 
146
  		}
-
 
147
	}
-
 
148
	function setLatLonForm(marker) {
-
 
149
  		coordMarker = marker.getPosition() ;
-
 
150
  		flat.value = coordMarker.lat();
-
 
151
  		flon.value = coordMarker.lng();
-
 
152
	}
-
 
153
';
-
 
154
 
-
 
155
 
-
 
156
 
-
 
157
/*
-
 
158
* +--Fin du code ----------------------------------------------------------------------------------------+
-
 
159
*
-
 
160
* $Log: not supported by cvs2svn $
-
 
161
* +-- Fin du code ----------------------------------------------------------------------------------------+
-
 
162
*/
-
 
163