//This script shows a rectangle defined by variable lat1, lat2, lng1, and lng2 below.
//Also GET parameters are possible:
// As above, latitudes and longitudes given separately:
//http://fiddle.jshell.net/u7G7n/44/show/light/?lat1=53.4&lng1=9.9&lat2=53.5&lng2=10.0
// Latitudes and longitudes as comma separated string. Format: lat1,lng1,lat2,lng2
//http://fiddle.jshell.net/u7G7n/44/show/light/?all=53.4,9.9,53.5,10.0
// Latitudes and longitudes as number with 6 decimal places but without decimal separator as comma separated string. Format: lat1,lat2,lng1,lng2
//http://fiddle.jshell.net/u7G7n/44/show/light/?all=53400000,53500000,9900000,10000000
// Latitudes and longitudes as underline separated string. Only first four entries are considered. Format: lat1_lat2_lng1_lng2
//http://fiddle.jshell.net/u7G7n/44/show/light/?file=53.4_53.5_9.9_10.0_1_1_0.wigle
// Show up to 5 rectangles using "all" format:
//http://fiddle.jshell.net/u7G7n/44/show/light/?all=53400000,53500000,9900000,10000000&all2=53400000,53450000,9950000,10000000&all3=53500000,53450000,9950000,10000000&all4=53400000,53450000,9900000,9950000&all5=53500000,53450000,9900000,9950000
//Note: To make GET parameters work for jsfiddle refer to:
//http://stackoverflow.com/questions/16527958/how-to-pass-get-parameters-to-jsfiddle#answer-26381772
var rectangle;
var totalBounds = new google.maps.LatLngBounds();
var map;
var infoWindow;
//set default values.
lat1 = 49.05059113687008
lat2 = 49.9792908251706
lng1 = -111.109789062499999
lng2 = -111.892327148437516
function insertDot(t) {
return parseFloat(t.substr(0,t.length-6) + "." + t.substr(t.length-6));
}
function getRectangle(l_lat1, l_lng1, l_lat2, l_lng2) {
if(l_lat1 > l_lat2) {
var tmp = l_lat1;
l_lat1 = l_lat2;
l_lat2 = tmp;
}
if(l_lng1 > l_lng2) {
var tmp = l_lng1;
l_lng1 = l_lng2;
l_lng2 = tmp;
}
console.log("getRectanlge: " + l_lat1 +" "+ l_lng1+" "+ l_lat2+" "+...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.