Style and usability tweaks

This commit is contained in:
Will Bradley 2013-07-28 21:13:03 -04:00
parent 0022492c7b
commit 9a4e091128
2 changed files with 36 additions and 21 deletions

View File

@ -1,19 +1,29 @@
<html>
<head>
<title>Printable High-Resolution Maps!</title>
<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">
#navigation {
position: absolute;
top: 0;
right: 0;
z-index: 999;
background-color: white;
font-family: Arial, Helvetica, sans-serif;
padding: 1em;
border: 1px solid black;
}
#map {
height: 612px; /* 8.5 inch at 72 dpi */
width: 792px; /* 11 inch at 72 dpi */
}
#results {
width: 18%;
position: absolute;
top: 0;
right: 0;
margin: 0 0 0 1em;
padding: 0;
width: 12em;
}
#results li span {
cursor: pointer;
@ -29,13 +39,15 @@
</head>
<body>
<div id="navigation">
<form method="get" action="#" id="search_form">
<input type="text" id="q" name="q" value="Tempe, Arizona" /><input type="submit" />
<input type="text" id="q" name="q" value="" /><input type="submit" />
</form>
<input type="button" value="Print" onclick="printMap()" />
<ul id="results"></ul>
</div>
<div id="map"></div>
<ul id="results"></ul>
<script type="text/javascript">

View File

@ -9,7 +9,7 @@
padding: 0;
margin: 0;
}
#printmessage {
#navigation {
position: absolute;
top: 0;
left: 0;
@ -29,7 +29,7 @@
size: 11in 8.5in;
margin: 0mm;
}
#printmessage {
#navigation {
display: none;
}
htmlff,boffdy {
@ -48,22 +48,16 @@
</head>
<body>
<div id="printmessage">
<div id="navigation">
<p>Wait for the (huge!) map to load, then click Print.<br/>
If it comes out poorly, close this window and try again.</p>
<input type="button" value="Print" id="printbutton" onclick="printMap()" />
</div>
<div id="title"></div>
<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 &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy; <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 ("&");
@ -73,9 +67,16 @@
params[tmparr[0]] = tmparr[1];
}
var query = decodeURIComponent(params["q"]);
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: query+' map from PrintMaps.com, data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy; <a href="http://cloudmade.com">CloudMade</a>',
maxZoom: 18
}).addTo(map);
// decode query param
if(params["q"] && params["b0"] && params["b1"] && params["b2"] && params["b3"]){
updateMap(decodeURIComponent(params["q"]),[[decodeURIComponent(params["b0"]), decodeURIComponent(params["b1"])],
updateMap(query,[[decodeURIComponent(params["b0"]), decodeURIComponent(params["b1"])],
[decodeURIComponent(params["b2"]), decodeURIComponent(params["b3"])]]);
}
else {
@ -84,6 +85,8 @@
function updateMap(query,bounds){
// Generate title
document.title = query + " map";
// Fit map to the GPS boundaries
map.fitBounds(bounds);
};
@ -106,7 +109,7 @@
function halveMap(){
resizeScale = 0.285; // magic number that seems to work best in Chrome
resizeScale = 0.281; // magic number that seems to work best in Chrome
// Halve size of map container (hopefully no redraw!)
map._container.style.width = window.getComputedStyle(map._container, null).width.split("px")[0]*resizeScale+"px";