﻿// JScript File

    //<![CDATA[
   
    var map;
    var geocoder = new GClientGeocoder();
    	
	geocoder.setBaseCountryCode('uk');
	
    function load() {
      if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		//map.addControl(new GMapTypeControl());
		map.enableContinuousZoom();
		map.enableScrollWheelZoom();
		map.setCenter(new GLatLng('51.573015','0.683727'),13);
      }
    }
    
	
	function addMarkerByLtLg(lt,lg,info)
	{
	    var marker = new GMarker(new GLatLng(lt,lg));
	    marker.bindInfoWindow("<div style='height:110px;'>" + info + "</div>");
	    map.addOverlay(marker);
	}
		
	
     function addAddressToMap(response) {
         if (!response || response.Status.code != 200) {
         geocoder_response = false;
         alert("Sorry, we were unable to geocode that address");
         } else {
         geocoder_response = true;
         place = response.Placemark[0];
         point = new GLatLng(place.Point.coordinates[1],
         place.Point.coordinates[0]);
         marker = new GMarker(point);
         marker.bindInfoWindow(place.address + '<br>' +
         '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode + "<br /><br />");
         map.addOverlay(marker);
         }
     }

     function showLocation(address, info) 
     {
        geocoder.getLocations(address, addAddressToMap);
     }
	
	
	function addMarker(address,info) {
	    
        geocoder.getLatLng(
            address,
            function(point) {
              if (point) {
	            var marker = new GMarker(point);
	            marker.bindInfoWindow(info);
	            map.addOverlay(marker);
                }
            }
        );
	}
	
	
    function listener()
    {
        GEvent.addListener(map, "click", function(marker, point) {
            if (marker.openInfoWindowHtml) {
	            marker.openInfoWindowHtml("Displays info here");
            }
        });
    }
    
    //]]>