Compare commits

..

1 Commits

Author SHA1 Message Date
crschmidt
3a23e9ff8f All tests pass! Take that branch and call it an RC!
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.0-rc1@1273 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-17 02:58:17 +00:00
44 changed files with 467 additions and 760 deletions

View File

@@ -2,18 +2,9 @@
rm ../doc/reference.html
CLASSES="Map Layer Layer.HTTPRequest Layer.Grid Layer.WMS Layer.KaMap Layer.EventPane Layer.Google Layer.VirtualEarth Layer.Markers Layer.Text Layer.GeoRSS Layer.Boxes Icon Marker Marker.Box Tile Tile.Image Tile.WFS Control Control.LayerSwitcher Control.MouseDefaults Control.MouseToolbar Control.PanZoom Control.PanZoomBar Control.Permalink Control.Scale LonLat Size Pixel Bounds"
echo "<html>
<head>
<title>OpenLayers Class Reference Documentation</title>
<style type='text/css'>
.type { background-color: #ddd }
td { border: black solid 1px; padding: 3px; }
table { border-collapse: collapse; margin: 5px 10px; }
.classref { margin-left: 20px; }
div.index { float:left; width: 300px; }
</style>
</head>
<body>" >> ../doc/reference.html
echo "<html><head><title>OpenLayers Class Reference Documentation</title><style type='text/css'> .type { background-color: #ddd } td { border: black solid 1px; padding: 3px; } table { border-collapse: collapse; margin: 5px 10px; } .classref { margin-left: 20px; }
div.index { float:left; width: 300px; }
</style></head><body>" >> ../doc/reference.html
for i in $CLASSES; do
echo "<div class='index'><a href='#OpenLayers.$i'>OpenLayers.$i</a></div>" >> ../doc/reference.html
@@ -23,17 +14,16 @@ echo "<br style='clear:both' />" >> ../doc/reference.html
for i in $CLASSES; do
cat ../doc/$i.txt | \
perl -pe 's!^(.*?) -- (.*?) -- (.*?)$! <tr><td>$1</td><td>$2</td><td>$3</td></tr>!g;
s!^( \* )?(.*?) -- (.*?)$! <tr><td>$2</td><td>$3</td></tr>!g;
s!^ \* (.*)$! </table>\n\n<h3>$1</h3>\n <table>!;
s!{OpenLayers.(.*?)\|(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">\2</a>!g;
s!{OpenLayers.(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">OpenLayers.$1</a>!;
s!{([A-Za-z]+?)\|(.+?)}!<span class="type" title="$1">\2<\/span>!g;
s!{([A-Za-z]+?)}!<span class="type" title="$1">$1<\/span>!g;
s!^\* (.*)$!</table>\n<h2>$1</h2>\n<table>!;
s!^OpenLayers\.(.*)$!<h1><a name="OpenLayers.$1">OpenLayers.$1</a></h1><div class="classref">!' \
perl -pe 's!^(.*?) -- (.*?) -- (.*?)$! <tr><td>$1</td><td>$2</td><td>$3</td></tr>!g' | \
perl -pe 's!^( \* )?(.*?) -- (.*?)$! <tr><td>$2</td><td>$3</td></tr>!g' | \
perl -pe 's!^ \* (.*)$! </table>\n\n<h3>$1</h3>\n <table>!' | \
perl -pe 's!{OpenLayers.(.*?)\|(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">\2</a>!g' | \
perl -pe 's!{OpenLayers.(.*?)}!<a href="#OpenLayers.$1" title="OpenLayers.$1">OpenLayers.$1</a>!' | \
perl -pe 's!{([A-Za-z]+?)\|(.+?)}!<span class="type" title="$1">\2<\/span>!g' | \
perl -pe 's!{([A-Za-z]+?)}!<span class="type" title="$1">$1<\/span>!g' | \
perl -pe 's!^\* (.*)$!</table>\n<h2>$1</h2>\n<table>!' | \
perl -pe 's!^OpenLayers\.(.*)$!<h1><a name="OpenLayers.$1">OpenLayers.$1</a></h1><div class="classref">!' \
>> ../doc/reference.html
echo '</table></div>' >> ../doc/reference.html
done
echo " </body>
</html>" >> ../doc/reference.html
echo "</body></html>" >> ../doc/reference.html

View File

@@ -1,7 +1,6 @@
OpenLayers.Layer.GeoRSS
GeoRSS layer. Pass a name and location of a GeoRSS file on the web, and a marker will be added to the map for each item in the GeoRSS feed. Uses OpenLayers.loadURL to load the XML, parses the data, and adds markers to the map. The GeoRSS layer supports 1.0 and 2.0 in IE and Firefox, and supports 2.0 in Safari. (Ticket #111 explains the reason for this difference.)
GeoRSS layer. Pass a name and location of a GeoRSS file on the web, and a marker will be added to the map for each item in the GeoRSS feed. Uses OpenLayers.loadURL to load the XML, parses the data, and adds markers to the map.
* Constructor
OpenLayers.Layer.GeoRSS(name, url) -- Name and location of GeoRSS XML file.

View File

@@ -1,8 +1,6 @@
OpenLayers.Layer.WMS
The WMS layer allows one to connect to a WMS server to obtain images. Params are available as a hash on the layer object, however, all keys are upper-cased automatically for maximum compatibility with WMS servers, so a parameter which is set as 'layers' will be uppercased to LAYERS. Where 'layer' is your Javscript variable for the layer, layer.params.LAYERS is the value of the layers param as set by the constructor.
If you wish to change params, you should use mergeNewParams, rather than accessing the parameters directly.
The WMS layer allows one to connect to a WMS server to obtain images.
* Constructor
OpenLayers.Layer.WMS(name, url, params, options) -- URL is the base URL to the layer. Params is a set of params to be included in the HTTP Request. Options is a set of options, extending the parameters of the layer.
@@ -11,5 +9,5 @@ If you wish to change params, you should use mergeNewParams, rather than accessi
getURL({OpenLayers.Bounds|bounds}) -- {String} -- Returns a WMS URL for the given bounds based on the properties of the layer.
All other methods are inherited from {OpenLayers.Layer.Grid}
* Options
* Parameters
isBaseLayer -- WMS layers default to being base layers unless one of their parameters is 'transparent':'true'.

View File

@@ -23,23 +23,20 @@
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') ,
{ controls: [new OpenLayers.Control.MouseDefaults()] });
map = new OpenLayers.Map( $('map') );
var normal = new OpenLayers.Layer.Google( "Google", // );
{ minZoomLevel: 3, maxZoomLevel: 8 });
var normal = new OpenLayers.Layer.Google( "Google" );
var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP });
var hybrid = new OpenLayers.Layer.Google( "Google Hybrid" , {type: G_HYBRID_MAP });
map.addLayers([satellite, normal, hybrid]);
map.addLayers([normal, satellite, hybrid]);
markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.PanZoomBar() );
}

View File

@@ -18,7 +18,7 @@
{layers: 'basic'} );
var jpl_wms = new OpenLayers.Layer.KaMap( "Satellite",
"http://www.openlayers.org/world/index.php", {g: "satellite", map: "world"});
"/world/index.php", {g: "satellite", map: "world"});
var dm_wms = new OpenLayers.Layer.WMS( "Canada",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +

View File

@@ -1,29 +0,0 @@
<html>
<head>
<title>Setting a visual Extent</title>
<script src="../lib/OpenLayers.js"></script>
</head>
<body>
<h1>Setting a Visual Extent</h1>
<p>
Because the ability to set the map to a given extent is limited by the
current resolutions available, zoomToExtent will not always set the map to
exactly the right extent. In order to visually annotate the actual extent,
this example, will use the Boxes layer to visually describe the desired
extent as well as setting the map extent.
</p>
<div style="width:100%; height:75%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
var bounds = new OpenLayers.Bounds(-45,-45, 0, 45);
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.zoomToExtent(bounds);
var boxes = new OpenLayers.Layer.Boxes("boxes");
var box = new OpenLayers.Marker.Box(bounds);
boxes.addMarker(box);
map.addLayer(boxes);
</script>
</body>
</html>

View File

@@ -1,90 +0,0 @@
<html>
<script src="../lib/Prototype.js"></script>
<script type="text/javascript">
var one, two, div, msg;
function init() {
one = $("one");
two = $("two");
div = $("div");
msg = $("msg");
Event.observe(div, "click", bar);
one.checked = true;
two.checked = false;
Event.observe(one, "change", oneClick);
Event.observe(two, "change", twoClick);
}
function bar(e) {
message("clicked div");
Event.stop(e);
var status = "one: ";
status += (one.checked) ? "checked" : "unchecked";
status += " two: ";
status += (two.checked) ? "checked" : "unchecked";
message(status);
}
function oneClick(e) {
message("clicked one");
}
function twoClick(e) {
message("clicked two");
}
function message(txt) {
msg.innerHTML += " ** " + txt;
}
</script>
<body onload="init()" onclick="message('clicked body')" onmouseup="message('<br>')">
<div> The idea here is to simulate the layerswitcher radiobuttons UI
without all the overhead of openlayers.
<br>
<br>
There are event handlers attached to the following elements:
<br>
* Body - Prints message "clicked body" to message area
<br>
* Blue Div - Prints message "clicked div" to message area, stops
the event propagation, prints a message with the
status of the two radiobuttons
<br>
* Radio One - Prints message "clicked one" to message area
<br>
* Radio Two - Prints message "clicked two" to message area
<br>
<br>
<b>
The problem, as you will see if you click the radio buttons
themselves, is that their "checked" status seems to update, but
their visual UI bit does not. Can we fix this!?!
</b>
</div>
<div id="div" style="background-color:blue; margin:50px">
<input id="one" type="radio" name="foo"/>
<span> one </span>
<br>
<input id="two" type="radio" name="foo"/>
<span> two </span>
</div>
<div id="msg" style="background-color:pink; margin-top:200px">
Events:
</div>
</body>
</html>

View File

@@ -14,12 +14,11 @@
var map = new OpenLayers.Map('map', {'maxResolution': 1.40625/4, controls:[]});
var ka_wms = new OpenLayers.Layer.KaMap( "TIGER (KaMap)",
"http://boston.freemap.in/tile.php" , { map: 'tiger', layers: 'TIGER' });
"http://boston.freemap.in/tile.php" , { map: 'tiger', layers: 'TIGER' }, 'degrees', 72 );
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://wms.jpl.nasa.gov/wms.cgi",
{layers: "modis,global_mosaic"});
jpl_wms.setVisibility(false);
ka_wms.isBaseLayer = false;
map.addLayers([jpl_wms,ka_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MouseToolbar());

View File

@@ -11,15 +11,15 @@
<script type="text/javascript">
<!--
function init(){
var mapOptions = { maxResolution: 1.6, numZoomLevels: 21};
var map = new OpenLayers.Map('map', mapOptions);
var map = new OpenLayers.Map('map', {'maxResolution': 1.6, maxZoomLevel:20});
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
var ww = new OpenLayers.Layer.WorldWind( "Urban",
"http://worldwind25.arc.nasa.gov/tile/tile.aspx?", .8, 9,
{T:"104"}, { tileSize: new OpenLayers.Size(512,512) });
{T:"104"});
ww.setTileSize(new OpenLayers.Size(512,512));
map.addLayers([ol_wms, ww]);

View File

@@ -18,23 +18,20 @@
var lon = 5;
var lat = 40;
var zoom = 15;
var zoom = 5;
var map, velayer, layer;
function init(){
map = new OpenLayers.Map( $('map') ,
{controls:[new OpenLayers.Control.MouseDefaults()]});
map = new OpenLayers.Map( $('map') );
velayer = new OpenLayers.Layer.VirtualEarth( "VE",
{ minZoomLevel: 4, maxZoomLevel: 6 });
velayer = new OpenLayers.Layer.VirtualEarth( "VE");
map.addLayer(velayer);
markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.setCenter(new OpenLayers.LonLat(lon, lat), 2);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.PanZoomBar() );
}
function add() {

View File

@@ -35,7 +35,7 @@ var map,ia_wms;
<body onload="init()">
<h1>OpenLayers Example</h1>
<p>WMS-T example: update the times, and the radar image will change. Uses Layer.changeParams. Thanks to David Bitner for the inspiration, the original code, and the kick in the butt!</p>
<input type='text' id='time' value="2005-08-29T13:00:00Z" onChange='ia_wms.mergeNewParams({"time":this.value});' >
<input type='text' id='time' value="2005-08-29T13:00:00Z" onChange='ia_wms.changeParams({"time":this.value});' >
<div id="map"></div>
</body>
</html>

View File

@@ -1,54 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var lon = 50;
var lat = 0;
var zoom = 0;
var map, layer;
function init(){
var options = {
// resolutions: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.00137329101],
// scales: [50000000, 10000000],
// maxResolution: 0.17578125,
// minResolution: 0.0439453125,
// maxScale: 10000000,
// minScale: 50000000,
minResolution: "auto",
minExtent: new OpenLayers.Bounds(-1, -1, 1, 1),
maxResolution: "auto",
maxExtent: new OpenLayers.Bounds(-180, -90, 90, 180),
// numZoomLevels: 5,
controls: [new OpenLayers.Control.MouseDefaults()]
};
map = new OpenLayers.Map( $('map') , options);
map.addControl(new OpenLayers.Control.PanZoomBar());
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 B

View File

@@ -420,8 +420,8 @@ OpenLayers.Bounds.prototype = {
* @type OpenLayers.Bounds
*/
add:function(x, y){
return new OpenLayers.Bounds(this.left + x, this.bottom + y,
this.right + x, this.top + y);
return new OpenLayers.Box(this.left + x, this.bottom + y,
this.right + x, this.top + y);
},
/**

View File

@@ -119,18 +119,16 @@ OpenLayers.Control.LayerSwitcher.prototype =
inputElem.type = (baseLayer) ? "radio" : "checkbox";
inputElem.value = layer.name;
inputElem.checked = checked;
inputElem.defaultChecked = checked;
inputElem.layer = layer;
inputElem.control = this;
Event.observe(inputElem, "mouseup",
this.onInputClick.bindAsEventListener(inputElem));
// create span
var labelSpan = document.createElement("span");
labelSpan.innerHTML = layer.name;
labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "auto";
Event.observe(labelSpan, "click",
this.onInputClick.bindAsEventListener(inputElem));
Event.observe(labelSpan,
"click",
this.onLabelClick.bindAsEventListener(inputElem));
// create line break
var br = document.createElement("br");
@@ -160,17 +158,11 @@ OpenLayers.Control.LayerSwitcher.prototype =
*
* @param {Event} e
*/
onInputClick: function(e) {
if (this.type == "radio") {
this.checked = true;
this.layer.map.setBaseLayer(this.layer, true);
this.layer.map.events.triggerEvent("changebaselayer");
} else {
onLabelClick: function(e) {
var clickedRadioButton = ((this.type == "radio") && (this.checked));
if (!clickedRadioButton) {
this.checked = !this.checked;
this.control.updateMap();
}
Event.stop(e);
},
/** Need to update the map accordingly whenever user clicks in either of
@@ -197,7 +189,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
for(var i=0; i < this.baseLayerInputs.length; i++) {
var input = this.baseLayerInputs[i];
if (input.checked) {
this.map.setBaseLayer(input.layer, false);
this.map.setBaseLayer(input.layer, true);
}
}
@@ -279,8 +271,6 @@ OpenLayers.Control.LayerSwitcher.prototype =
Event.observe(this.div, "mouseup",
this.mouseUp.bindAsEventListener(this));
Event.observe(this.div, "click",
this.ignoreEvent);
Event.observe(this.div, "mousedown",
this.mouseDown.bindAsEventListener(this));
Event.observe(this.div, "dblclick", this.ignoreEvent);
@@ -311,9 +301,8 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.baseLayersDiv = document.createElement("div");
this.baseLayersDiv.style.paddingLeft = "10px";
/*Event.observe(this.baseLayersDiv, "click",
Event.observe(this.baseLayersDiv, "click",
this.onLayerClick.bindAsEventListener(this));
*/
this.layersDiv.appendChild(this.baseLayersDiv);
@@ -326,9 +315,8 @@ OpenLayers.Control.LayerSwitcher.prototype =
this.dataLayersDiv = document.createElement("div");
this.dataLayersDiv.style.paddingLeft = "10px";
/*Event.observe(this.dataLayersDiv, "click",
Event.observe(this.dataLayersDiv, "click",
this.onLayerClick.bindAsEventListener(this));
*/
this.layersDiv.appendChild(this.dataLayersDiv);
this.div.appendChild(this.layersDiv);

View File

@@ -60,7 +60,6 @@ OpenLayers.Control.MouseDefaults.prototype =
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 1);
Event.stop(evt);
return false;
},
/**
@@ -125,24 +124,20 @@ OpenLayers.Control.MouseDefaults.prototype =
defaultMouseUp: function (evt) {
if (!Event.isLeftClick(evt)) return;
if (this.zoomBox) {
if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
}
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
} else {
if (this.performedDrag) {
this.map.setCenter(this.map.center);

View File

@@ -35,7 +35,6 @@ OpenLayers.Control.MouseToolbar.prototype =
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
this.buttons = new Object();
this.map.events.register( "click", this, this.defaultClick );
this.map.events.register( "dblclick", this, this.defaultDblClick );
this.map.events.register( "mousedown", this, this.defaultMouseDown );
this.map.events.register( "mouseup", this, this.defaultMouseUp );
@@ -47,6 +46,7 @@ OpenLayers.Control.MouseToolbar.prototype =
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan.");
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
this._addButton("measure", "measuring-stick-off.png", "measuring-stick-on.png", centered, sz, "Hold alt when clicking to show distance between selected points");
this.switchModeTo("pan");
this.map.events.register("zoomend", this, function() { this.switchModeTo("pan"); });
return this.div;
@@ -69,7 +69,6 @@ OpenLayers.Control.MouseToolbar.prototype =
btn.events = new OpenLayers.Events(this, btn);
btn.events.register("mousedown", this, this.buttonClick);
btn.events.register("mouseup", this, Event.stop);
btn.events.register("click", this, Event.stop);
btn.action = id;
btn.title = title;
btn.alt = title;
@@ -94,8 +93,6 @@ OpenLayers.Control.MouseToolbar.prototype =
this.performedDrag = false;
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 2);
Event.stop(evt);
return false;
},
/**
@@ -147,7 +144,6 @@ OpenLayers.Control.MouseToolbar.prototype =
"absolute");
this.measureBox.style.width="4px";
this.measureBox.style.height="4px";
this.measureBox.style.fontSize = "1px";
this.measureBox.style.backgroundColor="red";
this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.layerContainerDiv.appendChild(this.measureBox);
@@ -239,25 +235,18 @@ OpenLayers.Control.MouseToolbar.prototype =
if (!Event.isLeftClick(evt)) return;
switch (this.mode) {
case "zoombox":
console.log(this.mouseDragStart, evt.xy);
console.log(Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || Math.abs((this.mouseDragStart.y - evt.xy.y)) > 5);
console.log(Math.abs(this.mouseDragStart.x-evt.xy.x) > 5);
console.log(Math.abs(this.mouseDragStart.y-evt.xy.y)>5);
if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
}
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
this.leaveMode();
@@ -277,12 +266,6 @@ OpenLayers.Control.MouseToolbar.prototype =
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.defaultMouseUp(evt);
}
},
defaultClick: function (evt) {
if (this.performedDrag) {
this.performedDrag = false;
return false;
}
}
});

View File

@@ -25,33 +25,19 @@ OpenLayers.Control.PanZoomBar.prototype =
OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments);
this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoomBar.X,
OpenLayers.Control.PanZoomBar.Y);
// put code here to catch "changebaselayer" event from map, because
// we are going to have to redraw this thing each time, because
// maxZoom will/might change.
},
/**
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);
this.map.events.register("changebaselayer", this, this.redraw);
},
/** clear the div and start over.
*
*/
redraw: function() {
if (this.div != null) {
this.div.innerHTML = "";
}
this.draw();
},
/**
* @param {OpenLayers.Pixel} px
*/
draw: function(px) {
// initialize our internal div
OpenLayers.Control.prototype.draw.apply(this, arguments);
px = this.position.clone();
px = this.position;
// place the controls
this.buttons = new Array();
@@ -77,9 +63,9 @@ OpenLayers.Control.PanZoomBar.prototype =
var imgLocation = OpenLayers.Util.getImagesLocation();
var id = "OpenLayers_Control_PanZoomBar_Slider" + this.map.id;
var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();
var slider = OpenLayers.Util.createAlphaImageDiv(id,
centered.add(-1, zoomsToEnd * this.zoomStopHeight),
centered.add(-1,
(this.map.getMaxZoomLevel())*this.zoomStopHeight),
new OpenLayers.Size(20,9),
imgLocation+"slider.png",
"absolute");
@@ -93,7 +79,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.sliderEvents.register("click", this, this.doubleClick);
sz = new OpenLayers.Size();
sz.h = this.zoomStopHeight * this.map.getNumZoomLevels();
sz.h = this.zoomStopHeight*(this.map.getMaxZoomLevel()+1);
sz.w = this.zoomStopWidth;
var div = null
@@ -129,7 +115,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.map.events.register("zoomend", this, this.moveZoomBar);
centered = centered.add(0,
this.zoomStopHeight * this.map.getNumZoomLevels());
this.zoomStopHeight*(this.map.getMaxZoomLevel()+1));
return centered;
},
/*
@@ -150,7 +136,7 @@ OpenLayers.Control.PanZoomBar.prototype =
var y = evt.xy.y;
var top = Position.page(evt.object)[1];
var levels = Math.floor((y - top)/this.zoomStopHeight);
this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels);
this.map.zoomTo(this.map.getMaxZoomLevel() - levels);
Event.stop(evt);
},
@@ -197,8 +183,8 @@ OpenLayers.Control.PanZoomBar.prototype =
if (!Event.isLeftClick(evt)) return;
if (this.zoomStart) {
this.div.style.cursor="default";
this.map.events.unregister("mouseup", this, this.passEventToSlider);
this.map.events.unregister("mousemove", this, this.passEventToSlider);
this.map.events.remove("mousemove");
this.map.events.remove("mouseup");
var deltaY = this.zoomStart.y - evt.xy.y
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
this.moveZoomBar();
@@ -212,8 +198,8 @@ OpenLayers.Control.PanZoomBar.prototype =
*/
moveZoomBar:function() {
var newTop =
((this.map.getNumZoomLevels()-1) - this.map.getZoom()) *
this.zoomStopHeight + this.startTop + 1;
(this.map.getMaxZoomLevel() - this.map.getZoom()) * this.zoomStopHeight
+ this.startTop + 1;
this.slider.style.top = newTop + "px";
},

View File

@@ -48,8 +48,9 @@ OpenLayers.Feature.WFS.prototype =
//this should be overridden by subclasses
// must return an Object with 'id' and 'lonlat' values set
var point = xmlNode.getElementsByTagName("Point");
var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]);
var text = OpenLayers.Util.getXmlNodeValue(point[0]);
var floats = text.split(",");
return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
parseFloat(floats[1])),
id: null};

