Subversion Repositories Applications.bazar

Rev

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

Rev 468 Rev 479
Line 58... Line 58...
58
 
58
 
59
		var optionsGoogleMapsv3 = {
59
		var optionsGoogleMapsv3 = {
60
			// On centre la carte sur le languedoc roussillon
60
			// On centre la carte sur le languedoc roussillon
61
			center: new google.maps.LatLng(43.84245116699036, 3.768310546875),
61
			center: new google.maps.LatLng(43.84245116699036, 3.768310546875),
-
 
62
			zoom: 7,
-
 
63
			mapTypeId: "OSM",
-
 
64
			mapTypeControlOptions: {
-
 
65
				mapTypeIds: ["OSM", 
62
			zoom: 7,
66
					google.maps.MapTypeId.ROADMAP,
-
 
67
					google.maps.MapTypeId.HYBRID,
-
 
68
					google.maps.MapTypeId.SATELLITE,
-
 
69
					google.maps.MapTypeId.TERRAIN]
63
			mapTypeId: google.maps.MapTypeId.G_HYBRID_MAP,
70
			},
64
			mapTypeControl: true,
71
			mapTypeControl: true,
65
			scaleControl: true
72
			scaleControl: true
66
		};
73
		};
-
 
74
	    map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
-
 
75
		map.mapTypes.set("OSM", new google.maps.ImageMapType({
-
 
76
 			getTileUrl: function(coord, zoom) {
-
 
77
 				return "http://osm.tela-botanica.org/tile/" + // cache de tuiles avec nginx
-
 
78
 				zoom + "/" + coord.x + "/" + coord.y + ".png";
-
 
79
 			},
-
 
80
 			tileSize: new google.maps.Size(256, 256),
-
 
81
 			isPng: true,
-
 
82
 			alt: "OpenStreetMap",
-
 
83
 			name: "OSM",
-
 
84
			maxZoom: 19
Line 67... Line 85...
67
	    map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
85
		}));
68
 
86
 
69
	    google.maps.event.addListener(map, "click", function(event) {
87
	    google.maps.event.addListener(map, "click", function(event) {
70
			if (marker != null) {
88
			if (marker != null) {
Line 102... Line 120...
102
			' ;
120
			' ;
103
		} 
121
		} 
104
	    $script .= 'geocoder = new google.maps.Geocoder();
122
	    $script .= 'geocoder = new google.maps.Geocoder();
105
	};
123
	};
106
	function showAddress() {
124
	function showAddress() {
107
		var adresse = document.getElementById("bf_adresse").value;
125
        var adresse = document.getElementById("bf_adresse").value;
-
 
126
        if (adresse == "") {
-
 
127
            return false;
-
 
128
        }
108
    	var ville = "";
129
        var ville = "";
109
	  	if (document.getElementById("bf_ville")) {
130
        if (document.getElementById("bf_ville")) {
110
	  		ville = document.getElementById("bf_ville").value ;
131
            ville = document.getElementById("bf_ville").value ;
111
	  	}
132
        }
112
	  	var cp = document.getElementById("bf_cp_lieu_evenement").value ;
133
        var cp = document.getElementById("bf_cp_lieu_evenement").value ;
113
	    var pays;
134
        var pays;
114
	  	if (document.getElementById("liste30")) {
135
        if (document.getElementById("liste30")) {
115
	  		var selectIndex = document.getElementById("liste30").selectedIndex;
136
            var selectIndex = document.getElementById("liste30").selectedIndex;
116
	  		pays = document.getElementById("liste30").options[selectIndex].text ;
137
            pays = document.getElementById("liste30").options[selectIndex].text ;
117
	  	} else {
138
        } else {
118
	  		pays = document.getElementById("bf_pays").value;
139
            pays = document.getElementById("bf_pays").value;
119
	  	}
140
        }
120
	  	var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
141
        var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
121
	  	if (geocoder) {
142
        if (address && geocoder) {
122
	    	geocoder.geocode({
143
            geocoder.geocode({
123
	    		address: address
144
                address: address
124
	    	}, function(result, status) {
145
            }, function(result, status) {
125
	    		 if (status != google.maps.GeocoderStatus.OK) {
146
                 if (status != google.maps.GeocoderStatus.OK) {
126
    				alert(address + " not found");
147
                    alert(address + " not found");
127
			} else {
148
            } else {
128
			marker.setMap(null);
-
 
129
			marker = null;
-
 
130
			//map.setCenter(point, 13);
-
 
131
			map.fitBounds(result[0].geometry.viewport);
149
                map.fitBounds(result[0].geometry.viewport);
132
			marker = new google.maps.Marker({
150
                marker = new google.maps.Marker({
133
				position: result[0].geometry.location,
151
                    position: result[0].geometry.location,
134
				draggable: true,
152
                    draggable: true,
135
				map: map
153
                    map: map
136
				});
154
                });
137
			google.maps.event.addListener(marker, "dragend", function () {
155
                google.maps.event.addListener(marker, "dragend", function () {
138
					coordMarker = marker.getPosition() ;
156
                    coordMarker = marker.getPosition() ;
139
					flat.value = coordMarker.lat();
157
                    flat.value = coordMarker.lat();
140
					flon.value = coordMarker.lng();
158
                    flon.value = coordMarker.lng();
141
				});
159
                });
142
			setLatLonForm(marker);
160
                setLatLonForm(marker);
143
			//marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
161
                //marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
144
		}
162
            }
145
      		});
163
        });
146
  		}
164
    }
147
	}
165
    }
148
	function setLatLonForm(marker) {
166
	function setLatLonForm(marker) {
149
  		coordMarker = marker.getPosition() ;
167
  		coordMarker = marker.getPosition() ;
150
  		flat.value = coordMarker.lat();
168
  		flat.value = coordMarker.lat();
151
  		flon.value = coordMarker.lng();
169
  		flon.value = coordMarker.lng();
152
	}
170
	}