diff -r 000000000000 -r 5ecce0e1ef52 rectangle-overlay-params.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rectangle-overlay-params.html	Wed Apr 09 12:36:39 2014 +0200
@@ -0,0 +1,152 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+    <title>Rectangle Overlay</title>
+
+    <style type="text/css">
+      #map {
+        width: 1200px;
+        height: 800px;
+		margin: 5px;
+      }
+	  
+	  h2 {
+		margin: 2px;
+	  }
+	  
+	  ul {
+		margin: 2px;
+	  }
+	  
+	  body {
+		font-size: 12pt;
+		font-family: Arial, sans-serif;
+		}
+    </style>
+
+    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
+
+    <script type="text/javascript">
+      // Global variables
+      var map;
+      var marker1;
+      var marker2;
+      var rectangle;
+
+      /**
+       * Called on the initial page load.
+       */
+      function init() {
+	  
+	  	var qs = GetQueryString();
+		
+		//Set map width if specified
+		if (!(typeof qs.width === "undefined"))	{
+			document.getElementById('map').style.width=qs.width[0].concat("px");
+			//window.alert("width");
+		}
+		
+		//Set map height if specified
+		if (!(typeof qs.height === "undefined"))	{
+			document.getElementById('map').style.height=qs.height[0].concat("px");	
+			//window.alert("height");
+		}
+		
+		//Display help if expected parameters are not specified
+		if ( typeof qs.s === "undefined" || typeof qs.w === "undefined" || typeof qs.n === "undefined" || typeof qs.e === "undefined") {
+				document.getElementById('help').innerHTML='Pass the URI parameters as follow: \
+					<ul>\
+					<li>\'s\' for southernmost latitude.</li>\
+					<li>\'n\' for northernmost latitude.</li>\
+					<li>\'e\' for easternmost longitude.</li>\
+					<li>\'w\' for westernmost longitude.</li>\
+					<li>\'c\' Specify a <a href="http://www.w3schools.com/cssref/css_colornames.asp">color name</a> for your rectangles.</li>\
+					<li>\'width\' Map width in pixels, default is 1200.</li>\
+					<li>\'height\' Map heigh in pixels, default is 800.</li>\
+					</ul>\
+					You can specify any number of rectangles.<br />\
+					Map will be centered on the first rectangle.<br />\
+					Click <a href="rectangle-overlay-params.html?w=8.619000&n=50.134350&e=8.714110&s=50.091180&w=8.657227&n=50.119630&e=8.673706&s=50.108644&w=8.652547&n=50.109318&e=8.658400&s=50.105320&c=black&c=red&c=green">here</a> for an example.';
+
+			//Still display the map
+			map = new google.maps.Map(document.getElementById('map'), {
+					'zoom': 3,
+					'center': new google.maps.LatLng(45,0),
+					'mapTypeId': google.maps.MapTypeId.ROADMAP
+					});
+			
+			return;
+		}
+		
+
+		
+        var latLngBounds = new google.maps.LatLngBounds(
+          new google.maps.LatLng(qs.s[0], qs.w[0]),
+          new google.maps.LatLng(qs.n[0], qs.e[0])
+        );
+	  
+        map = new google.maps.Map(document.getElementById('map'), {
+          'zoom': 12,
+          'center': new google.maps.LatLng(latLngBounds.getCenter().lat(),latLngBounds.getCenter().lng()),
+          'mapTypeId': google.maps.MapTypeId.ROADMAP
+        });
+
+        
+		//Create all our rectangles
+		rectangles = []; //Create rentangles array
+		for (var i = 0; i < qs.s.length; i++) {
+		rectangles.push(new google.maps.Rectangle({map: map,fillColor: (typeof qs.c === "undefined" || typeof qs.c[i] === "undefined"?'#666666':qs.c[i]) }));
+		//window.alert(qs.c[i]);
+		}
+		
+        redraw();
+      }
+      
+      /**
+       * Updates the Rectangle's bounds to resize its dimensions.
+       */
+      function redraw() {
+	    var qs = GetQueryString();
+		for (var i = 0; i < qs.s.length; i++) {		
+        var latLngBounds = new google.maps.LatLngBounds(
+          new google.maps.LatLng(qs.s[i], qs.w[i]),
+          new google.maps.LatLng(qs.n[i], qs.e[i])
+        );
+        rectangles[i].setBounds(latLngBounds);
+		}
+      }
+	  
+  /** 
+   * This function is anonymous, is executed immediately and 
+   * the return value is assigned to QueryString!
+   */ 	  
+	 function GetQueryString() {
+	  var query_string = {};
+	  var query = window.location.search.substring(1);
+	  var vars = query.split("&");
+	  for (var i=0;i<vars.length;i++) {
+		var pair = vars[i].split("=");
+			// If first entry with this name
+		if ((typeof query_string[pair[0]] === "undefined") ) {
+		  query_string[pair[0]] = pair[1];
+ 		  var arr = [ query_string[pair[0]], pair[1] ];
+		  query_string[pair[0]] = arr;
+		} else {
+		  query_string[pair[0]].push(pair[1]);
+		}
+	  } 
+		return query_string;
+	}
+
+      // Register an event listener to fire when the page finishes loading.
+      google.maps.event.addDomListener(window, 'load', init);
+    </script>
+  </head>
+  <body>
+    <h2>Google maps rectangle overlay</h2>
+	<div id="help"><a href='rectangle-overlay-params.html'>help</a></div>
+    <div id="map"></div>
+  </body>
+</html>
+