View File

@@ -51,7 +51,10 @@ OpenLayers.Layer.prototype = {
maxResolution: null,
/** @type int */
numZoomLevels: null,
minZoomLevel: null,
/** @type int */
maxZoomLevel: null,
/** @type float */
minScale: null,
@@ -145,12 +148,6 @@ OpenLayers.Layer.prototype = {
Object.extend(this, this.options);
},
/**
*
*/
onMapResize: function() {
//this function can be implemented by subclasses
},
/**
* @param {OpenLayers.Bounds} bound
@@ -166,21 +163,18 @@ OpenLayers.Layer.prototype = {
* so that subclasses can override this and take special action once
* they have their map variable set.
*
* Here we take care to bring over any of the necessary default properties
* from the map.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
this.map = map;
var properties = new Array(
'projection', 'units',
'scales', 'resolutions',
'maxScale', 'minScale',
'projection', 'minExtent', 'maxExtent',
'minScale', 'maxScale',
'maxResolution', 'minResolution',
'minExtent', 'maxExtent',
'numZoomLevels'
'minZoomLevel', 'maxZoomLevel', 'units',
'scales', 'resolutions'
);
for(var i=0; i < properties.length; i++) {
if (this[properties[i]] == null) {
@@ -226,16 +220,6 @@ OpenLayers.Layer.prototype = {
/* */
/********************************************************/
/**
* @param {Boolean} isBaseLayer
*/
setIsBaseLayer: function(isBaseLayer) {
this.isBaseLayer = isBaseLayer;
if (this.map != null) {
this.map.events.triggerEvent("changelayer");
}
},
/**
* @type String
*/
@@ -258,11 +242,19 @@ OpenLayers.Layer.prototype = {
},
/**
* @returns The total number of zoom levels this layer can reach
* @returns The minimum zoom level that can be reached in this layer
* @type int
*/
getNumZoomLevels: function() {
return this.numZoomLevels;
getMinZoomLevel: function() {
return this.minZoomLevel;
},
/**
* @returns The maximum zoom level that can be reached in this layer
* @type int
*/
getMaxZoomLevel: function() {
return this.maxZoomLevel;
},
/********************************************************/
@@ -280,7 +272,7 @@ OpenLayers.Layer.prototype = {
*/
getResolution: function() {
var viewSize = this.map.getSize();
var extent = this.getExtent();
var extent = this.map.getExtent();
return Math.max( extent.getWidth() / viewSize.w,
extent.getHeight() / viewSize.h );
},
@@ -324,7 +316,7 @@ OpenLayers.Layer.prototype = {
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var size = this.map.getSize();
var center = this.map.getCenter();
var center = this.map.getCenter(); //map center lon/lat
var res = this.map.getResolution();
var delta_x = viewPortPx.x - (size.w / 2);

View File

@@ -37,6 +37,9 @@ OpenLayers.Layer.EventPane.prototype =
if (arguments.length > 0) {
if (this.pane == null) {
this.pane = OpenLayers.Util.createDiv();
this.pane.style.width = "100%";
this.pane.style.height = "100%";
this.pane.style.backgroundColor = "transparent";
}
}
},
@@ -49,20 +52,15 @@ OpenLayers.Layer.EventPane.prototype =
*/
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
this.pane.style.display = this.div.style.display;
this.pane.style.width="100%";
this.pane.style.height="100%";
if (/MSIE/.test(navigator.userAgent)) {
this.pane.style.background = "url("+OpenLayers.Util.getImagesLocation()+"blank.gif)";
}
if (this.isFixed) {
this.map.viewPortDiv.appendChild(this.pane);
} else {
this.map.layerContainerDiv.appendChild(this.pane);
}
this.map.events.attachToElement(this.pane);
},
/**

View File

@@ -11,6 +11,11 @@ OpenLayers.Layer.GeoRSS = Class.create();
OpenLayers.Layer.GeoRSS.prototype =
Object.extend( new OpenLayers.Layer.Markers(), {
/** GeoRSS layer is never a base layer.
* @type Boolean
*/
isBaseLayer: false,
/** store url of text file
* @type str */
location:null,

View File

@@ -2,8 +2,31 @@
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
if (typeof GMap2 != "undefined") {
/** Hack-on function because GMAPS does not give it to us
*
* @param {GLatLng} gLatLng
*
* @returns A GPoint specifying gLatLng translated into "Container" coords
* @type GPoint
*/
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
// first we translate into "DivPixel"
var gPoint = this.fromLatLngToDivPixel(gLatLng);
// locate the sliding "Div" div
// it seems like "b" is the main div
var div = this.b.firstChild.firstChild;
// adjust by the offset of "Div" and voila!
gPoint.x += div.offsetLeft;
gPoint.y += div.offsetTop;
return gPoint;
};
}
/**
* @class
@@ -26,7 +49,7 @@ OpenLayers.Layer.Google.prototype =
// OPTIONS
/** @type int */
minZoomLevel: 0,
minZoomLevel: -1,
/** @type int */
maxZoomLevel: 16,
@@ -42,8 +65,6 @@ OpenLayers.Layer.Google.prototype =
if (this.maxExtent == null) {
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
}
this.addContainerPxFunction();
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
},
/**
@@ -126,13 +147,6 @@ OpenLayers.Layer.Google.prototype =
}
},
/**
* @param {Event} evt
*/
onMapResize: function() {
this.gmap.checkResize();
},
/** If we can't load the GMap, then display an error message to the
* user and tell them where to go for help.
*
@@ -245,12 +259,6 @@ OpenLayers.Layer.Google.prototype =
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds);
var gZoom = this.gmap.getBoundsZoomLevel(gBounds);
//make sure zoom is within bounds
var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),
this.maxZoomLevel);
zoom = this.getOLZoomFromGZoom(gZoom);
}
return zoom;
@@ -279,7 +287,7 @@ OpenLayers.Layer.Google.prototype =
getOLZoomFromGZoom: function(gZoom) {
var zoom = null;
if (gZoom != null) {
zoom = gZoom - this.minZoomLevel;
zoom = gZoom;
}
return zoom;
},
@@ -294,7 +302,7 @@ OpenLayers.Layer.Google.prototype =
getGZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = olZoom + this.minZoomLevel;
zoom = olZoom;
}
return zoom;
},
@@ -408,34 +416,8 @@ OpenLayers.Layer.Google.prototype =
}
return gLatLngBounds;
},
addContainerPxFunction: function() {
if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) {
/** Hack-on function because GMAPS does not give it to us
*
* @param {GLatLng} gLatLng
*
* @returns A GPoint specifying gLatLng translated into "Container" coords
* @type GPoint
*/
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
// first we translate into "DivPixel"
var gPoint = this.fromLatLngToDivPixel(gLatLng);
// locate the sliding "Div" div
// it seems like "b" is the main div
var div = this.b.firstChild.firstChild;
// adjust by the offset of "Div" and voila!
gPoint.x += div.offsetLeft;
gPoint.y += div.offsetTop;
return gPoint;
};
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Google"
});

