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> <html>
<head> <head>
<title>Printable High-Resolution Maps!</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" /> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]> <!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" /> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]--> <![endif]-->
<style type="text/css"> <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 { #map {
height: 612px; /* 8.5 inch at 72 dpi */ height: 612px; /* 8.5 inch at 72 dpi */
width: 792px; /* 11 inch at 72 dpi */ width: 792px; /* 11 inch at 72 dpi */
} }
#results { #results {
width: 18%; margin: 0 0 0 1em;
position: absolute; padding: 0;
top: 0; width: 12em;
right: 0;
} }
#results li span { #results li span {
cursor: pointer; cursor: pointer;
@ -29,13 +39,15 @@
</head> </head>
<body> <body>
<form method="get" action="#" id="search_form"> <div id="navigation">
<input type="text" id="q" name="q" value="Tempe, Arizona" /><input type="submit" /> <form method="get" action="#" id="search_form">
</form> <input type="text" id="q" name="q" value="" /><input type="submit" />
<input type="button" value="Print" onclick="printMap()" /> </form>
<input type="button" value="Print" onclick="printMap()" />
<ul id="results"></ul>
</div>
<div id="map"></div> <div id="map"></div>
<ul id="results"></ul>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -9,7 +9,7 @@
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
#printmessage { #navigation {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
@ -29,7 +29,7 @@
size: 11in 8.5in; size: 11in 8.5in;
margin: 0mm; margin: 0mm;
} }
#printmessage { #navigation {
display: none; display: none;
} }
htmlff,boffdy { htmlff,boffdy {
@ -48,22 +48,16 @@
</head> </head>
<body> <body>
<div id="printmessage"> <div id="navigation">
<p>Wait for the (huge!) map to load, then click Print.<br/> <p>Wait for the (huge!) map to load, then click Print.<br/>
If it comes out poorly, close this window and try again.</p> If it comes out poorly, close this window and try again.</p>
<input type="button" value="Print" id="printbutton" onclick="printMap()" /> <input type="button" value="Print" id="printbutton" onclick="printMap()" />
</div> </div>
<div id="title"></div>
<div id="map"></div> <div id="map"></div>
<script type="text/javascript"> <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 // Get url params
var prmstr = window.location.search.substr(1); var prmstr = window.location.search.substr(1);
var prmarr = prmstr.split ("&"); var prmarr = prmstr.split ("&");
@ -73,9 +67,16 @@
params[tmparr[0]] = tmparr[1]; 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 // decode query param
if(params["q"] && params["b0"] && params["b1"] && params["b2"] && params["b3"]){ 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"])]]); [decodeURIComponent(params["b2"]), decodeURIComponent(params["b3"])]]);
} }
else { else {
@ -84,6 +85,8 @@
function updateMap(query,bounds){ function updateMap(query,bounds){
// Generate title
document.title = query + " map";
// Fit map to the GPS boundaries // Fit map to the GPS boundaries
map.fitBounds(bounds); map.fitBounds(bounds);
}; };
@ -106,7 +109,7 @@
function halveMap(){ 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!) // Halve size of map container (hopefully no redraw!)
map._container.style.width = window.getComputedStyle(map._container, null).width.split("px")[0]*resizeScale+"px"; map._container.style.width = window.getComputedStyle(map._container, null).width.split("px")[0]*resizeScale+"px";