function MyApplication() {

var map = new GMap2(document.getElementById("map"));
// Création de la carte en utilisant les nouveaux outils
map.addMapType(G_PHYSICAL_MAP);
var mapControl = new GHierarchicalMapTypeControl();

// Configuration des relations Type Controle
mapControl.clearRelationships();
mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Plus de d"+String.fromCharCode(233)+"tails", false);
map.addControl(mapControl); // Affichage des contrôles

map.setCenter(new GLatLng(49.013088, 5.371281), 8);
var x = document.getElementById("souszone");
if(x){
lat = parseFloat(x.value.split(",")[0]);
lng = parseFloat(x.value.split(",")[1]);
scale = parseInt(x.value.split(",")[2]);
map.setCenter(new GLatLng(lat,lng),scale);
}else{
map.setCenter(new GLatLng(49.013088,5.371281), 8);
}

map.addControl(new GSmallZoomControl()); // autres curseurs GSmallControl GLargeControl
new GKeyboardHandler(map);
map.enableContinuousZoom();
map.enableDoubleClickZoom(); // Zoom avec double-clic
map.enableScrollWheelZoom(); // Zoom avec la molette de la souris

// Restriction du Zoom (minimum et maximum)
var mt = map.getMapTypes();
for (var i=0; i<mt.length; i++) {
mt[i].getMinimumResolution = function() {return 8;}
mt[i].getMaximumResolution = function() {return 16;}
}

// écouteur Mouvement pour restriction de la carte
GEvent.addListener(map, "move", function() {
checkBounds();
});
	// limites de la carte (centre)
var allowedBounds = new GLatLngBounds(new GLatLng(48.451277,4.835861), new GLatLng(49.630375,5.88658));
	// si la position de la carte est en dehors de la zone définie, blocage
	function checkBounds() {
		if (allowedBounds.contains(map.getCenter())) {
		return;
		}
	var C = map.getCenter();
	var X = C.lng();
	var Y = C.lat();
	var AmaxX = allowedBounds.getNorthEast().lng();
	var AmaxY = allowedBounds.getNorthEast().lat();
	var AminX = allowedBounds.getSouthWest().lng();
	var AminY = allowedBounds.getSouthWest().lat();
	if (X < AminX) {X = AminX;}
	if (X > AmaxX) {X = AmaxX;}
	if (Y < AminY) {Y = AminY;}
	if (Y > AmaxY) {Y = AmaxY;}
	//alert ("Restriction "+Y+" "+X);
	map.setCenter(new GLatLng(Y,X));
	}


var point = new GLatLng(lat, lng);

var marker = new GMarker(point, {icon:G_DEFAULT_ICON, draggable: true}); 
map.addOverlay(marker);
marker.enableDragging();

GEvent.addListener(marker, "drag", function(){
document.getElementById("localisation").value=marker.getPoint().toUrlValue();
});


}

function initialize() {
if (GBrowserIsCompatible()) {
var application = new MyApplication();
}else{
alert("DÃ©solÃ©, Google Maps n'est pas compatible avec votre navigateur.");
}
}