View File

@@ -42,6 +42,7 @@ OpenLayers.Layer.Grid.prototype =
destroy: function() {
this.clearGrid();
this.grid = null;
this.alpha = null;
this.tileSize = null;
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
},
@@ -87,6 +88,30 @@ OpenLayers.Layer.Grid.prototype =
}
},
/**
* @param {String} tileID
*
* @returns The OpenLayers.Tile with the corresponding ID from the grid.
* if no tile is found, returns null
* @type OpenLayers.Tile
*/
getTile: function(tileID) {
var foundTile = null;
if (this.grid) {
for(var iRow = 0; iRow < this.grid.length; iRow++) {
var row = this.grid[iRow];
for(var iCol = 0; iCol < row.length; iCol++) {
var tile = row[iCol];
if (tile.id == tileID) {
foundTile = tile;
}
}
}
}
return foundTile;
},
/** This function is called whenever the map is moved. All the moving
* of actual 'tiles' is done by the map, but moveTo's role is to accept
* a bounds and make sure the data that that bounds requires is pre-loaded.
@@ -125,8 +150,6 @@ OpenLayers.Layer.Grid.prototype =
},
/**
* @private
*
* @returns A Bounds object representing the bounds of all the currently
* loaded tiles (including those partially or not at all seen
* onscreen)
@@ -147,7 +170,7 @@ OpenLayers.Layer.Grid.prototype =
},
/**
* @private
*
*/
_initTiles:function() {
var viewSize = this.map.getSize();
@@ -223,16 +246,8 @@ OpenLayers.Layer.Grid.prototype =
this.spiralTileLoad();
},
/**
* @private
/**
*
* Starts at the top right corner of the grid and proceeds in a spiral
* towards the center, adding tiles one at a time to the beginning of a
* queue.
*
* Once all the grid's tiles have been added to the queue, we go back
* and iterate through the queue (thus reversing the spiral order from
* outside-in to inside-out), calling draw() on each tile.
*/
spiralTileLoad: function() {
var tileQueue = new Array();
@@ -264,8 +279,6 @@ OpenLayers.Layer.Grid.prototype =
break;
}
// if the test grid coordinates are within the bounds of the
// grid, get a reference to the tile.
var tile = null;
if ((testRow < this.grid.length) &&
(testCell < this.grid[0].length)) {
@@ -273,16 +286,12 @@ OpenLayers.Layer.Grid.prototype =
}
if ((tile != null) && (!tile.queued)) {
//add tile to beginning of queue, mark it as queued.
tileQueue.unshift(tile);
tile.queued = true;
//restart the directions counter and take on the new coords
directionsTried = 0;
iRow = testRow;
iCell = testCell;
} else {
//need to try to load a tile in a different direction
direction = (direction + 1) % 4;
directionsTried++;
}
@@ -292,7 +301,6 @@ OpenLayers.Layer.Grid.prototype =
for(var i=0; i < tileQueue.length; i++) {
var tile = tileQueue[i]
tile.draw();
//mark tile as unqueued for the next time (since tiles are reused)
tile.queued = false;
}
},
@@ -312,6 +320,67 @@ OpenLayers.Layer.Grid.prototype =
},
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/** Calculates based on resolution, center, and mapsize
*
* @returns A Bounds object which represents the lon/lat bounds of the
* current viewPort.
* @type OpenLayers.Bounds
*/
getExtent: function () {
var extent = null;
var center = this.map.getCenter();
if (center != null) {
var res = this.getResolution();
var size = this.map.getSize();
var w_deg = size.w * res;
var h_deg = size.h * res;
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
center.lat - h_deg / 2,
center.lon + w_deg / 2,
center.lat + h_deg / 2);
}
return extent;
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @return {int}
*/
getZoomForExtent: function (bounds) {
var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize();
var width = bounds.getWidth();
var height = bounds.getHeight();
var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h;
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
var maxZoomLevel = this.map.getMaxZoomLevel();
var minZoomLevel = this.map.getMinZoomLevel();
//make sure zoom is within bounds
zoom = Math.min( Math.max(zoom, minZoomLevel),
maxZoomLevel );
return zoom;
},
/** go through and remove all tiles from the grid, calling
* destroy() on each of them to kill circular references
*
@@ -393,65 +462,6 @@ OpenLayers.Layer.Grid.prototype =
}
},
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/********************************************************/
/** Calculates based on resolution, center, and mapsize
*
* @returns A Bounds object which represents the lon/lat bounds of the
* current viewPort.
* @type OpenLayers.Bounds
*/
getExtent: function () {
var extent = null;
var center = this.map.getCenter();
if (center != null) {
var res = this.map.getResolution();
var size = this.map.getSize();
var w_deg = size.w * res;
var h_deg = size.h * res;
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
center.lat - h_deg / 2,
center.lon + w_deg / 2,
center.lat + h_deg / 2);
}
return extent;
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @return {int}
*/
getZoomForExtent: function (bounds) {
var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize();
var width = bounds.getWidth();
var height = bounds.getHeight();
var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h;
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
//make sure zoom is within bounds
zoom = Math.min( Math.max(zoom, 0),
this.getNumZoomLevels() - 1);
return zoom;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Grid"
});

