Changeset 189 for trunk/npemap.org.uk
- Timestamp:
- Oct 26, 2006, 9:26:12 PM (14 years ago)
- Location:
- trunk/npemap.org.uk/static/tiles
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/static/tiles/grid.css
r125 r189 23 23 z-index: 10; 24 24 } 25 25 26 div.geonames { 27 background-color: white; 28 border: 1px solid black; 29 float: right; 30 position: absolute; 31 } 32 div.geonames span.loc { 33 font-size: 60%; 34 } 35 26 36 span.terms { 27 37 margin-top: 0px; -
trunk/npemap.org.uk/static/tiles/map.html
r176 r189 22 22 23 23 <div id="main_page"> 24 <div id="m ove" style="float:right">24 <div id="menu" style="float:right"> 25 25 <table border="0"> 26 26 <tr> … … 57 57 <a href="/reportBug.html">problem?</a> 58 58 </div> 59 <div >59 <div id="geonames-search"> 60 60 <form onsubmit="return find()" action=""> 61 61 <p><label for="where">Place name:</label><br/> -
trunk/npemap.org.uk/static/tiles/mapTiles.js
r187 r189 417 417 418 418 function find() { 419 request = 'http://ws.geonames.org/searchJSON?name=' + encodeURIComponent($('where').value) + '& maxRows=1&callback=getLocation&country=GB&fclass=P&style=SHORT';419 request = 'http://ws.geonames.org/searchJSON?name=' + encodeURIComponent($('where').value) + '&callback=getLocation&country=GB&fclass=P&style=SHORT'; 420 420 aObj = new JSONscriptRequest(request); 421 421 // Build the script tag … … 434 434 var geonames = jData.geonames; 435 435 if (geonames.length > 0) { 436 var name = geonames[0]; 437 var ll = new LatLng(name.lat,name.lng); 436 if (geonames.length == 1) { 437 var name = geonames[0]; 438 gotoLatLong(name.lat, name.lng, 1); 439 } else { 440 var popup = geonamesPopup(); 441 for(var i=0; i<geonames.length; i=i+1) { 442 appendLink(popup, geonames[i]); 443 } 444 } 445 $('where').value = ''; 446 } 447 else { 448 alert("Sorry, can't find that location"); 449 } 450 } 451 452 function geonamesPopup() { 453 var popup = document.createElement("div"); 454 popup.className = "geonames"; 455 $("menu").appendChild(popup); 456 var link = document.createElement("A"); 457 link.onclick = function () { $("menu").removeChild(popup); return false; }; 458 link.href = '#'; 459 link.innerHTML = "close" ; 460 popup.appendChild(link); 461 popup.appendChild(document.createElement("BR")); 462 // popup.setXY($("geonames-search").getXY()); 463 return popup; 464 } 465 466 function appendLink(popup, loc) { 467 var link = document.createElement("A"); 468 link.onclick = function () { gotoLatLong(loc.lat, loc.lng, 1); $("menu").removeChild(popup); return false; }; 469 link.href = '#'; 470 link.innerHTML = loc.name ; 471 popup.appendChild(link); 472 var span = document.createElement("SPAN"); 473 span.className = "loc"; 474 formatLatLong(span, loc.lat, loc.lng); 475 popup.appendChild(span); 476 popup.appendChild(document.createElement("BR")); 477 } 478 479 function formatLatLong(parent, lat, lng) { 480 var text = " N " + formatDeg(lat) + " " ; 481 if (lng < 0) { text += "W ";} else { text += "E ";} 482 text += formatDeg(Math.abs(lng)); 483 parent.appendChild(document.createTextNode(text)); 484 } 485 486 function formatDeg(num) { 487 var text = (Math.floor(num * 10)/10) + "° "; 488 return text; 489 } 490 491 function gotoLatLong(lat, lng, zoom) { 492 var ll = new LatLng(lat,lng); 438 493 ll.WGS84ToOSGB36(); 439 494 var en = ll.toOSRef(); 440 495 var easting = Math.round(en.easting/1000); 441 496 var northing = Math.round(en.northing/1000); 442 gotoLocation(easting, northing, 1); 443 444 $('where').value = ''; 445 } 446 else { 447 alert("Sorry, can't find that location"); 448 } 449 } 450 451 497 gotoLocation(easting, northing, zoom); 498 } 499 500
Note: See TracChangeset
for help on using the changeset viewer.