var map;
var bounds = new GLatLngBounds(0,0); 
var woudloper_x = "52.723629";
var woudloper_y = "5.763896";

function gMapLaden() {
  if (GBrowserIsCompatible()) {
	  
	var linksboven = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,10));
    var rechtsboven = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
	var positie_lmc = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,40));	
	var positie_mtc = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));	  
	  
	map = new GMap2(document.getElementById("map"), { mapTypes: [G_SATELLITE_MAP,G_NORMAL_MAP] });
	map.removeMapType(G_HYBRID_MAP);
	//map.removeMapType(G_SATELLITE_MAP);
	map.addMapType(G_SATELLITE_3D_MAP);	
	
	var mtc = map.addControl(new GMenuMapTypeControl(),positie_mtc);
	
	map.addControl(new GSmallMapControl());
	var point = new GLatLng(parseFloat(woudloper_x),parseFloat(woudloper_y));
	map.setCenter(point,10);
	var marker = createMarker(point);
	map.addOverlay(marker);
	//map.panTo(point,14);
	
	markersInDeBuurt();
	
  }
}

function createMarker(point) {
  var icon = new GIcon();
  icon.image = "/img/ico/ico-woudloper.png";
  icon.iconSize = new GSize(93,91);	
  icon.iconAnchor = new GPoint(20,91)
  icon.infoWindowAnchor = new GPoint(45,45);
  var infovenster = new GMarker(point, {icon: icon, draggable: false } );
  
  GEvent.addListener(infovenster, "click", function() {										 

  });

  return infovenster;
  
}

function markersInDeBuurt() {
  var in_de_buurt = [
  { "lbl":"Brennels Buiten","gx":52.682262,"gy":5.873995 },
  { "lbl":"Poldertoren","gx":52.710208,"gy":5.750978 },
  { "lbl":"Bosbad","gx":52.716612,"gy":5.754948 },
  { "lbl":"Kinderboerderij Emmelerbos","gx":52.722388,"gy":5.757394 },
  { "lbl":"Schokland Museum","gx":52.634886,"gy":5.777392 }
  ];
  
  for (i=0;i<in_de_buurt.length;i++) {
    var lbl = in_de_buurt[i].lbl;
	var gx = parseFloat(in_de_buurt[i].gx);
	var gy = parseFloat(in_de_buurt[i].gy);
	var point = new GLatLng(gx,gy);
	
	var buurt_marker = createInDeBuurtMarkers(point,lbl);
	map.addOverlay(buurt_marker);
	
  }
}
  
function createInDeBuurtMarkers(point,lbl) {
	
  var icon = new GIcon();
  icon.image = "/img/ico/ico-in-de-buurt.png";
  icon.iconSize = new GSize(12,12);	
  icon.iconAnchor = new GPoint(6,6)
  icon.infoWindowAnchor = new GPoint(6,12);
  var infovenster = new GMarker(point, {icon: icon, draggable: false, title: lbl, clickable:false } );
  return infovenster;
  
}  
  

