# HG changeset patch
# User sl
# Date 1397126733 -7200
# Node ID 54ac29018aafd36e142734e174738bfe421a2ac2
# Parent b014e6b2a9e21d8c5a79f2b2766ff012df9ea5fc
Rectangle overlay params:
Adding support for 'cycle' and 'zoom' param.
Fixing issue with step not being interpreted and an integer.
Updating help documentation.
diff -r b014e6b2a9e2 -r 54ac29018aaf rectangle-overlay-params.html
--- a/rectangle-overlay-params.html Wed Apr 09 19:55:16 2014 +0200
+++ b/rectangle-overlay-params.html Thu Apr 10 12:45:33 2014 +0200
@@ -58,7 +58,7 @@
var animation=false;
if (!(typeof qs.anim === "undefined")) {
- animation=true;
+ animation=(qs.anim[0]=='true'||qs.anim[0]=='1');
//window.alert("Using animation mode");
}
@@ -67,16 +67,32 @@
intervalInMs=qs.interval[0];
//window.alert("Interval: " + intervalInMs + " ms");
}
+
+ var cycle=false; //Whether we should cycle through our animation
+ if (!(typeof qs.cycle === "undefined")) {
+ cycle=(qs.cycle[0]=='true'||qs.cycle[0]=='1');
+ //window.alert("cycle: " + cycle);
+ }
+ var zoom=12; //Specify default zoom
+ if (!(typeof qs.zoom === "undefined")) {
+ zoom=parseInt(qs.zoom[0]);
+ //window.alert("zoom: " + zoom);
+ }
+
+
var step=1; //default to n seconds
if (!(typeof qs.step === "undefined")) {
- step=qs.step[0];
+ //Use parseInt to force that variable to an integer rather than a string
+ step=parseInt(qs.step[0]);
//window.alert("Step: " + step);
}
//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: \
+ \
+
Rectangles parameters:
\
\
- \'s\' for southernmost latitude.
\
- \'n\' for northernmost latitude.
\
@@ -84,11 +100,22 @@
- \'w\' for westernmost longitude.
\
- \'c\' Specify a color name or value (use %23FFFFFF for white) for your rectangles.
\
- \'a\' Specify alpha opacity of your rectangle fill, it should be between 1 and 0. For instance 0.5 makes it half transparent.
\
+
\
+ \
+ You can specify any number of rectangles.
\
+ Map will be centered on the first rectangle.
\
+ \
+ Global parameters:
\
+ \
- \'width\' Map width in pixels, default is 1200.
\
- \'height\' Map heigh in pixels, default is 800.
\
+ - \'zoom\' Specify default zoom.
\
+ - \'anim\' Specify whether or not to perform an animation on our list of rectangles. By default no animation is performed.
\
+ - \'interval\' The interval between each animation step specified in milliseconds (ms).
\
+ - \'cycle\' Specify whether our not our animation is to keep on going forever or simple run once. By default it runs just once.
\
+ - \'step\' Specify how many rectangles do we display on every animation tick.
\
\
- You can specify any number of rectangles.
\
- Map will be centered on the first rectangle.
\
+ \
Click here for an example.';
//Still display the map
@@ -109,7 +136,7 @@
);
map = new google.maps.Map(document.getElementById('map'), {
- 'zoom': 12,
+ 'zoom': zoom,
'center': new google.maps.LatLng(latLngBounds.getCenter().lat(),latLngBounds.getCenter().lng()),
'mapTypeId': google.maps.MapTypeId.ROADMAP
});
@@ -134,38 +161,46 @@
}
}
else {
- var currentRect=0;
- rectangles = []; //Create rectangles array
- //We are doing an animation so just setup our timer
- var animTimer=setInterval(function(){
- //alert("Hello");
- if ((currentRect+step)