Subversion Repositories Applications.papyrus

Rev

Rev 2149 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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