View File

@@ -36,17 +36,10 @@ OpenLayers.Layer.HTTPRequest.prototype =
this.params = Object.extend( new Object(), params);
},
/** When the layer is added to the map, once it has taken all the
* relevant properties from the map (in Layer.setMap()), we will
* make the call to initialize the layer's resolutions array.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
this.initResolutions();
},
/**
*
*/
@@ -138,83 +131,31 @@ OpenLayers.Layer.HTTPRequest.prototype =
return requestString;
},
/** This method's responsibility is to set up the 'resolutions' array
* for the layer -- this array is what the layer will use to interface
* between the zoom levels of the map and the resolution display of the
* layer.
*
* The user has several options that determine how the array is set up.
*
* For a detailed explanation, see the following wiki from the
* openlayers.org homepage:
*
* http://trac.openlayers.org/wiki/SettingZoomLevels
*
* @private
*/
initResolutions: function() {
if ((this.scales != null) || (this.resolutions != null)) {
//preset levels
if (this.scales != null) {
this.resolutions = new Array();
for(var i = 0; i < this.scales.length; i++) {
this.resolutions[i] =
OpenLayers.Util.getResolutionFromScale(this.scales[i],
this.units);
}
}
this.numZoomLevels = this.resolutions.length;
} else {
//maxResolution and numZoomLevels
if (this.scales != null) {
this.resolutions = new Array();
// determine maxResolution
if (this.minScale) {
this.maxResolution =
OpenLayers.Util.getResolutionFromScale(this.minScale,
this.units);
} else if (this.maxResolution == "auto") {
var viewSize = this.map.getSize();
var wRes = this.maxExtent.getWidth() / viewSize.w;
var hRes = this.maxExtent.getHeight()/ viewSize.h;
this.maxResolution = Math.max(wRes, hRes);
}
// determine minResolution
if (this.maxScale != null) {
this.minResolution =
OpenLayers.Util.getResolutionFromScale(this.maxScale);
} else if ((this.minResolution == "auto") &&
(this.minExtent != null)){
var viewSize = this.map.getSize();
var wRes = this.minExtent.getWidth() / viewSize.w;
var hRes = this.minExtent.getHeight()/ viewSize.h;
this.minResolution = Math.max(wRes, hRes);
}
// determine numZoomLevels
if (this.minResolution != null) {
var ratio = this.maxResolution / this.minResolution;
this.numZoomLevels =
Math.floor(Math.log(ratio) / Math.log(2)) + 1;
}
// now we have numZoomLevels and maxResolution,
// we can populate the resolutions array
for (var i=0; i < this.numZoomLevels; i++) {
this.resolutions.push(this.maxResolution / Math.pow(2, i));
for(var i = 0; i < this.scales.length; i++)
this.resolutions[i] = OpenLayers.Util.getResolutionFromScale(this.scales[i], this.units);
this.maxZoomLevel = this.resolutions.length;
} else if (this.resolutions != null) {
this.maxZoomLevel = this.resolutions.length;
} else {
this.resolutions = new Array();
if (this.minScale)
this.maxResolution = OpenLayers.Util.getResolutionFromScale(this.minScale, this.units);
var maxRes = this.getMaxResolution();
if (this.maxScale) {
/* This will cause this.map.getMaxZoomLevel() to be set the next time
* it is called, which means that the next portion here will succeed. */
var minRes = OpenLayers.Util.getResolutionFromScale(this.maxScale);
this.maxZoomLevel = Math.floor(Math.log(maxRes/minRes) / Math.log(2));
}
for (var i=this.getMinZoomLevel(); i <= this.getMaxZoomLevel(); i++) {
this.resolutions.push(maxRes / Math.pow(2, i));
}
}
},
/**
* @returns The currently selected resolution of the map, taken from the
* resolutions array, indexed by current zoom level.
* @type float
*/
getResolution: function() {
var zoom = this.map.getZoom();

View File

@@ -49,7 +49,7 @@ OpenLayers.Layer.KaMap.prototype =
*/
getURL: function (bounds) {
var mapRes = this.map.getResolution();
var scale = Math.round((this.map.getScale() * 10000)) / 10000;
var scale = this.map.getScale();
var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h);
var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w);
var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h);

View File

@@ -11,6 +11,12 @@ OpenLayers.Layer.Text = Class.create();
OpenLayers.Layer.Text.prototype =
Object.extend( new OpenLayers.Layer.Markers(), {
/** Text layer is never a base layer.
*
* @type Boolean
*/
isBaseLayer: false,
/** store url of text file - this should be specified in the
* "options" hashtable
* @type str */

View File

@@ -14,12 +14,6 @@ OpenLayers.Layer.VirtualEarth.prototype =
/** @type VEMap */
vemap: null,
/** @type int */
minZoomLevel: 1,
/** @type int */
maxZoomLevel: 17,
/**
* @constructor
*
@@ -27,8 +21,6 @@ OpenLayers.Layer.VirtualEarth.prototype =
*/
initialize:function(name) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
},
/**
@@ -208,26 +200,24 @@ OpenLayers.Layer.VirtualEarth.prototype =
*/
getZoomForExtent: function (bounds) {
var zoom = null;
if (this.vemap != null) {
var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize();
var maxRes = this.map.getMaxResolution();
var viewSize = this.map.getSize();
var width = bounds.getWidth();
var height = bounds.getHeight();
var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h;
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
var maxZoomLevel = this.map.getMaxZoomLevel();
var minZoomLevel = this.map.getMinZoomLevel();
var width = bounds.getWidth();
var height = bounds.getHeight();
var degPerPixel = (width > height) ? width / viewSize.w
: height / viewSize.h;
var veZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
Math.log(2) );
//make sure zoom is within bounds
var veZoom = Math.min(Math.max(veZoom, this.minZoomLevel),
this.maxZoomLevel);
zoom = this.getOLZoomFromVEZoom(veZoom);
}
//make sure zoom is within bounds
zoom = Math.min( Math.max(zoom, minZoomLevel),
maxZoomLevel );
return zoom;
},
@@ -255,7 +245,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
getOLZoomFromVEZoom: function(veZoom) {
var zoom = null;
if (veZoom != null) {
zoom = veZoom - this.minZoomLevel;
zoom = veZoom;
}
return zoom;
},
@@ -270,7 +260,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
getVEZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = olZoom + this.minZoomLevel;
zoom = olZoom;
}
return zoom;
},

