PageSourceSearch

https://la-gueriniere.fr/script-googleMap_public

js la-gueriniere.fr collected 2026-10-02 20:02:35 UTC 25,004 bytes, 957 lines download raw bytes

1var infoWindow;
2var emajineMap = function(divmap)
3{
4	this.divmap = divmap;
5	infoWindow = new google.maps.InfoWindow;
6	this.map = new google.maps.Map(document.getElementById(divmap));
7	this.map.setMapTypeId(google.maps.MapTypeId.TERRAIN);
8	this.map.setOptions({zoom:8});
9	this.latlngbounds = new google.maps.LatLngBounds();
10	this.nbMarkers = 0;
11	this.editableMarkers = {};
12	this.infowindows = [];
13	this.pov = null;
14	this.isStreetviewLoaded = false;
15	this.currentEditSpot = null;
16	this.currentEditSpotIsNew = false;
17
18	google.maps.event.addListener(this.map, 'click', function() {
19      infoWindow.close();
20    });
21
22    if (parent.googleMapBindEvents) {
23		parent.googleMapBindEvents(this.map, google);
24    }
25
26	this.onInit();
27};
28
29emajineMap.prototype.onInit = function()
30{
31};
32
33emajineMap.prototype.setInfowindowSize = function(infoWindow)
34{
35	if ($('.googleMapBulle').width() > 100) {
36		// on considère qu'une css est correctement appliquée sinon
37		// on applique une taille par défault
38		return;
39	}
40
41	$('.googleMapBulle, .gm-style-iw').css({
42		'width':'250px',
43		'height':'150px',
44		'overflow-x': 'hidden',
45	});
46};
47
48emajineMap.prototype.setAddLocationIconUrl = function(iconUrl)
49{
50	this.addLocationIconUrl = iconUrl;
51};
52
53emajineMap.prototype.getAddLocationIconUrl = function()
54{
55	return this.addLocationIconUrl;
56};
57
58emajineMap.prototype.setSize = function(width, height)
59{
60	this.width  = width;
61	this.height = height;
62};
63
64emajineMap.prototype.setPov = function(pov)
65{
66	this.pov  = pov;
67};
68
69emajineMap.prototype.setFormUrlSpotAdd = function(formUrl)
70{
71	this.formUrlSpotAdd = formUrl;
72};
73
74emajineMap.prototype.setFormUrlSpotEdit = function(formUrl)
75{
76	this.formUrlSpotEdit = formUrl;
77};
78
79emajineMap.prototype.setMarkerEditable = function(marker, spotId)
80{
81	var self = this;
82
83	self.editableMarkers[spotId.toString()] = marker;
84
85	google.maps.event.addListener(marker, 'click', function(event) {
86		self.editMarker(spotId);
87	});
88
89	if (!self.latlngbounds.contains(marker.getPosition())) {
90		self.latlngbounds.extend(marker.getPosition());
91	}
92};
93
94emajineMap.prototype.editMarker = function(spotId)
95{
96	var self = this;
97	$.getJSON('googlemap-json-' + spotId + '.html', function(data) {
98		self.createFormPoint(self.editableMarkers[spotId.toString()], data, true);
99	});
100};
101
102emajineMap.prototype.reverseGeoCode = function(address)
103{
104	var self = this;
105
106	if (address == '') {
107		if (parent) {
108			parent.simpleAlert("Information", "<div class=\"pb20\">Vous devez renseigner le champ adresse</div>", "fermer");
109		}
110		return;
111	}
112
113	self.geocoder(address, function(results, status) {
114		if (status == google.maps.GeocoderStatus.OK) {
115			self.map.setCenter(results[0].geometry.location);
116			self.map.setZoom(15);
117		} else if (parent) {
118			parent.simpleAlert("Adresse inconnue", address, "fermer");
119		}
120	});
121};
122
123emajineMap.prototype.geocoder = function(address, callback)
124{
125	var geocoder = new google.maps.Geocoder();
126
127	geocoder.geocode({'address': address}, callback );
128};
129
130
131emajineMap.prototype.manualGeoCode = function(callback)
132{
133	this.createFormPoint(this.map.getCenter(), {}, false, callback);
134};
135
136emajineMap.prototype.openMarker = function(marker)
137{
138	var position = marker.getPosition();
139	this.setPoint(position.lat(), position.lng());
140	this.setPointToCoord();
141	google.maps.event.trigger(marker, 'click');
142}
143
144emajineMap.prototype.createFormPoint = function(coordOrMarker, values, isEdit, callback)
145{
146	var self       = this,
147		isPaned    = false,
148		width      = Math.round(this.width * 0.7, 0),
149		infowindow = null;
150
151	// créer ou modifie le point
152	if (isEdit) {
153		var marker = coordOrMarker;
154		var coord  = marker.getPosition();
155		marker.setDraggable(true);
156		marker.setCursor('move');
157	} else {
158		var coord  = coordOrMarker;
159		var	marker = new google.maps.Marker({
160			map: self.map,
161			position: coord,
162			icon: self.getAddLocationIconUrl(),
163			draggable: true,
164			cursor: 'move'
165		});
166	}
167
168	var hidingInfo = google.maps.event.addListener(marker, 'dragstart', function(event) {
169		infowindow.close();
170	});
171
172	var reCenter = google.maps.event.addListener(marker, 'dragend', function(event) {
173		infowindow.open(self.map, marker);
174		self.setInfowindowSize(infowindow);
175	});
176
177	// créer l'infobulle
178	infowindow = new google.maps.InfoWindow({
179			maxWidth: width
180		}),
181		content    =
182		'<div id="contentSpot">' +
183			'<div id="spotMainPanel">' +
184				'<span id="spotIconCurrent" style="float:right"></span>' +
185				'<p>'+
186					'<label for="spotName">Nom :</label>' +
187					'<input id="spotName" type="text">'+
188				'</p>' +
189				'<p>'+
190					'<label for="spotDesc">Description : <a href="#">Édition avancée</a></label>' +
191					'<textarea id="spotDesc" cols="25" rows="3"></textarea>' +
192				'</p>' +
193				'<p class="txtcenter">' +
194					'<a href="#" id="spotBtnValid">Valider</a> ' +
195					'<a href="#" id="spotBtnCancel">Annuler</a>' +
196				'</p>' +
197			'</div>' +
198		'</div>';
199
200
201	// repositionne le point pour faire place à l'infobulle
202	if (!isEdit) {
203		google.maps.event.addListener(this.map, 'center_changed', function()
204		{
205			setTimeout(function() {
206				if (!isPaned) {
207					self.map.panBy(0, -40);
208					isPaned = true;
209				}
210			}, 1000);
211		});
212	}
213
214	// action sur l'infobulle
215	google.maps.event.addListener(infowindow, 'domready', function()
216	{
217		var content     = $('#contentSpot'),
218			nom         = $('#spotName', content),
219			desc        = $('#spotDesc', content),
220			ckeLink     = $('label a', desc.parent()),
221			iconCurrent = $('#spotIconCurrent', content),
222			mainPanel   = $('#spotMainPanel', content),
223			btnValid    = $('#spotBtnValid', content),
224			btnCancel   = $('#spotBtnCancel', content),
225			advanced    = parent.window.jQuery('#marquerIconSelector', parent.window.document),
226			url         = (isEdit) ? self.formUrlSpotEdit : self.formUrlSpotAdd;
227
228		advanced.hide();
229
230		// rempli le formulaire avec les valeurs
231		// sauf l'icone qui est chargée plus loin
232		if (isEdit) {
233			nom.val(values.nom);
234			desc.val(values.description);
235			url = url.replace('{spotId}', values.id);
236		}
237
238		// switch de layer dans l'infobulle
239		var togglePanel = function(type) {
240
241			advanced.toggle();
242
243			if (type == 'icon') {
244				$('#divimarquer', advanced).show();
245				$('#divdescriptionspot', advanced).hide();
246				advanced.addClass('panelIconSelector').removeClass('panelCkEditor');
247			} else if (type == 'cke') {
248				$('#divimarquer', advanced).hide();
249				$('#divdescriptionspot', advanced).show().find('.fck_preview').hide();
250				advanced.addClass('panelCkEditor').removeClass('panelIconSelector');
251			} else {
252
253			}
254
255			return false;
256		};
257
258		// ferme l'infobulle
259		var cancel = function() {
260
261			advanced.hide();
262
263			infowindow.close();
264			infowindow.setMap(null);
265
266			if (isEdit) {
267				marker.setDraggable(false);
268				marker.setCursor('normal');
269				marker.setPosition(coord);
270				self.map.setCenter(coord);
271			} else {
272				marker.setMap(null);
273			}
274
275			self.currentEditSpot = null;
276
277			// appelle la callback si elle existe
278			if (typeof callback == 'function') {
279				callback();
280			}
281
282			return false;
283		};
284
285		// post le formulaire
286		var valid = function() {
287			var inputIcon   = $('#div_imarquer_selector .radio:checked', advanced).val(),
288				inputCustom = $('#custom_imarquer', advanced).val(),
289				coord       = marker.getPosition();
290
291			var data = {
292				'icon': (inputCustom != '') ? inputCustom : inputIcon,
293				'spot': coord.lat() + '|' + coord.lng(),
294				'nom': nom.val(),
295				'descriptionSpot': desc.val()
296			};
297
298			if (data.nom == '') {
299				if (typeof parent.simpleAlert == 'function') {
300					parent.simpleAlert("Information",
301						"Veuillez entrer un nom",
302						"fermer");
303					return false;
304				}
305			} else {
306				// création ou mise à jour de spot
307				$.post(url, data, function() {
308					if (parent && parent.window != window) {
309						var activeLayer = parent.window.jQuery('#iframe_contener', parent.window.document).parent().find('.active_tab a');
310						activeLayer.trigger('click');
311					}
312				});
313				return cancel();
314			}
315		};
316
317		iconCurrent.click(function() { togglePanel('icon'); });
318		ckeLink.click(function() { togglePanel('cke'); });
319		btnValid.click(valid);
320		btnCancel.click(cancel);
321		google.maps.event.addListener(infowindow, 'closeclick', cancel);
322
323		// charge le selecteur d'icon via ajax
324		// see: mods\Emajine_Ressources_Center_Spot::makeForm();
325		advanced.load(url, function()
326		{
327			$('#divspot', advanced).remove();
328			$('#divnom', advanced).remove();
329			$('#divdescriptionspot label', advanced).remove();
330
331			$('a.closeBox', advanced).unbind('click').click(function(e)
332			{
333				e.preventDefault();
334				e.stopPropagation();
335
336				var inputIcon   = $('#div_imarquer_selector .radio:checked', advanced),
337					inputCustom = $('#custom_imarquer', advanced);
338
339				if (inputCustom.val() != '') {
340					var icon = inputCustom.parent().find('.icon img').first();
341				} else {
342					var icon = inputIcon.parent().find('img');
343				}
344
345				iconCurrent.children().remove();
346				iconCurrent.append(icon.clone());
347
348				parent.window.CKEDITOR.instances['descriptionspot'].updateElement();
349				desc.val($('#descriptionspot', advanced).val());
350
351				togglePanel();
352			}).appendTo($('a.closeBox', advanced).closest('.wrap'));
353
354			var antiDoubleAction = true;
355
356			$('.pin', advanced).click(function() {
357				if (!antiDoubleAction) {
358					$('.delete', advanced).trigger('click');
359					$('a.closeBox', advanced).trigger('click');
360				}
361				antiDoubleAction = ! antiDoubleAction;
362			});
363
364			var c = $('div.formw', advanced).children();
365			iconCurrent.append(c.first().find('img').clone());
366			c.first().remove();
367			c.show();
368		});
369	});
370
371	// centre la carte sur le point et affiche l'infobulle (et masque les autres)
372	self.closeAllInfowindow();
373	self.map.setCenter(coord);
374	infowindow.setContent(content);
375	infowindow.open(this.map, marker);
376	self.infowindows.push(infowindow);
377	self.setInfowindowSize(infowindow);
378
379	// supprime l'edition précédante non validée si il y en a une
380	if (self.currentEditSpot != null && self.currentEditSpotIsNew) {
381		// supprime le spot précédent
382		self.currentEditSpot.setMap(null);
383	}
384
385	// enregistre l'édition courante
386	self.currentEditSpot = marker;
387	self.currentEditSpotIsNew = !isEdit;
388};
389
390emajineMap.prototype.setNewMarkerPosition = function(event, url)
391{
392	var position = event.latLng;
393	url += '&lat=' + position.lat() + '&lng=' + position.lng();
394	$.get(url);
395}
396
397emajineMap.prototype.closeAllInfowindow = function()
398{
399	var i;
400	for (i in this.infowindows) {
401		if (this.infowindows[i]) {
402			this.infowindows[i].close();
403			this.infowindows[i].setMap(null);
404			this.infowindows[i] = null;
405		}
406	}
407};
408
409// initialise les points du centre
410emajineMap.prototype.setPoint = function(latitude, longitude)
411{
412	this.point = new google.maps.LatLng(latitude, longitude);
413	// le centre de la carte (qui n'est pas un spot,
414	// ne doit pas être utiliser pour centrer sur les spots)
415	//this.latlngbounds.extend(this.point);
416};
417
418emajineMap.prototype.setPointToUserLocation = function()
419{
420	var self = this;
421	if(navigator.geolocation) {
422		navigator.geolocation.getCurrentPosition(function(position) {
423			self.setPoint(position.coords.latitude, position.coords.longitude);
424			self.setPointToCoord();
425		}, function() {
426			// no geolocatisation
427		});
428	} else {
429		// no geolocatisation
430	}
431};
432
433emajineMap.prototype.setPointToCoord = function()
434{
435	this.setCenter();
436};
437
438emajineMap.prototype.setPointToSpot = function()
439{
440	this.setCenter(true);
441};
442
443// initialise le zoom
444emajineMap.prototype.setZoom = function(zoom)
445{
446	this.zoom = zoom;
447	this.map.setOptions({zoom: zoom});
448};
449
450// creation du point centrale
451emajineMap.prototype.setCenter = function(ignorePoint)
452{
453	if (ignorePoint || typeof this.point === 'undefined') {
454		if (this.nbMarkers < 2) {
455			this.map.setCenter(this.latlngbounds.getCenter(), this.zoom ? this.zoom : 1);
456		} else {
457			var maxZoom = this.map.getZoom();
458			this.map.fitBounds(this.latlngbounds);
459			// si tous les marqueurs sont trop proche le niveau de zoom de la carte est
460			// considéré comme le niveau de zoom maximum.
461			if (this.map.getZoom() > maxZoom) {
462				this.map.setZoom(maxZoom);
463			}
464		}
465	} else {
466		this.map.setCenter(this.point, this.zoom ? this.zoom : 8);
467	}
468};
469
470emajineMap.prototype.setType = function(type) {
471	this.map.setMapTypeId(type);
472};
473
474emajineMap.prototype.setStreetview = function(callback) {
475
476	if (this.isStreetviewLoaded) {
477		this.map.getStreetView().setVisible(true);
478		if (callback) callback(true);
479		return;
480	}
481
482	var self     = this;
483		zoom     = this.map.getZoom(),
484		stview   = new google.maps.StreetViewService(),
485		pano     = this.map.getStreetView(),
486		status   = null;
487
488	this.isStreetviewLoaded = true;
489
490	stview.getPanoramaByLocation(this.map.getCenter(), 50, function(panoInfo, status)
491	{
492		if (status == google.maps.StreetViewStatus.OK) {
493			pano.setPosition(panoInfo.location.latLng);
494			pano.setZoom((zoom >= 1 && zoom <= 5) ? zoom : 3);
495			var	pov = self.pov.split('|');
496			pano.setPov({heading:parseFloat(pov[0], 10), pitch:parseFloat(pov[1], 10)});
497			pano.setVisible(true);
498			if (callback) callback(true);
499			google.maps.event.addListener(pano, 'closeclick', function() {
500				self.setZoom(23);
501			});
502		} else {
503			self.isStreetviewLoaded = false;
504			if (parent.alertStreetViewImpossible) {
505				parent.alertStreetViewImpossible();
506	  		}
507			if (callback) callback(false);
508		}
509	});
510};
511
512// Fixe les controles
513// @deprecated
514emajineMap.prototype.setControl = function(control)
515{
516	return false;
517};
518
519emajineMap.prototype.setZoomControl = function(control)
520{
521	var options = {};
522	options.zoomControl = true;
523	this.map.setOptions(options);
524};
525
526emajineMap.prototype.setOptions = function(options)
527{
528	this.map.setOptions(options);
529};
530
531emajineMap.prototype.setGoogleBar = function(bool)
532{
533	// Déprécié et supprimé en e-majine 1.9
534};
535
536emajineMap.prototype.setDefaultControl = function()
537{
538	this.map.setOptions({keyboardShortcuts: true});
539};
540
541emajineMap.prototype.addTrafficLayer = function()
542{
543	this.trafficLayer = new google.maps.TrafficLayer();
544	this.trafficLayer.setMap(this.map);
545};
546
547emajineMap.prototype.addTransitLayer = function()
548{
549	this.transitLayer = new google.maps.TransitLayer();
550	this.transitLayer.setMap(this.map);
551};
552
553emajineMap.prototype.addWeatherLayer = function()
554{
555	// supprimé en API 3.22
556};
557
558emajineMap.prototype.addBikeLayer = function()
559{
560	this.bikeLayer = new google.maps.BicyclingLayer();
561	this.bikeLayer.setMap(this.map);
562};
563
564emajineMap.prototype.addKmlLayer = function(file)
565{
566	this.kmlLayer = new google.maps.KmlLayer({url: file});
567	this.kmlLayer.setMap(this.map);
568};
569
570emajineMap.prototype.switchKmlLayer = function(file)
571{
572	if (this.kmlLayer) {
573		this.kmlLayer.setMap(null);
574		this.kmlLayer = null;
575	}
576	this.addKmlLayer(file);
577}
578
579/******************************************************************************
580 * LIVE *
581******************************************************************************/
582
583emajineMap.prototype.liveMapMode = function(value, callback)
584{
585	if (value == 'GM_MapMode_Street') {
586		this.setStreetview(callback);
587	} else {
588		this.map.getStreetView().setVisible(false);
589	}
590};
591
592emajineMap.prototype.liveType = function(value)
593{
594	switch(value) {
595		case 'GM_Map_Normal'    : this.map.setMapTypeId(google.maps.MapTypeId.ROADMAP);   break;
596		case 'GM_Map_Hybrid'    : this.map.setMapTypeId(google.maps.MapTypeId.HYBRID);    break;
597		case 'GM_Map_Satellite' : this.map.setMapTypeId(google.maps.MapTypeId.SATELLITE); break;
598		case 'GM_Map_Physical'  : this.map.setMapTypeId(google.maps.MapTypeId.TERRAIN);   break;
599	}
600};
601
602emajineMap.prototype.liveCenter = function(value)
603{
604	switch (value) {
605		case 'GM_MapCenter_Spot'  : this.setPointToSpot();         break;
606		case 'GM_MapCenter_User'  : this.setPointToUserLocation(); break;
607		case 'GM_MapCenter_Coord' : this.setPointToCoord();        break;
608	}
609};
610
611emajineMap.prototype.liveZoom = function(value)
612{
613	this.map.setZoom(parseInt(value, 10));
614};
615
616emajineMap.prototype.liveStreetviewControl = function(value)
617{
618	this.map.setOptions({'streetViewControl': value});
619};
620
621emajineMap.prototype.liveZoomControl = function(value)
622{
623	// Supprimé en API 3.22
624};
625
626emajineMap.prototype.livePanControl = function(value)
627{
628	// Supprimé en API 3.22
629};
630
631emajineMap.prototype.liveScaleControl = function(value)
632{
633	this.map.setOptions({'scaleControl': value});
634};
635
636emajineMap.prototype.liveMapTypeControl = function(value)
637{
638	switch(value) {
639		case 'GM_MapTypeControl_Default'       : value = google.maps.MapTypeControlStyle.DEFAULT;        break;
640		case 'GM_MapTypeControl_DropDownMenu'  : value = google.maps.MapTypeControlStyle.DROPDOWN_MENU;  break;
641		case 'GM_MapTypeControl_HorizontalBar' : value = google.maps.MapTypeControlStyle.HORIZONTAL_BAR; break;
642	}
643	this.map.setOptions({'mapTypeControlOptions': {'style': value}});
644};
645
646emajineMap.prototype.liveOverviewControl = function(value)
647{
648	// Supprimé en API 3.22
649};
650
651emajineMap.prototype.liveTraficLayer = function(value)
652{
653	if (value) {
654		this.addTrafficLayer();
655	} else {
656		this.trafficLayer.setMap(null);
657	}
658};
659
660emajineMap.prototype.liveBuswayLayer = function(value)
661{
662	if (value) {
663		this.addTransitLayer();
664	} else {
665		this.transitLayer.setMap(null);
666	}
667};
668
669emajineMap.prototype.liveMeteoLayer = function(value)
670{
671	// Supprimé en API 3.22
672};
673
674emajineMap.prototype.liveBicycleLayer = function(value)
675{
676	if (value) {
677		this.addBikeLayer();
678	} else {
679		this.bikeLayer.setMap(null);
680	}
681};
682
683emajineMap.prototype.liveKmlLayer = function(value)
684{
685	if (!value) {
686		this.kmlLayer.setMap(null);
687		this.kmlLayer = null;
688	}
689};
690/******************************************************************************/
691
692
693//initialisation de l'image du marker
694emajineMap.prototype.setIcon = function(icon)
695{
696	this.tinyIcon = false;
697	if (icon) {
698		this.tinyIcon = {};
699		this.tinyIcon.url = icon;
700	}
701};
702
703// Creation d'un point
704emajineMap.prototype.getMarker = function (latitude, longitude, icon)
705{
706	var marker = new google.maps.Marker();
707	marker.setMap(this.map);
708	if (this.tinyIcon) {
709		marker.setIcon(this.tinyIcon);
710	}
711	if (icon !== '') {
712		marker.setIcon(icon);
713	}
714
715	latitude  = parseFloat(latitude);
716	longitude = parseFloat(longitude);
717
718	if (!isNaN(latitude) && !isNaN(longitude)) {
719		var point = new google.maps.LatLng(latitude, longitude);
720		marker.setPosition(point);
721		if (!this.latlngbounds.contains(point)) {
722			this.latlngbounds.extend(point);
723		}
724	}
725	return marker;
726};
727
728//Decrepated
729emajineMap.prototype.getLabeledMarker = function (latitude,longitude,label)
730{
731	var point = new google.maps.LatLng(latitude, longitude);
732	if (!this.latlngbounds.contains(point)) {
733		this.latlngbounds.extend(point);
734	}
735	return new StyledMarker({styleIcon: new StyledIcon(StyledIconTypes.MARKER,{text:label}), position: point, map: this.map, icon: this.tinyIcon});
736};
737
738//Ajout du layer sur le marker (infobulle)
739emajineMap.prototype.setMarker = function (marker,url) {
740	var self = this;
741	if(url) {
742		google.maps.event.addListener(marker, "click", function () {
743			marker = this;
744			var coord = marker.getPosition();
745			infoWindow.setContent('<div id="gMapWindowContent" class="googleMapBulle">Please wait...</div>');
746			infoWindow.open(this.map, marker);
747			google.maps.event.clearListeners(infoWindow, 'domready');
748			google.maps.event.addListener(infoWindow, 'domready', function() {
749				displayFileContent(url, 'gMapWindowContent', function() {
750					self.setInfowindowSize(infoWindow);
751				});
752			});
753		});
754	}
755	if (!this.latlngbounds.contains(marker.getPosition())) {
756		this.latlngbounds.extend(marker.getPosition());
757	}
758	this.nbMarkers ++;
759};
760
761// layer pour afficher les coordonnées.
762emajineMap.prototype.afficheCoord = function (marker){
763	var coord = marker.getLatLng();
764	var coord1 = coord.lat();
765	var coord2 = coord.lng();
766	var info = '<span style="font-size:small;"><strong>Coordonnées :</strong> <br />Latitude : '+coord1+'<br />Longitude : '+coord2+'</span>';
767	infoWindow.setContent(info);
768	infoWindow.open(this.map, marker);
769	self.setInfowindowSize(infoWindow);
770};
771
772//Itineraire :
773emajineMap.prototype.getDirection = function (divdirection)
774{
775	document.getElementById(divdirection).innerHTML = '';
776	this.gdir = new google.maps.DirectionsService();
777	this.directionsDisplay = new google.maps.DirectionsRenderer({
778		'map': this.map,
779		'preserveViewport': true,
780		'draggable': true
781    });
782	this.directionsDisplay.setPanel(document.getElementById(divdirection));
783
784	var directionsDisplay = this.directionsDisplay;
785	google.maps.event.addListener(this.directionsDisplay, 'directions_changed',
786		function() {
787			currentDirections = directionsDisplay.getDirections();
788	});
789
790};
791
792emajineMap.prototype.setDirections = function (fromAddress, toAddress, locale)
793{
794    var request = {
795        origin: fromAddress,
796        destination: toAddress,
797        travelMode: google.maps.DirectionsTravelMode.DRIVING
798    };
799    var direction = this.directionsDisplay;
800    var map = this.map;
801    this.gdir.route(request, function(response, status) {
802		if (status == google.maps.DirectionsStatus.OK) {
803			direction.setDirections(response);
804			map.fitBounds(response.routes[0].bounds);
805		}
806    });
807};
808
809emajineMap.prototype.loadJsonSpots = function(url)
810{
811	var latlngbounds = this.latlngbounds;
812	var defaultZoomLevel = this.zoom ? this.zoom : 1;
813	var emajineMap = this;
814	var map = this.map;
815	var centerPoint = this.point;
816	var nbSpot = this.nbMarkers
817	$.get(url, function(datas) {
818		datas = eval(datas);
819		var len = datas.length;
820		if (len>0) {
821			for (var i = 0; i < len;i++) {
822				if (typeof datas[i] != 'undefined') {
823					emajineMap.setIcon(datas[i].icon);
824					var m = emajineMap.getMarker(datas[i].latitude, datas[i].longitude, datas[i].icon);
825					emajineMap.setMarker(m, datas[i].uri);
826					nbSpot ++;
827				}
828			}
829		}
830		emajineMap.setPointToSpot();
831		return;
832	});
833};
834
835var map, fieldId, mod, fieldHidden, fieldHtml, defCoord, _coord, _info, marker, mapOptions;
836function loadFieldMap(fieldID, mode)
837{
838	fieldId = fieldID;
839	mod = mode;
840	fieldHidden = document.getElementById(fieldId + 'idhidden');
841	fieldHtml = document.getElementById(fieldId+'span');
842	defCoord = document.getElementById(fieldId+'idhidden').value;
843	_coord='';// coordonnées sous la forme "latitude|longitude"
844	_info='';//  coordonnées sous la forme "Latitude : latitude Longitude : longitude"
845	mapOptions=new Array();
846
847	if (mod=='address') {
848		initGeocoder(fieldId);
849	} else if(mod=='map') {
850		initMap(defCoord);
851	} else {
852		initMap(defCoord);
853		initGeocoder(fieldId, map);
854	}
855	mapOptions["map"]= map;
856	return mapOptions;
857}
858function initGeocoder(fieldId, map)
859{
860	var geo = document.getElementById("search" + fieldId);
861	geo.onclick = function()
862	{
863		var geocoder = new google.maps.Geocoder();
864		var address = document.getElementById("adresse" + fieldId).value;
865		if (address != '') {
866			geocoder.geocode({'address': address}, function(results, status) {
867				if (status == google.maps.GeocoderStatus.OK) {
868					updateCoord(results[0].geometry.location);
869					if (typeof map !== 'undefined') {
870						initMarker(results[0].geometry.location);
871					}
872				} else {
873					alert(address + " _not_found_");
874				}
875			});
876		}else{
877			alert("_vous_devez_renseigner_le_champ_adresse_");
878			document.getElementById("adresse" + fieldId).focus();
879		}
880	}
881}
882function updateCoord(location)
883{
884	var lat = location.lat();
885	var lng = location.lng();
886	_coord = lat + '|' + lng;
887	_info = "Latitude"+' : '+lat+" Longitude"+' : '+lng;
888	updateFieldsMap(_coord, _info)
889}
890
891function displayFileContent(url, divID, onLoaded)
892{
893	$.get(url, function(data) {
894		$('#' + divID).html(data);
895		if (typeof onLoaded == 'function') {
896			onLoaded();
897		}
898	});
899}
900function updateFieldsMap(coordhidden, coordhtml)
901{
902	if(fieldHidden) fieldHidden.value=coordhidden;
903	if(fieldHtml) fieldHtml.innerHTML=coordhtml;
904}
905
906function initMap(defCoord)
907{
908	map = new google.maps.Map(document.getElementById("map" + fieldId));
909	if(defCoord){
910		defCoord = defCoord.split('|');
911		var defPt = new google.maps.LatLng(defCoord[0], defCoord[1]);
912		updateCoord(defPt);
913		initMarker(defPt);
914	}else{
915		//fixe le centre de la carte sur Paris
916		map.setCenter(new google.maps.LatLng(46.80851951372989, 2.180614471435547), 5);
917	}
918
919	map.setZoom(5);
920	map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
921
922	//affiche la barre latérale de navigation et le button [plan|satellite|mixte]
923	var options = {};
924	options.zoomControl           = true;
925	options.zoomControlOptions    = {style: google.maps.ZoomControlStyle.DEFAULT};
926	options.mapTypeControl        = true;
927	options.mapTypeControlOptions = {style: google.maps.MapTypeControlStyle.DEFAULT};
928	options.keyboardShortcuts     = true;
929	map.setOptions(options);
930
931	google.maps.event.addListener(map, "click", function(point) {
932		updateCoord(point.latLng);
933		initMarker(point.latLng);
934	});
935}
936
937function initMarker(location)
938{
939	map.setCenter(location);
940	if (typeof marker !== 'undefined') {
941		marker.setMap(null);
942	}
943	marker = new google.maps.Marker({
944		map: map,
945		draggable: true,
946		position: location
947	});
948	google.maps.event.addListener(marker, 'dragend', function() {
949		updateCoord(marker.getPosition());
950		map.setCenter(marker.getPosition());
951	});
952}
953
954function initGmapContentIziMedia()
955{
956	checkboxBeautiful();
957}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.