Make the freemap example better documented and simpler. Before it had some
stuff that didn't actually work in there, so removing it is a Good Thing, and makes the example more legible, and some additional comments which make what the code is doing more understandable. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1773 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -2,14 +2,13 @@
|
||||
<head>
|
||||
|
||||
<style type="text/css">
|
||||
body { font-family: sans-serif; font-weight: bold; font-size: .8em; }
|
||||
body {
|
||||
border: 0px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
#map {
|
||||
width: 65%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0px;
|
||||
padding: 0px;
|
||||
@@ -22,86 +21,29 @@
|
||||
var lat = 900863;
|
||||
var lon = 235829;
|
||||
var zoom = 6;
|
||||
var map, layer;
|
||||
var map, layer;
|
||||
|
||||
function init(){
|
||||
// these should be object methods or something
|
||||
map = new OpenLayers.Map( $('map') );
|
||||
var basemap = new OpenLayers.Layer.WMS( "Boston",
|
||||
"http://boston.freemap.in/cgi-bin/mapserv?",
|
||||
{map: '/www/freemap.in/boston/map/gmaps.map', layers: 'border,water,roads', format: 'png', 'transparent': 'off'},
|
||||
{map: '/www/freemap.in/boston/map/gmaps.map', layers: 'border,water,roads,rapid_transit,buildings', format: 'png', 'transparent': 'off'},
|
||||
// These are the important parts for creating a non-epsg:4326
|
||||
// map: Maxextent is the boundary of the map/tile loading area,
|
||||
// maxResolution is the units/pixel at the highest zoom, and
|
||||
// projection is the projection to be used in WMS/WFS Requests.
|
||||
{maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution: 296985/1024, projection:"EPSG:2805" } );
|
||||
var rapid = new OpenLayers.Layer.WMS( "Rapid Transit",
|
||||
"http://boston.freemap.in/cgi-bin/mapserv?",
|
||||
{map: '/www/freemap.in/boston/map/mass.map', layers: 'rapid_transit', format: 'png', transparent:'true'} );
|
||||
var buildings = new OpenLayers.Layer.WMS( "Buildings",
|
||||
"http://boston.freemap.in/cgi-bin/mapserv?",
|
||||
{map: '/www/freemap.in/boston/map/mass.map', layers: 'buildings', format: 'png', transparent:'true'} );
|
||||
|
||||
map.addLayer(basemap);
|
||||
map.addLayer(rapid);
|
||||
map.addLayer(buildings);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
}
|
||||
function getaddress() {
|
||||
if (!document.getElementById('address').value) {return; }
|
||||
document.getElementById('status').innerHTML = "Finding address...";
|
||||
var address = document.getElementById('address').value;
|
||||
address = escape(address);
|
||||
addr = "/geocode.cgi?address="+address;
|
||||
var handler = XMLrequest();
|
||||
if (handler) {
|
||||
handler.onreadystatechange=function() {
|
||||
if (handler.readyState == 4 && handler.status == 200) {
|
||||
var latlon = handler.responseText;
|
||||
latlon = latlon.split(",");
|
||||
if (latlon[1]) {
|
||||
map.setCenter(new OpenLayers.LonLat(parseFloat(latlon[1]), parseFloat(latlon[0])), 15);
|
||||
document.getElementById('status').innerHTML = "";
|
||||
|
||||
} else {
|
||||
document.getElementById('status').innerHTML = "Could not find address, sorry.";
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.open("GET", addr, true);
|
||||
handler.send('');
|
||||
}
|
||||
}
|
||||
function XMLrequest() {
|
||||
xmlhttp={};
|
||||
try {
|
||||
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (E) { }
|
||||
}
|
||||
try {
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
} catch (e) {}
|
||||
return xmlhttp;
|
||||
}
|
||||
function setLink() {
|
||||
var link = document.getElementById("link");
|
||||
var center = map.getCenter();
|
||||
var zoom = map.getZoom();
|
||||
link.innerHTML="http://boston.freemap.in/?zoom="+zoom+"&lat="+center.lat+"&lon="+center.lon;
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body onload="init()">
|
||||
<div id="right" style="float:right;width:30%;padding:10px;" ><h1>Boston Free Map</h1><!--Search: <input type="text" id='address' name="address"><input type="submit" value="Go!" onclick="javascript:getaddress()"/>--><div id="status" style="height:20px;min-height:20px;"> </div>
|
||||
<div>Map powered by <a href="http://www.openlayers.org/">OpenLayers</a>
|
||||
and <a href="http://mapserver.gis.umn.edu/">MapServer</a>.
|
||||
Data downloaded from
|
||||
<a href="http://www.mass.gov/mgis/">Office of Geographic and Environmental Information (MassGIS)</a>.</div>
|
||||
<!--<a onclick="setLink(); return false" href="#" id="update">Update Link</a>
|
||||
<div id="link"></div>-->
|
||||
</div>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user