View File

@@ -18,8 +18,6 @@ OpenLayers.Layer.WFS.prototype =
* @type Boolean
*/
isBaseLayer: false,
buffer: 1,
/** Allow the user to specify special classes for features and tiles.
*
@@ -159,10 +157,10 @@ OpenLayers.Layer.WFS.prototype =
*
* Once params have been changed, we will need to re-init our tiles
*
* @param {Object} newParams Hashtable of new params to use
* @param {Object} params Hashtable of new params to use
*/
mergeNewParams:function(newParams) {
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
mergeNewParams:function(params) {
var upperParams = OpenLayers.Util.upperCaseObject(params);
var newArguments = [upperParams];
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments);

View File

@@ -121,10 +121,10 @@ OpenLayers.Layer.WMS.prototype =
*
* Once params have been changed, we will need to re-init our tiles
*
* @param {Object} newParams Hashtable of new params to use
* @param {Object} params Hashtable of new params to use
*/
mergeNewParams:function(newParams) {
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
mergeNewParams:function(params) {
var upperParams = OpenLayers.Util.upperCaseObject(params);
var newArguments = [upperParams];
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,
newArguments);

View File

@@ -177,11 +177,8 @@ OpenLayers.Layer.WMS.Untiled.prototype =
* @param {Object} newParams
*/
mergeNewParams:function(newParams) {
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
var newArguments = [upperParams];
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
newArguments);
//redraw
arguments);
this.moveTo();
},

