2013-07-28 10:29:24 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
|
|
|
|
<!--[if lte IE 8]>
|
|
|
|
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
|
|
|
|
<![endif]-->
|
|
|
|
<style type="text/css">
|
|
|
|
body{
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
2013-07-28 23:34:21 +00:00
|
|
|
#printbutton {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 999;
|
|
|
|
}
|
2013-07-28 10:29:24 +00:00
|
|
|
#map {
|
|
|
|
height: 2550px; /* 8.5 inch at 300 dpi */
|
|
|
|
width: 3300px; /* 11 inch at 300 dpi */
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<style type="text/css" media="print">
|
|
|
|
@page {
|
|
|
|
size: 11in 8.5in;
|
|
|
|
margin: 0mm;
|
|
|
|
}
|
2013-07-28 23:34:21 +00:00
|
|
|
#printbutton {
|
|
|
|
display: none;
|
|
|
|
}
|
2013-07-28 10:29:24 +00:00
|
|
|
htmlff,boffdy {
|
|
|
|
height: 8.5in;
|
|
|
|
width: 11in;
|
|
|
|
}
|
|
|
|
#mapfoo {
|
|
|
|
margin: 0.25in;
|
|
|
|
height: 8in;
|
|
|
|
width: 10.5in;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
2013-07-28 23:34:21 +00:00
|
|
|
<input type="button" value="Print" id="printbutton" onclick="printMap()" />
|
2013-07-28 10:29:24 +00:00
|
|
|
<div id="map"></div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
var query = "";
|
|
|
|
var map = L.map('map', {zoomControl: false}); //.setView([51.505, -0.09], 13);
|
|
|
|
L.tileLayer('http://{s}.tile.cloudmade.com/4be2d4a8b7ae4a5e8ebc0558bb5d7db4/997/256/{z}/{x}/{y}.png', {
|
|
|
|
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>',
|
|
|
|
maxZoom: 18
|
|
|
|
}).addTo(map);
|
|
|
|
|
|
|
|
// Get url params
|
|
|
|
var prmstr = window.location.search.substr(1);
|
|
|
|
var prmarr = prmstr.split ("&");
|
|
|
|
var params = {};
|
|
|
|
for ( var i = 0; i < prmarr.length; i++) {
|
|
|
|
var tmparr = prmarr[i].split("=");
|
|
|
|
params[tmparr[0]] = tmparr[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
// decode query param
|
|
|
|
if(params["q"] && params["b0"] && params["b1"] && params["b2"] && params["b3"]){
|
|
|
|
updateMap(decodeURIComponent(params["q"]),[[decodeURIComponent(params["b0"]), decodeURIComponent(params["b1"])],
|
|
|
|
[decodeURIComponent(params["b2"]), decodeURIComponent(params["b3"])]]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
alert("No boundaries given!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateMap(query,bounds){
|
|
|
|
// Fit map to the GPS boundaries
|
|
|
|
map.fitBounds(bounds);
|
|
|
|
};
|
|
|
|
|
2013-07-28 23:34:21 +00:00
|
|
|
function printMap(){
|
|
|
|
halveMap();
|
|
|
|
print();
|
2013-07-28 10:29:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-28 23:34:21 +00:00
|
|
|
|
|
|
|
function halveMap(){
|
|
|
|
// Halve size of each leaflet tile AND decrease its offsets by half
|
|
|
|
var leaflets = document.getElementsByClassName("leaflet-tile");
|
|
|
|
for(var i=0; i < leaflets.length; i++){
|
|
|
|
element = leaflets[i];
|
|
|
|
element.style.width = element.style.width.split("px")[0]/2+"px";
|
|
|
|
element.style.height = element.style.height.split("px")[0]/2+"px";
|
|
|
|
|
|
|
|
computedStyle = window.getComputedStyle(element, null); // "null" means this is not a pesudo style.
|
|
|
|
// You can retrieve the CSS3 matrix string by the following method.
|
|
|
|
var matrix = computedStyle.getPropertyValue('transform')
|
|
|
|
|| computedStyle.getPropertyValue('-moz-transform')
|
|
|
|
|| computedStyle.getPropertyValue('-webkit-transform')
|
|
|
|
|| computedStyle.getPropertyValue('-ms-transform')
|
|
|
|
|| computedStyle.getPropertyValue('-o-transform');
|
|
|
|
|
|
|
|
// Parse this string to obtain different attributes of the matrix.
|
|
|
|
// This regexp matches anything looks like this: anything(1, 2, 3, 4, 5, 6);
|
|
|
|
// Hence it matches both matrix strings:
|
|
|
|
// 2d: matrix(1,2,3,4,5,6)
|
|
|
|
// 3d: matrix3d(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
|
|
|
|
var matrixPattern = /^\w*\((((\d+)|(\d*\.\d+)|(\-\d*)),\s*)*((\d+)|(\d*\.\d+)|(\-\d*))\)/i;
|
|
|
|
var matrixValue = [];
|
|
|
|
if (matrixPattern.test(matrix)) { // When it satisfy the pattern.
|
|
|
|
console.log(matrix);
|
|
|
|
var matrixCopy = matrix.replace(/^\w*\(/, '').replace(')', '');
|
|
|
|
console.log(matrixCopy);
|
|
|
|
m = matrixCopy.split(/\s*,\s*/);
|
|
|
|
console.log(m);
|
|
|
|
m[4] = m[4]/2;
|
|
|
|
m[5] = m[5]/2;
|
|
|
|
console.log(m);
|
|
|
|
element.style.webkitTransform = "matrix("+m[0]+", "+m[1]+", "+m[2]+", "+m[3]+", "+m[4]+", "+m[5]+")";
|
|
|
|
console.log(element.style.webkitTransform);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Halve size of map container (hopefully no redraw!)
|
|
|
|
|
|
|
|
map._container.style.width = window.getComputedStyle(map._container, null).width.split("px")[0]/2+"px";
|
|
|
|
map._container.style.height = window.getComputedStyle(map._container, null).height.split("px")[0]/2+"px";
|
|
|
|
|
2013-07-28 10:29:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-28 23:34:21 +00:00
|
|
|
|
|
|
|
|
2013-07-28 10:29:24 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|