Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1215 Rev 1216
Line 167... Line 167...
167
//+----------------------------------------------------------------------------------------------------------+
167
//+----------------------------------------------------------------------------------------------------------+
168
// GOOGLE MAP
168
// GOOGLE MAP
169
var map;
169
var map;
170
var marker;
170
var marker;
171
var latLng;
171
var latLng;
-
 
172
var geocoder;
-
 
173
 
-
 
174
$(document).ready(function() {
-
 
175
	initialiserGoogleMap();
-
 
176
	
-
 
177
	// Autocompletion du champ adresse
-
 
178
	$("#carte-recherche").autocomplete({
-
 
179
		//Cette partie utilise geocoder pour extraire des valeurs d'adresse
-
 
180
		source: function(request, response) {
-
 
181
			
-
 
182
			geocoder.geocode( {'address': request.term+', France', 'region' : 'fr' }, function(results, status) {
-
 
183
				if (status == google.maps.GeocoderStatus.OK) {
-
 
184
					response($.map(results, function(item) {
-
 
185
						var retour = {
-
 
186
							label: item.formatted_address,
-
 
187
							value: item.formatted_address,
-
 
188
							latitude: item.geometry.location.lat(),
-
 
189
							longitude: item.geometry.location.lng()
-
 
190
						};
-
 
191
						return retour;
-
 
192
					}));
-
 
193
				} else {
-
 
194
					afficherErreurGoogleMap(status);
-
 
195
				}
-
 
196
			});
-
 
197
		},
-
 
198
		// Cette partie est executee a la selection d'une adresse
-
 
199
		select: function(event, ui) {
-
 
200
			var latLng = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);
-
 
201
			deplacerMarker(latLng);
-
 
202
		}
-
 
203
	});
-
 
204
	
-
 
205
	$("#geolocaliser").click(function() {
-
 
206
		var latitude = $('#latitude').val();
-
 
207
		var longitude = $('#longitude').val();
-
 
208
		latLng = new google.maps.LatLng(latitude, longitude);
-
 
209
		deplacerMarker(latLng);
-
 
210
	});
-
 
211
	
-
 
212
	google.maps.event.addListener(marker, 'dragend', function() {
-
 
213
		trouverCommune(marker.getPosition());
-
 
214
		mettreAJourMarkerPosition(marker.getPosition());
-
 
215
	});
-
 
216
	
-
 
217
	google.maps.event.addListener(map, 'click', function(event) {
-
 
218
		deplacerMarker(event.latLng);
-
 
219
	});
-
 
220
});
Line 172... Line 221...
172
 
221
 
173
function initialiserGoogleMap(){
222
function initialiserGoogleMap(){
174
	// Carte
223
	// Carte
Line 197... Line 246...
197
	
246
	
198
	// Création de la carte Google
247
	// Création de la carte Google
199
	map = new google.maps.Map(document.getElementById('map-canvas'), options); //affiche la google map dans la div map_canvas
248
	map = new google.maps.Map(document.getElementById('map-canvas'), options); //affiche la google map dans la div map_canvas
Line -... Line 249...
-
 
249
	map.mapTypes.set('OSM', osmMapType);
-
 
250
	
-
 
251
	// Création du Geocoder
200
	map.mapTypes.set('OSM', osmMapType);
252
	geocoder = new google.maps.Geocoder();
201
	
253
	
202
	// Marqueur google draggable
254
	// Marqueur google draggable
203
	marker = new google.maps.Marker({
255
	marker = new google.maps.Marker({
204
		map: map,
256
		map: map,
Line 219... Line 271...
219
			deplacerMarker(latLng);
271
			deplacerMarker(latLng);
220
		});
272
		});
221
	}
273
	}
222
}
274
}
Line 223... Line -...
223
 
-
 
224
$(document).ready(function() {
-
 
225
	
-
 
226
	initialiserGoogleMap();
-
 
227
	
-
 
228
	$("#geolocaliser").click(function() {
-
 
229
		var latitude = $('#latitude').val();
-
 
230
		var longitude = $('#longitude').val();
-
 
231
		latLng = new google.maps.LatLng(latitude, longitude);
-
 
232
		deplacerMarker(latLng);
-
 
233
	});
-
 
234
	
-
 
235
	google.maps.event.addListener(marker, 'dragend', function() {
-
 
236
		trouverCommune(marker.getPosition());
-
 
237
		mettreAJourMarkerPosition(marker.getPosition());
-
 
238
	});
-
 
239
	
-
 
240
	google.maps.event.addListener(map, 'click', function(event) {
-
 
241
		deplacerMarker(event.latLng);
-
 
242
	});
-
 
243
});
-
 
244
 
275
 
245
function deplacerMarker(latLng) {
276
function deplacerMarker(latLng) {
246
	if (marker != undefined) {
277
	if (marker != undefined) {
247
		marker.setPosition(latLng);
278
		marker.setPosition(latLng);
248
		map.setCenter(latLng);
279
		map.setCenter(latLng);