

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(50.384764,-4.083824),10);
		
		
		function myRedraw() {

map.removeOverlay(polygon2);

		bounds = map.getBounds();

		southWest = bounds.getSouthWest();
		northEast = bounds.getNorthEast();
		lngSpan = northEast.lng() - southWest.lng();
        latSpan = northEast.lat() - southWest.lat();
		polygon2 = new GPolygon([
		new GLatLng(southWest.lat(), southWest.lng()),
		new GLatLng(southWest.lat() + latSpan, southWest.lng()),
		new GLatLng(southWest.lat() + latSpan, southWest.lng() + lngSpan ),
		new GLatLng(southWest.lat(), southWest.lng() + lngSpan),
    new GLatLng(50.461759, -4.280891),
    new GLatLng(50.461759, -3.80577),
    new GLatLng(50.30397513777613, -3.80577),
    new GLatLng(50.30397513777613, -4.280891),
    new GLatLng(50.461759, -4.280891),
		new GLatLng(southWest.lat(), southWest.lng() + lngSpan),
		new GLatLng(southWest.lat(), southWest.lng())
], "#f33f00", 0, 1, "#F4792B", 0.3);		
map.addOverlay(polygon2);
}

		
	
 	GEvent.addListener(map, "moveend", function() {
    myRedraw();
  } );
 GEvent.addListener(map, "zoomend", function() {
    myRedraw();
  }  	);
		
		
		
		map.setMapType(G_NORMAL_MAP);
        //map.setUIToDefault();
		map.addControl(new GSmallMapControl());
 // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon(G_DEFAULT_ICON);
        baseIcon.shadow = "img/mappins/shadow.png";
        baseIcon.iconSize = new GSize(32, 32);
        baseIcon.shadowSize = new GSize(50, 32);
        baseIcon.iconAnchor = new GPoint(16, 16);
        baseIcon.infoWindowAnchor = new GPoint(27, 5);
		baseIcon.imageMap = [0,0, 32,0 , 32,32 ,0,32];
		
		 function createMarker(point, pin, description) {
		var Icon = new GIcon(baseIcon);
		Icon.image = "img/mappins/" + pin + ".png";
		markerOptions = { icon:Icon };
        var marker = new GMarker(point, markerOptions);
		
		GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(description);
			//myRedraw();
          });
          return marker;
		}
		
		 var latlng = new GLatLng(50.387322,-4.022265);
		 var pin = "green";
		 var des = "<h3 class='logo'>Com'Pass</h3><div class='mapaddress'><h3>Com'Pass Driving School</h3><br />24 Branson Court<br />Plympton<br />Plymouth<br />PL7 2WU<br /><b>Tel:</b> 01752 339922<br /><b>Email:</b> <a href='info@compassdrivingschool.co.uk'>info@compassdrivingschool.co.uk</a> </div> ";
		map.addOverlay(createMarker(latlng, pin, des));


			var bounds = map.getBounds();

		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
		var polygon2 = new GPolygon([
    new GLatLng(southWest.lat(), southWest.lng()),
    new GLatLng(southWest.lat() + latSpan, southWest.lng()),
    new GLatLng(southWest.lat() + latSpan, southWest.lng() + lngSpan ),
    new GLatLng(southWest.lat(), southWest.lng() + lngSpan),
    new GLatLng(50.461759, -4.280891),
    new GLatLng(50.461759, -3.80577),
    new GLatLng(50.30397513777613, -3.80577),
    new GLatLng(50.30397513777613, -4.280891),
    new GLatLng(50.461759, -4.280891),
	new GLatLng(southWest.lat(), southWest.lng() + lngSpan),
    new GLatLng(southWest.lat(), southWest.lng())
], "#f33f00", 0, 1, "#F4792B", 0.3);	

		var polygon1 = new GPolygon([
    new GLatLng(50.461759, -4.280891),
    new GLatLng(50.461759, -3.80577),
    new GLatLng(50.30397513777613, -3.80577),
    new GLatLng(50.30397513777613, -4.280891),
    new GLatLng(50.461759, -4.280891)
], "#F4792B",2, 1, "#F4792B", 0.0);


		
		
		// map.addOverlay(polygon2);
		map.addOverlay(polygon2);
		map.addOverlay(polygon1);




		
      }
    }


