Subversion Repositories Applications.papyrus

Rev

Rev 1461 | Rev 1539 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1461 Rev 1510
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.1 2007-06-25 09:52:36 alexandre_tb Exp $
22
// CVS : $Id: formulaire.fonct.google.php,v 1.2 2007-07-04 11:52:55 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.1 $
32
*@version       $Revision: 1.2 $
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 lat = document.getElementById("latitude");
40
	var lat = document.getElementById("latitude");
41
    var lon = document.getElementById("longitude");
41
    var lon = document.getElementById("longitude");
42
    
42
    
43
    function load() {
43
    function load() {
44
    if (GBrowserIsCompatible()) {
44
    if (GBrowserIsCompatible()) {
-
 
45
	  
45
      map = new GMap2(document.getElementById("map"));
46
      map = new GMap2(document.getElementById("map"), G_HYBRID_MAP);
-
 
47
      
46
      map.addControl(new GSmallMapControl());
48
      map.addControl(new GSmallMapControl());
47
	  map.addControl(new GMapTypeControl());
49
	  map.addControl(new GMapTypeControl());
48
	  map.addControl(new GScaleControl());
50
	  map.addControl(new GScaleControl());
49
	  map.enableContinuousZoom();
51
	  map.enableContinuousZoom();
50
	
52
	
51
	  // On centre la carte sur le languedoc roussillon
53
	  // On centre la carte sur le languedoc roussillon
52
	  center = new GLatLng(43.84245116699036, 3.768310546875);
54
	  center = new GLatLng(43.84245116699036, 3.768310546875);
53
      map.setCenter(center, 7);
55
      map.setCenter(center, 7);map.setMapType(G_HYBRID_MAP);
54
	  //marker = new GMarker(center, {draggable: true}) ;
56
	  //marker = new GMarker(center, {draggable: true}) ;
55
      GEvent.addListener(map, "click", function(marker, point) {
57
      GEvent.addListener(map, "click", function(marker, point) {
56
	    if (marker) {
58
	    if (marker) {
57
	      map.removeOverlay(marker);
59
	      map.removeOverlay(marker);
58
	      var lat = document.getElementById("latitude");
60
	      var lat = document.getElementById("latitude");
59
          var lon = document.getElementById("longitude");
61
          var lon = document.getElementById("longitude");
60
	      lat.value = "";
62
	      lat.value = "";
61
          lon.value = "";
63
          lon.value = "";
62
	    } else {
64
	    } else {
63
	      // On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
65
	      // 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}) ;
66
	      marker = new GMarker(point, {draggable: true}) ;
65
	      GEvent.addListener(marker, "dragend", function () {
67
	      GEvent.addListener(marker, "dragend", function () {
66
            coordMarker = marker.getPoint() ;
68
            coordMarker = marker.getPoint() ;
67
            var lat = document.getElementById("latitude");
69
            var lat = document.getElementById("latitude");
68
            var lon = document.getElementById("longitude");
70
            var lon = document.getElementById("longitude");
69
            lat.value = coordMarker.lat();
71
            lat.value = coordMarker.lat();
70
            lon.value = coordMarker.lng();
72
            lon.value = coordMarker.lng();
71
          });
73
          });
72
          map.addOverlay(marker);
74
          map.addOverlay(marker);
73
          setLatLonForm(marker);
75
          setLatLonForm(marker);
74
	    }
76
	    }
75
    });' ;
77
    });' ;
76
	if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
78
	if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
77
		$script .= '
79
		$script .= '
78
				point = new GLatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
80
				point = new GLatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
79
				marker = new GMarker(point, {draggable: true});
81
				marker = new GMarker(point, {draggable: true});
80
				map.addOverlay(marker);' ;
82
				map.addOverlay(marker);' ;
81
	} 
83
	} 
82
    $script .= 'geocoder = new GClientGeocoder();
84
    $script .= 'geocoder = new GClientGeocoder();
83
  }
85
  }
84
};
86
};
85
function showAddress() {
87
function showAddress() {
86
  var adresse = document.getElementById("bf_adresse").value ;
88
  var adresse = document.getElementById("bf_adresse").value ;
87
  var ville = document.getElementById("bf_ville").value ;
89
  var ville = document.getElementById("bf_ville").value ;
88
  var cp = document.getElementById("bf_cp_lieu_evenement").value ;
90
  var cp = document.getElementById("bf_cp_lieu_evenement").value ;
-
 
91
  if (document.getElementById("liste30")) {
89
  var selectIndex = document.getElementById("liste30").selectedIndex;
92
  	var selectIndex = document.getElementById("liste30").selectedIndex;
90
  var pays = document.getElementById("liste30").options[selectIndex].text ;
93
  	var pays = document.getElementById("liste30").options[selectIndex].text ;
-
 
94
  } else {
-
 
95
  	var pays = document.getElementById("bf_pays").value;
91
  
96
  }
92
  var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
97
  var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
93
  if (geocoder) {
98
  if (geocoder) {
94
    geocoder.getLatLng(
99
    geocoder.getLatLng(
95
      address,
100
      address,
96
      function(point) {
101
      function(point) {
97
        if (!point) {
102
        if (!point) {
98
          alert(address + " not found");
103
          alert(address + " not found");
99
        } else {
104
        } else {
100
          map.setCenter(point, 13);
105
          map.setCenter(point, 13);
101
          var marker = new GMarker(point, {draggable: true});
106
          var marker = new GMarker(point, {draggable: true});
102
          GEvent.addListener(marker, "dragend", function () {
107
          GEvent.addListener(marker, "dragend", function () {
103
  coordMarker = marker.getPoint() ;
108
  coordMarker = marker.getPoint() ;
104
  var lat = document.getElementById("latitude");
109
  var lat = document.getElementById("latitude");
105
  var lon = document.getElementById("longitude");
110
  var lon = document.getElementById("longitude");
106
  lat.value = coordMarker.lat();
111
  lat.value = coordMarker.lat();
107
  lon.value = coordMarker.lng();
112
  lon.value = coordMarker.lng();
108
});
113
});
109
 
114
 
110
          map.addOverlay(marker);
115
          map.addOverlay(marker);
111
          setLatLonForm(marker)
116
          setLatLonForm(marker)
112
          marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
117
          marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
113
        }
118
        }
114
      }
119
      }
115
    );
120
    );
116
  }
121
  }
117
}
122
}
118
function setLatLonForm(marker) {
123
function setLatLonForm(marker) {
119
  coordMarker = marker.getPoint() ;
124
  coordMarker = marker.getPoint() ;
120
  var lat = document.getElementById("latitude");
125
  var lat = document.getElementById("latitude");
121
  var lon = document.getElementById("longitude");
126
  var lon = document.getElementById("longitude");
122
  lat.value = coordMarker.lat();
127
  lat.value = coordMarker.lat();
123
  lon.value = coordMarker.lng();
128
  lon.value = coordMarker.lng();
124
}
129
}
125
';
130
';
126
 
131
 
127
/*
132
/*
128
* +--Fin du code ----------------------------------------------------------------------------------------+
133
* +--Fin du code ----------------------------------------------------------------------------------------+
129
*
134
*
130
* $Log: not supported by cvs2svn $
135
* $Log: not supported by cvs2svn $
-
 
136
* Revision 1.1  2007-06-25 09:52:36  alexandre_tb
-
 
137
* version intiale -- en cours
-
 
138
*
131
*
139
*
132
* +-- Fin du code ----------------------------------------------------------------------------------------+
140
* +-- Fin du code ----------------------------------------------------------------------------------------+
133
*/
141
*/