Subversion Repositories Applications.bazar

Rev

Rev 416 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
253 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
// +------------------------------------------------------------------------------------------------------+
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;
416 jpm 39
    // Variables globales
40
    // cette fonction peut déjà être présente
41
	if (typeof(addListener) != \'function\') {
42
		// fonction portable pour ajout de listeners
43
		function addListener(element, baseName, handler)
44
		{
45
			if (element.addEventListener) {
46
				element.addEventListener(baseName, handler, false) ;
47
			} else if (element.attachEvent) {
48
				element.attachEvent(\'on\'+baseName, handler) ;
49
			}
50
		}
51
	}
52
    addListener(window,\'load\',loadMap) ;
53
    //var isMap = true ;
253 alexandre_ 54
	var geocoder = null;
55
	var lat = document.getElementById("latitude");
56
    var lon = document.getElementById("longitude");
57
 
416 jpm 58
    function loadMap() {
253 alexandre_ 59
    if (GBrowserIsCompatible()) {
60
      map = new GMap2(document.getElementById("map"));
416 jpm 61
      map.setMapType(G_HYBRID_MAP) ;
253 alexandre_ 62
      map.addControl(new GSmallMapControl());
63
	  map.addControl(new GMapTypeControl());
64
	  map.addControl(new GScaleControl());
65
	  map.enableContinuousZoom();
66
 
67
	  // On centre la carte sur le languedoc roussillon
418 jpm 68
	  center = new GLatLng(47.0833015, 2.35000001);
416 jpm 69
      map.setCenter(center, 6);
253 alexandre_ 70
	  //marker = new GMarker(center, {draggable: true}) ;
71
      GEvent.addListener(map, "click", function(marker, point) {
72
	    if (marker) {
73
	      map.removeOverlay(marker);
74
	      var lat = document.getElementById("latitude");
75
          var lon = document.getElementById("longitude");
76
	      lat.value = "";
77
          lon.value = "";
78
	    } else {
79
	      // On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
80
	      marker = new GMarker(point, {draggable: true}) ;
81
	      GEvent.addListener(marker, "dragend", function () {
82
            coordMarker = marker.getPoint() ;
83
            var lat = document.getElementById("latitude");
84
            var lon = document.getElementById("longitude");
85
            lat.value = coordMarker.lat();
86
            lon.value = coordMarker.lng();
87
          });
88
          map.addOverlay(marker);
89
          setLatLonForm(marker);
90
	    }
91
    });' ;
92
	if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
93
		$script .= '
94
				point = new GLatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
95
				marker = new GMarker(point, {draggable: true});
96
				map.addOverlay(marker);' ;
97
	}
98
    $script .= 'geocoder = new GClientGeocoder();
99
  }
100
};
101
function showAddress() {
102
  var adresse = document.getElementById("bf_adresse").value ;
103
  var ville = document.getElementById("bf_ville").value ;
104
  var cp = document.getElementById("bf_cp_lieu_evenement").value ;
105
  var selectIndex = document.getElementById("liste30").selectedIndex;
106
  var pays = document.getElementById("liste30").options[selectIndex].text ;
107
 
108
  var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
109
  if (geocoder) {
110
    geocoder.getLatLng(
111
      address,
112
      function(point) {
113
        if (!point) {
114
          alert(address + " not found");
115
        } else {
116
          map.setCenter(point, 13);
117
          var marker = new GMarker(point, {draggable: true});
118
          GEvent.addListener(marker, "dragend", function () {
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
          map.addOverlay(marker);
127
          setLatLonForm(marker)
128
          marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
129
        }
130
      }
131
    );
132
  }
133
}
134
function setLatLonForm(marker) {
135
  coordMarker = marker.getPoint() ;
136
  var lat = document.getElementById("latitude");
137
  var lon = document.getElementById("longitude");
138
  lat.value = coordMarker.lat();
139
  lon.value = coordMarker.lng();
140
}
141
';
142
 
143
/*
144
* +--Fin du code ----------------------------------------------------------------------------------------+
145
*
146
* $Log: not supported by cvs2svn $
147
* +-- Fin du code ----------------------------------------------------------------------------------------+
148
*/