View File

@@ -25,11 +25,11 @@ OpenLayers.Layer.WorldWind.prototype =
zoomLevels: null,
initialize: function(name, url, lzd, zoomLevels, params, options) {
initialize: function(name, url, lzd, zoomLevels, params) {
this.lzd = lzd;
this.zoomLevels = zoomLevels;
var newArguments = new Array();
newArguments.push(name, url, params, options);
newArguments.push(name, url, params);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {});
if (arguments.length > 0 && params) {

View File

@@ -78,38 +78,33 @@ OpenLayers.Map.prototype = {
// Options
/** @type OpenLayers.Size */
tileSize: null,
/** @type String */
projection: "EPSG:4326",
/** @type String */
units: 'degrees',
/** @type OpenLayers.Bounds */
maxExtent: null,
/** default max is 360 deg / 256 px, which corresponds to
* zoom level 0 on gmaps
*
* @type float */
maxResolution: 1.40625,
/** @type float */
minResolution: null,
/** @type float */
maxScale: null,
/** @type float */
minScale: null,
/** @type OpenLayers.Bounds */
maxExtent: null,
/** @type OpenLayers.Bounds */
minExtent: null,
/** @type int */
minZoomLevel: 0,
/** @type int */
numZoomLevels: 16,
maxZoomLevel: 16,
/** @type OpenLayers.Size */
tileSize: null,
/** @type String */
units: 'degrees',
/** @type Float */
minScale: null,
/**
@@ -134,8 +129,6 @@ OpenLayers.Map.prototype = {
// the layerContainerDiv is the one that holds all the layers
id = div.id + "_OpenLayers_Container";
this.layerContainerDiv = OpenLayers.Util.createDiv(id);
this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1;
this.viewPortDiv.appendChild(this.layerContainerDiv);
this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES);
@@ -155,7 +148,7 @@ OpenLayers.Map.prototype = {
Event.observe(window, 'resize',
this.updateSize.bindAsEventListener(this));
}
//set the default options
this.setOptions(options);
@@ -214,6 +207,16 @@ OpenLayers.Map.prototype = {
// now add the options declared by the user
// (these will override defaults)
Object.extend(this, options);
// if maxResolution is specified as "auto", calculate it
// based on the maxExtent and the viewSize
//
if (this.maxResolution == "auto" || this.maxResolution == null) {
var maxExtent = this.getMaxExtent();
var viewSize = this.getSize();
this.maxResolution = Math.max(maxExtent.getWidth() / viewSize.w,
maxExtent.getHeight() / viewSize.h );
}
},
/**
@@ -467,18 +470,14 @@ OpenLayers.Map.prototype = {
if (oldSize == null)
this.size = oldSize = newSize;
if (!newSize.equals(oldSize)) {
//notify layers of mapresize
for(var i=0; i < this.layers.length; i++) {
this.layers[i].onMapResize();
}
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
var zoom = this.getZoom();
this.zoom = null;
this.setCenter(center, zoom);
// move the layer container so that the map is still centered
var dx = (newSize.w - oldSize.w) / 2,
dy = (newSize.h - oldSize.h) / 2;
var lcStyle = this.layerContainerDiv.style;
lcStyle.left = (parseInt(lcStyle.left) + dx) + "px";
lcStyle.top = (parseInt(lcStyle.top ) + dy) + "px";
// reset the map center
this.layerContainerOrigin = this.center.clone();
// store the new size
this.size = newSize;
// the div might have moved on the page, also
@@ -644,8 +643,8 @@ OpenLayers.Map.prototype = {
*/
isValidZoomLevel: function(zoomLevel) {
return ( (zoomLevel != null) &&
(zoomLevel >= 0) &&
(zoomLevel < this.getNumZoomLevels()) );
(zoomLevel >= this.getMinZoomLevel()) &&
(zoomLevel <= this.getMaxZoomLevel()) );
},
/**
@@ -681,9 +680,15 @@ OpenLayers.Map.prototype = {
*/
getProjection: function() {
var projection = null;
if (this.baseLayer != null) {
projection = this.baseLayer.getProjection();
}
if (projection == null) {
projection = this.projection;
}
return projection;
},
@@ -693,9 +698,15 @@ OpenLayers.Map.prototype = {
*/
getMaxResolution: function() {
var maxResolution = null;
if (this.baseLayer != null) {
maxResolution = this.baseLayer.getMaxResolution();
}
if (maxResolution == null) {
maxResolution = this.maxResolution;
}
return maxResolution;
},
@@ -704,25 +715,55 @@ OpenLayers.Map.prototype = {
*/
getMaxExtent: function () {
var maxExtent = null;
if (this.baseLayer != null) {
maxExtent = this.baseLayer.getMaxExtent();
}
}
if (maxExtent == null) {
maxExtent = this.maxExtent;
}
return maxExtent;
},
/**
* @returns The total number of zoom levels that can be displayed by the
* current baseLayer.
* @returns The maximum zoom level that can be reached in the map
* @type int
*/
getNumZoomLevels: function() {
var numZoomLevels = null;
getMaxZoomLevel: function() {
var maxZoomLevel = null;
if (this.baseLayer != null) {
numZoomLevels = this.baseLayer.getNumZoomLevels();
maxZoomLevel = this.baseLayer.getMaxZoomLevel();
}
return numZoomLevels;
if (maxZoomLevel == null) {
maxZoomLevel = this.maxZoomLevel;
}
return maxZoomLevel;
},
/**
* @returns The minimum zoom level that can be reached in the map
* @type int
*/
getMinZoomLevel: function() {
var minZoomLevel = null;
if (this.baseLayer != null) {
minZoomLevel = this.baseLayer.getMinZoomLevel();
}
if (minZoomLevel == null) {
minZoomLevel = this.minZoomLevel;
}
return minZoomLevel;
},
/********************************************************/
/* */
/* Baselayer Functions */
@@ -742,6 +783,7 @@ OpenLayers.Map.prototype = {
*/
getExtent: function () {
var extent = null;
if (this.baseLayer != null) {
extent = this.baseLayer.getExtent();
}
@@ -755,6 +797,7 @@ OpenLayers.Map.prototype = {
*/
getResolution: function () {
var resolution = null;
if (this.baseLayer != null) {
resolution = this.baseLayer.getResolution();
}
@@ -768,8 +811,9 @@ OpenLayers.Map.prototype = {
*/
getScale: function () {
var scale = null;
if (this.baseLayer != null) {
var res = this.getResolution();
var res = this.baseLayer.getResolution();
var units = this.baseLayer.units;
scale = res * OpenLayers.INCHES_PER_UNIT[units] *
OpenLayers.DOTS_PER_INCH;
@@ -787,6 +831,7 @@ OpenLayers.Map.prototype = {
*/
getZoomForExtent: function (bounds) {
zoom = null;
if (this.baseLayer != null) {
zoom = this.baseLayer.getZoomForExtent(bounds);
}
@@ -808,9 +853,7 @@ OpenLayers.Map.prototype = {
* @param {int} zoom
*/
zoomTo: function(zoom) {
if (this.isValidZoomLevel(zoom)) {
this.setCenter(null, zoom);
}
this.setCenter(null, zoom);
},
/**
@@ -884,11 +927,7 @@ OpenLayers.Map.prototype = {
* @private
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
if (this.baseLayer != null) {
lonlat = this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
}
return lonlat;
return this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
},
/**
@@ -901,11 +940,7 @@ OpenLayers.Map.prototype = {
* @private
*/
getViewPortPxFromLonLat: function (lonlat) {
var px = null;
if (this.baseLayer != null) {
px = this.baseLayer.getViewPortPxFromLonLat(lonlat);
}
return px;
return this.baseLayer.getViewPortPxFromLonLat(lonlat);
},

View File

@@ -64,9 +64,7 @@ OpenLayers.Tile.Image.prototype =
*/
clear: function() {
OpenLayers.Tile.prototype.clear.apply(this, arguments);
if(this.imgDiv) {
this.imgDiv.style.display = "none";
}
this.imgDiv.style.display = "none";
},
/**

View File

@@ -79,8 +79,8 @@ OpenLayers.Tile.WFS.prototype =
if (this.urls != null) {
for(var i=0; i < this.urls.length; i++) {
var params = { BBOX:this.bounds.toBBOX() };
var url = this.urls[i] + "&" +
var params = { BBOX:bounds.toBBOX() };
var url = this.urls[i] +
OpenLayers.Util.getParameterString(params);
OpenLayers.loadURL(url, null, this, success, failure);
}

View File

@@ -355,8 +355,6 @@ OpenLayers.Util.getXmlNodeValue = function(node) {
Try.these(
function() {
val = node.text;
if (!val)
val = node.textContent;
},
function() {
val = node.textContent;

View File

@@ -1,56 +0,0 @@
OpenLayers 2.0 Release Notes
* Deprecated Methods which were removed:
For details, see r1228
* OpenLayers.Map
* removed: getFullExtent() -- use getMaxExtent() instead
* removed: zoomToFullExtent() -- use zoomToMaxExtent() instead
* OpenLayers.Layer.Grid
* removed: setTileSize() -- user should instead pass a 'tileSize' property
as one of the options when initializing the Grid Layer. ex:
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
var options = {tileSize: new OpenLayers.Size(500,50)};
var map = new OpenLayers.Map('map', options);
layer = new OpenLayers.Layer.WMS(name, url, params);
* OpenLayers.Layer.HTTPRequest
* removed: changeParams() -- use mergeNewParams() instead
* OpenLayers.Pixel
* removed: copyOf() -- use clone() instead
* OpenLayers.Size
* removed: copyOf() -- use clone() instead
* OpenLayers.LonLat
* removed: copyOf() -- use clone() instead
* OpenLayers.Bounds
* removed: copyOf() -- use clone() instead
* Array
* removed: copyOf() -- use clone() instead
* MouseWheel
* It is now possible to zoom in/out with the mouse wheel instead of clicks.
* Spiral Gridding
* Instead of loading from the top to bottom of the map, Openlayers will
now start loading tiles from the center of the map.
* Tile Re-Use
* In order to lower memory constraints and reduce element creation times,
OpenLayers now creates a single set of images/tiles and reuses them as
you scroll around the map.
* New Layer Support
* Google
* Virtual Earth
* GeoRSS (RSS 1.0 and 2.0 in FF, IE, RSS 2.0 in Safari)
* KaMap
* Untiled WMS
* Scale Based Methods
* It is now possible to set zooms based on the concept of scale. See
documentation in the options for the Map constructor.
OpenLayers 1.0
Initial release.

View File

@@ -38,10 +38,7 @@ Using OpenLayers in Your Own Website
The examples/ directory is full of useful examples.
Dcumentation is available in the doc/ directory: to build an HTML version
of the documentation, run ./docs.sh in the build/ directory.
Information on changes in the API is available in news.txt.
There is some documentation at http://trac.openlayers.org/ as well.
--------------------------
Contributing to OpenLayers

View File

@@ -20,11 +20,7 @@
if (!map.getCenter()) map.zoomToMaxExtent();
map.addControl(control);
map.pan(5, 0);
if (/MSIE/.test(navigator.userAgent)) {
t.eq($('permalink').href, "?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
} else {
t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
}
t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink");
}
function test_03_Control_Permalink_updateLinksBase (t) {
t.plan( 2 );

View File

@@ -89,17 +89,19 @@
function test_04_Layer_StandardOptionsAccessors (t) {
t.plan( 4 );
t.plan( 5 );
var projection = "chicken";
var maxExtent = new OpenLayers.Bounds(50,50,100,100);
var maxResolution = 1.5726;
var numZoomLevels = 11;
var minZoomLevel = 5;
var maxZoomLevel = 15;
var options = { projection: projection,
maxExtent: maxExtent,
maxResolution: maxResolution,
numZoomLevels: numZoomLevels
minZoomLevel: minZoomLevel,
maxZoomLevel: maxZoomLevel
};
var layer = new OpenLayers.Layer('Test Layer', options);
@@ -107,7 +109,8 @@
t.eq(layer.getProjection(), projection, "getProjection() works");
t.ok(layer.getMaxExtent().equals(maxExtent), "getMaxExtent() works");
t.eq(layer.getMaxResolution(), maxResolution, "getMaxResolution() works");
t.eq(layer.getNumZoomLevels(), numZoomLevels, "getNumZoomLevels() works");
t.eq(layer.getMinZoomLevel(), minZoomLevel, "getMinZoomLevel() works");
t.eq(layer.getMaxZoomLevel(), maxZoomLevel, "getMaxZoomLevel() works");
}
function test_05_Layer_visibility(t) {

View File

@@ -56,11 +56,7 @@
// MOUSEMOVE test does not seem to work...
// t.plan( 2 );
if (document.createEventObject) {
t.plan(3);
} else {
t.plan(1);
}
t.plan(1);
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.EventPane('Test Layer');

View File

@@ -114,13 +114,13 @@
* -insertColumn
* -insertRow
function 07_Layer_Grid_moveTo(t) {
function test_07_Layer_Grid_moveTo(t) {
}
function 08_Layer_Grid_insertColumn(t) {
function test_08_Layer_Grid_insertColumn(t) {
}
function 09_Layer_Grid_insertRow(t) {
function test_09_Layer_Grid_insertRow(t) {
}
*
@@ -166,15 +166,41 @@
}
function test_11_Layer_Grid_getTile(t) {
t.plan(2);
var options = {tileSize: new OpenLayers.Size(500,50)};
var map = new OpenLayers.Map('map', options);
//test with tile creation
layer = new OpenLayers.Layer.WMS(name, url, params);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
//grab a reference to one of the tiles
var tile = layer.grid[0][0];
var gotTile = layer.getTile(tile.id);
t.ok( gotTile == tile, "got right tile");
gotTile = layer.getTile("chicken");
t.ok( gotTile == null, "getTile() of bogus id returns null");
}
function test_99_Layer_Grid_destroy (t) {
t.plan( 3 );
t.plan( 4 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.Grid(name, url, params);
map.addLayer(layer);
layer.destroy();
t.eq( layer.grid, null, "layer.grid is null after destroy" );
t.eq( layer.alpha, null, "layer.alpha is null after destroy" );
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );

View File

@@ -107,13 +107,13 @@
* -insertColumn
* -insertRow
function 07_Layer_KaMap_moveTo(t) {
function test_07_Layer_KaMap_moveTo(t) {
}
function 08_Layer_KaMap_insertColumn(t) {
function test_08_Layer_KaMap_insertColumn(t) {
}
function 09_Layer_KaMap_insertRow(t) {
function test_09_Layer_KaMap_insertRow(t) {
}
*
@@ -158,15 +158,42 @@
t.ok( (layer.tileSize.h == 50) && (layer.tileSize.w == 500), "tileSize has been set correctly");
}
function test_11_Layer_KaMap_getTile(t) {
t.plan(2);
var options = {tileSize: new OpenLayers.Size(500,50)};
var map = new OpenLayers.Map('map', options);
//test with tile creation
layer = new OpenLayers.Layer.KaMap(name, url, params, units);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
//grab a reference to one of the tiles
var tile = layer.grid[0][0];
var gotTile = layer.getTile(tile.id);
t.ok( gotTile == tile, "got right tile");
gotTile = layer.getTile("chicken");
t.ok( gotTile == null, "getTile() of bogus id returns null");
}
function test_99_Layer_KaMap_destroy (t) {
t.plan( 3 );
t.plan( 4 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.KaMap(name, url, params, units);
map.addLayer(layer);
layer.destroy();
t.eq( layer.grid, null, "layer.grid is null after destroy" );
t.eq( layer.alpha, null, "layer.alpha is null after destroy" );
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );

View File

@@ -27,7 +27,7 @@
t.ok( map.controls instanceof Array, "map.controls is an Array" );
t.ok( map.events instanceof OpenLayers.Events, "map.events is an OpenLayers.Events" );
t.ok( map.getMaxExtent() instanceof OpenLayers.Bounds, "map.maxExtent is an OpenLayers.Bounds" );
t.ok( map.getNumZoomLevels() > 0, "map has a default numZoomLevels" );
t.ok( map.getMaxZoomLevel() > 0, "map.maxZoomLevel is set" );
}
function test_02_Map_center(t) {
t.plan(3);
@@ -63,8 +63,8 @@
}
function test_04_Map_options(t) {
t.plan(2);
map = new OpenLayers.Map($('map'), {numZoomLevels: 6, maxResolution: 3.14159});
t.eq( map.numZoomLevels, 6, "map.numZoomLevels set correctly via options hashtable" );
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: 3.14159});
t.eq( map.maxZoomLevel, 5, "map.maxZoomLevel set correctly via options hashtable" );
t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hashtable" );
}
function test_05_Map_center(t) {
@@ -151,10 +151,18 @@
}
t.ok(!found, "popup.div successfully removed from the map's viewPort");
}
function test_10_Map_auto_res(t) {
t.plan(2);
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: 'auto'});
t.eq( map.maxResolution, 1/3, "map.maxResolution set correctly via auto" );
map = new OpenLayers.Map($('map'), {maxZoomLevel: 5, maxResolution: null});
t.eq( map.maxResolution, 1/3, "map.maxResolution set correctly via null" );
}
/*** THIS IS A GOOD TEST, BUT IT SHOULD BE MOVED TO WMS.
* Also, it won't work until we figure out the viewSize bug
function 08_Map_px_lonlat_translation (t) {
function test_08_Map_px_lonlat_translation (t) {
t.plan( 6 );
map = new OpenLayers.Map($('map'));
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",