var map = null;
var geo = null;
var address = null;
var marker =null;
var newmarker=null ;

function MyMapInitialize(mapname, lat, lng, zoom) {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById(mapname));
    map.setCenter(new GLatLng(lat, lng), zoom);
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
	geocoder = new GClientGeocoder();
} }
function MyMapTerminate() {GUnload();}

function setMarker(point, address){
	var newmarker = new GMarker(point);
	GEvent.addListener(newmarker, "click", function() {newmarker.openInfoWindowHtml(address);});
	GEvent.addListener(newmarker, "dblclick", function() {map.removeOverlay(newmarker)});
	map.addOverlay(newmarker);
	//window.setTimeout(function() { map.removeOverlay(newmarker) }, 65000);
}
function MyMapAddMarker(lat, lng, markertype, info)
{
  var newmarker = new GMarker(new GLatLng(lat, lng), markertype);
  GEvent.addListener(newmarker, "click", function() {newmarker.openInfoWindowHtml(info);});
  map.addOverlay(newmarker);
  return newmarker;
}
function removeMarker(marker) { removeOverlay(marker);}
function MyMapRemoveMarker(newmarker) {map.removeOverlay(newmarker);}

function showAddress(address){
  document.getElementById("msgcoord").innerHTML = address.toString();
  if (geocoder) {
    geocoder.getLatLng (
      address,
      function(point) {
        if (!point) { alert(address + ". Adresse non trouvée"); } 
		else { address.marker = setMarker(point,address); }
} ) } }

function showAdr2(address, lat, lng){
 var point = new GLatLng(lat, lng);
 address.marker = setMarker(point,address)
}
	


