// JavaScript Document// JavaScript Document

$(document).ready(function(){

if(jQuery("#map_canvas").length != 0)
{
		var geocoder;
  		var map;
  		
  		function initialize() {
	    	geocoder = new google.maps.Geocoder();
	    	var latlng = new google.maps.LatLng(-34.397, 150.644);
	    	var myOptions = {
	      		zoom: 12,
	      		center: latlng,
	      		mapTypeId: google.maps.MapTypeId.ROADMAP
	    		}
	    	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  		} 		

		initialize();			
   		codeAddress();  
   		
   		
}


function codeAddress() 
{
    var address = 'Mortel 6a, Roggel';
    var image = new google.maps.MarkerImage('/henklevels.nl/img/beachflag.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(30, 55),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is the base of the flagpole at 0,32.
      new google.maps.Point(15, 55));
  	var shadow = new google.maps.MarkerImage('/henklevels.nl/img/beachflag_shadow.png',
      // The shadow image is larger in the horizontal dimension
      // while the position and offset are the same as for the main image.
      new google.maps.Size(34, 25),
      new google.maps.Point(0,0),
      new google.maps.Point(0, 25));

    
    if (geocoder) 
    {
      	geocoder.geocode( { 'address': address}, function(results, status) 
      	{
        	if (status == google.maps.GeocoderStatus.OK) 
        	{
          		map.setCenter(results[0].geometry.location);
          		var marker = new google.maps.Marker({
              		map: map, 
              		position: results[0].geometry.location,
              		shadow: shadow,
              		icon: image
          		});
        	} 
        	else 
        	{
          		alert("Geocode was not successful for the following reason: " + status);
        	}
      	});
    }
}





});

