From 104e509eb9e98477f2e184c3dd5dc1422c9c9c66 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Fri, 25 Aug 2006 18:17:06 +0000 Subject: [PATCH] Merge 2.0 branch to trunk. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1369 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- build/docs.sh | 36 +++-- doc/Control.Permalink.txt | 2 +- doc/Layer.GeoRSS.txt | 3 +- doc/Layer.WMS.txt | 6 +- examples/google.html | 9 +- examples/kamap.html | 2 +- examples/setextent.html | 29 +++++ examples/test.html | 90 +++++++++++++ examples/tiger.html | 3 +- examples/urban.html | 8 +- examples/ve.html | 11 +- examples/wmst.html | 2 +- examples/zoomLevels.html | 54 ++++++++ img/blank.gif | Bin 0 -> 42 bytes lib/OpenLayers/BaseTypes.js | 4 +- lib/OpenLayers/Control/LayerSwitcher.js | 32 +++-- lib/OpenLayers/Control/MouseDefaults.js | 54 +++++--- lib/OpenLayers/Control/MouseToolbar.js | 50 +++---- lib/OpenLayers/Control/PanZoomBar.js | 44 ++++--- lib/OpenLayers/Feature/WFS.js | 3 +- lib/OpenLayers/Layer.js | 55 ++++---- lib/OpenLayers/Layer/EventPane.js | 11 +- lib/OpenLayers/Layer/GeoRSS.js | 5 - lib/OpenLayers/Layer/Google.js | 78 ++++++----- lib/OpenLayers/Layer/Grid.js | 166 +++++++++++------------- lib/OpenLayers/Layer/HTTPRequest.js | 95 +++++++++++--- lib/OpenLayers/Layer/KaMap.js | 2 +- lib/OpenLayers/Layer/Text.js | 6 - lib/OpenLayers/Layer/VirtualEarth.js | 48 ++++--- lib/OpenLayers/Layer/WFS.js | 8 +- lib/OpenLayers/Layer/WMS.js | 6 +- lib/OpenLayers/Layer/WMS/Untiled.js | 5 +- lib/OpenLayers/Layer/WorldWind.js | 4 +- lib/OpenLayers/Map.js | 157 +++++++++------------- lib/OpenLayers/Tile/Image.js | 4 +- lib/OpenLayers/Tile/WFS.js | 4 +- lib/OpenLayers/Util.js | 2 + news.txt | 56 ++++++++ readme.txt | 5 +- tests/list-tests.html | 1 + tests/test_Control_MouseToolbar.html | 55 ++++++++ tests/test_Control_Permalink.html | 6 +- tests/test_Layer.html | 11 +- tests/test_Layer_EventPane.html | 6 +- tests/test_Layer_Grid.html | 34 +---- tests/test_Layer_KaMap.html | 35 +---- tests/test_Map.html | 16 +-- 47 files changed, 840 insertions(+), 483 deletions(-) create mode 100644 examples/setextent.html create mode 100644 examples/test.html create mode 100644 examples/zoomLevels.html create mode 100644 img/blank.gif create mode 100644 news.txt create mode 100644 tests/test_Control_MouseToolbar.html diff --git a/build/docs.sh b/build/docs.sh index 9ee82dac83..07c7917f06 100755 --- a/build/docs.sh +++ b/build/docs.sh @@ -2,9 +2,18 @@ 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 "OpenLayers Class Reference Documentation" >> ../doc/reference.html +echo " + + OpenLayers Class Reference Documentation + + + " >> ../doc/reference.html for i in $CLASSES; do echo "
OpenLayers.$i
" >> ../doc/reference.html @@ -14,16 +23,17 @@ echo "
" >> ../doc/reference.html for i in $CLASSES; do cat ../doc/$i.txt | \ -perl -pe 's!^(.*?) -- (.*?) -- (.*?)$! $1$2$3!g' | \ -perl -pe 's!^( \* )?(.*?) -- (.*?)$! $2$3!g' | \ -perl -pe 's!^ \* (.*)$! \n\n

$1

\n !' | \ -perl -pe 's!{OpenLayers.(.*?)\|(.*?)}!\2!g' | \ -perl -pe 's!{OpenLayers.(.*?)}!OpenLayers.$1!' | \ -perl -pe 's!{([A-Za-z]+?)\|(.+?)}!\2<\/span>!g' | \ -perl -pe 's!{([A-Za-z]+?)}!$1<\/span>!g' | \ -perl -pe 's!^\* (.*)$!
\n

$1

\n!' | \ -perl -pe 's!^OpenLayers\.(.*)$!

OpenLayers.$1

!' \ +perl -pe 's!^(.*?) -- (.*?) -- (.*?)$!
!g; + s!^( \* )?(.*?) -- (.*?)$! !g; + s!^ \* (.*)$!
$1$2$3
$2$3
\n\n

$1

\n !; + s!{OpenLayers.(.*?)\|(.*?)}!\2!g; + s!{OpenLayers.(.*?)}!OpenLayers.$1!; + s!{([A-Za-z]+?)\|(.+?)}!\2<\/span>!g; + s!{([A-Za-z]+?)}!$1<\/span>!g; + s!^\* (.*)$!
\n

$1

\n!; + s!^OpenLayers\.(.*)$!

OpenLayers.$1

!' \ >> ../doc/reference.html echo '
' >> ../doc/reference.html done -echo "" >> ../doc/reference.html +echo " +" >> ../doc/reference.html diff --git a/doc/Control.Permalink.txt b/doc/Control.Permalink.txt index f696959048..aa0a0b81b2 100644 --- a/doc/Control.Permalink.txt +++ b/doc/Control.Permalink.txt @@ -1,6 +1,6 @@ OpenLayers.Control.Permalink -A small control which updates a "Permalink" to the map every time the viewport changes. This allows users to copy a link to a specfic map view. By default, it places itself in the lower right corner of the map, +A small control which updates a "Permalink" to the map every time the viewport changes. This allows users to copy a link to a specfic map view. By default, it places itself in the lower right corner of the map. This control must be added to the map after a baselayer has been set. * Constructor OpenLayers.Control.Scale({DOMElement|element}?, {String|base}) -- Creates a new permalink control. The DOMElement is used, if passed, as the element on which the 'href' is set. If you prefer to put this link on an element outside of the map, set this element to an anchor element to have its href updated when the map moves. If you wish to make the link go to some other URL (for example, an editing interface rather than the current URL), the 'base' property can be used, to which the ?lat=&lon=&zoom= will be appended after the map has moved. diff --git a/doc/Layer.GeoRSS.txt b/doc/Layer.GeoRSS.txt index a38c77ba57..6f61629e9b 100644 --- a/doc/Layer.GeoRSS.txt +++ b/doc/Layer.GeoRSS.txt @@ -1,6 +1,7 @@ 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. +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.) + * Constructor OpenLayers.Layer.GeoRSS(name, url) -- Name and location of GeoRSS XML file. diff --git a/doc/Layer.WMS.txt b/doc/Layer.WMS.txt index dc4d374d01..edf0da8e0c 100644 --- a/doc/Layer.WMS.txt +++ b/doc/Layer.WMS.txt @@ -1,6 +1,8 @@ OpenLayers.Layer.WMS -The WMS layer allows one to connect to a WMS server to obtain images. +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. * 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. @@ -9,5 +11,5 @@ The WMS layer allows one to connect to a WMS server to obtain images. 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} -* Parameters +* Options isBaseLayer -- WMS layers default to being base layers unless one of their parameters is 'transparent':'true'. diff --git a/examples/google.html b/examples/google.html index 611cc0b51b..5b8495b9ab 100644 --- a/examples/google.html +++ b/examples/google.html @@ -23,20 +23,23 @@ var map, layer; function init(){ - map = new OpenLayers.Map( $('map') ); + map = new OpenLayers.Map( $('map') , + { controls: [new OpenLayers.Control.MouseDefaults()] }); - var normal = new OpenLayers.Layer.Google( "Google" ); + var normal = new OpenLayers.Layer.Google( "Google", // ); + { minZoomLevel: 3, maxZoomLevel: 8 }); 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([normal, satellite, hybrid]); + map.addLayers([satellite, normal, 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() ); } diff --git a/examples/kamap.html b/examples/kamap.html index 8f1cacf235..d2798e5c84 100644 --- a/examples/kamap.html +++ b/examples/kamap.html @@ -18,7 +18,7 @@ {layers: 'basic'} ); var jpl_wms = new OpenLayers.Layer.KaMap( "Satellite", - "/world/index.php", {g: "satellite", map: "world"}); + "http://www.openlayers.org/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," + diff --git a/examples/setextent.html b/examples/setextent.html new file mode 100644 index 0000000000..d90f7b820e --- /dev/null +++ b/examples/setextent.html @@ -0,0 +1,29 @@ + + +Setting a visual Extent + + + +

Setting a Visual Extent

+

+ 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. +

+
+ + + diff --git a/examples/test.html b/examples/test.html new file mode 100644 index 0000000000..ff3cfcaf46 --- /dev/null +++ b/examples/test.html @@ -0,0 +1,90 @@ + + + + + + + +
The idea here is to simulate the layerswitcher radiobuttons UI + without all the overhead of openlayers. +
+
+ There are event handlers attached to the following elements: +
+ * Body - Prints message "clicked body" to message area +
+ * Blue Div - Prints message "clicked div" to message area, stops + the event propagation, prints a message with the + status of the two radiobuttons +
+ * Radio One - Prints message "clicked one" to message area +
+ * Radio Two - Prints message "clicked two" to message area +
+
+ + 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!?! + +
+ +
+ + one +
+ + two +
+ +
+ Events: +
+ + + \ No newline at end of file diff --git a/examples/tiger.html b/examples/tiger.html index 7c3520e822..271a293e25 100644 --- a/examples/tiger.html +++ b/examples/tiger.html @@ -14,11 +14,12 @@ 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' }, 'degrees', 72 ); + "http://boston.freemap.in/tile.php" , { map: 'tiger', layers: 'TIGER' }); 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()); diff --git a/examples/urban.html b/examples/urban.html index ed2156b3fd..6531b10fd7 100644 --- a/examples/urban.html +++ b/examples/urban.html @@ -11,15 +11,15 @@ + + + +
+ + diff --git a/img/blank.gif b/img/blank.gif new file mode 100644 index 0000000000000000000000000000000000000000..4bcc753a12e9854923af4b9b5b9a4b76f1bc53a6 GIT binary patch literal 42 ocmZ?wbhEHbWMp7uXkY+=|Ns9h{$ybUF?B!$NXCJQ(S^Yp0J?7nHvj+t literal 0 HcmV?d00001 diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index 0fc0a2889f..5e06a464b5 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -420,8 +420,8 @@ OpenLayers.Bounds.prototype = { * @type OpenLayers.Bounds */ add:function(x, y){ - return new OpenLayers.Box(this.left + x, this.bottom + y, - this.right + x, this.top + y); + return new OpenLayers.Bounds(this.left + x, this.bottom + y, + this.right + x, this.top + y); }, /** diff --git a/lib/OpenLayers/Control/LayerSwitcher.js b/lib/OpenLayers/Control/LayerSwitcher.js index 68c334cdcb..2a1e406231 100644 --- a/lib/OpenLayers/Control/LayerSwitcher.js +++ b/lib/OpenLayers/Control/LayerSwitcher.js @@ -119,16 +119,18 @@ 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.onLabelClick.bindAsEventListener(inputElem)); - + Event.observe(labelSpan, "click", + this.onInputClick.bindAsEventListener(inputElem)); // create line break var br = document.createElement("br"); @@ -158,11 +160,17 @@ OpenLayers.Control.LayerSwitcher.prototype = * * @param {Event} e */ - onLabelClick: function(e) { - var clickedRadioButton = ((this.type == "radio") && (this.checked)); - if (!clickedRadioButton) { + + onInputClick: function(e) { + if (this.type == "radio") { + this.checked = true; + this.layer.map.setBaseLayer(this.layer, true); + this.layer.map.events.triggerEvent("changebaselayer"); + } else { this.checked = !this.checked; + this.control.updateMap(); } + Event.stop(e); }, /** Need to update the map accordingly whenever user clicks in either of @@ -189,7 +197,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, true); + this.map.setBaseLayer(input.layer, false); } } @@ -271,6 +279,8 @@ 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); @@ -301,8 +311,9 @@ 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); @@ -315,8 +326,9 @@ 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); diff --git a/lib/OpenLayers/Control/MouseDefaults.js b/lib/OpenLayers/Control/MouseDefaults.js index 2cf7854b4e..692c0d35b3 100644 --- a/lib/OpenLayers/Control/MouseDefaults.js +++ b/lib/OpenLayers/Control/MouseDefaults.js @@ -60,6 +60,7 @@ OpenLayers.Control.MouseDefaults.prototype = var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); this.map.setCenter(newCenter, this.map.zoom + 1); Event.stop(evt); + return false; }, /** @@ -80,6 +81,7 @@ OpenLayers.Control.MouseDefaults.prototype = this.zoomBox.style.backgroundColor = "white"; this.zoomBox.style.filter = "alpha(opacity=50)"; // IE this.zoomBox.style.opacity = "0.50"; + this.zoomBox.style.fontSize = "1px"; this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.map.viewPortDiv.appendChild(this.zoomBox); } @@ -95,8 +97,8 @@ OpenLayers.Control.MouseDefaults.prototype = if (this.zoomBox) { var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); - this.zoomBox.style.width = deltaX+"px"; - this.zoomBox.style.height = deltaY+"px"; + this.zoomBox.style.width = Math.max(1, deltaX) + "px"; + this.zoomBox.style.height = Math.max(1, deltaY) + "px"; if (evt.xy.x < this.mouseDragStart.x) { this.zoomBox.style.left = evt.xy.x+"px"; } @@ -124,20 +126,7 @@ OpenLayers.Control.MouseDefaults.prototype = defaultMouseUp: function (evt) { if (!Event.isLeftClick(evt)) return; if (this.zoomBox) { - 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.zoomBoxEnd(evt); } else { if (this.performedDrag) { this.map.setCenter(this.map.center); @@ -173,6 +162,37 @@ OpenLayers.Control.MouseDefaults.prototype = this.map.zoomOut(); }, + /** Zoombox function. + * + */ + zoomBoxEnd: function(evt) { + if (this.mouseDragStart != null) { + 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); + } else { + var end = this.map.getLonLatFromViewPortPx( evt.xy ); + this.map.setCenter(new OpenLayers.LonLat( + (end.lon), + (end.lat) + ), this.map.getZoom() + 1); + } + this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); + this.zoomBox = null; + } + }, + /** * Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/ @@ -189,7 +209,7 @@ OpenLayers.Control.MouseDefaults.prototype = var inMap = false; var elem = Event.element(e); while(elem != null) { - if (elem == this.map.div) { + if (this.map && elem == this.map.div) { inMap = true; break; } diff --git a/lib/OpenLayers/Control/MouseToolbar.js b/lib/OpenLayers/Control/MouseToolbar.js index e03e0652b4..99158913be 100644 --- a/lib/OpenLayers/Control/MouseToolbar.js +++ b/lib/OpenLayers/Control/MouseToolbar.js @@ -6,12 +6,14 @@ * @class * * @requires OpenLayers/Control.js + * @requires OpenLayers/Control/MouseDefaults.js */ OpenLayers.Control.MouseToolbar = Class.create(); OpenLayers.Control.MouseToolbar.X = 6; OpenLayers.Control.MouseToolbar.Y = 300; OpenLayers.Control.MouseToolbar.prototype = - Object.extend( new OpenLayers.Control(), { + Object.extend( new OpenLayers.Control(), + Object.extend( new OpenLayers.Control.MouseDefaults(), { mode: null, @@ -35,6 +37,7 @@ 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 ); @@ -46,9 +49,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,6 +70,7 @@ 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; @@ -93,6 +95,8 @@ 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; }, /** @@ -102,8 +106,10 @@ OpenLayers.Control.MouseToolbar.prototype = if (!Event.isLeftClick(evt)) return; this.mouseDragStart = evt.xy.clone(); this.performedDrag = false; + this.startViaKeyboard = false; if (evt.shiftKey && this.mode !="zoombox") { this.switchModeTo("zoombox"); + this.startViaKeyboard = true; } else if (evt.altKey && this.mode !="measure") { this.switchModeTo("measure"); } else if (!this.mode) { @@ -122,8 +128,10 @@ OpenLayers.Control.MouseToolbar.prototype = this.zoomBox.style.backgroundColor = "white"; this.zoomBox.style.filter = "alpha(opacity=50)"; // IE this.zoomBox.style.opacity = "0.50"; + this.zoomBox.style.fontSize = "1px"; this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.map.viewPortDiv.appendChild(this.zoomBox); + this.performedDrag = true; break; case "measure": var distance = ""; @@ -144,6 +152,7 @@ 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); @@ -175,7 +184,7 @@ OpenLayers.Control.MouseToolbar.prototype = switchModeTo: function(mode) { if (mode != this.mode) { - if (this.mode) { + if (this.mode && this.buttons[this.mode]) { OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation); } if (this.mode == "measure" && mode != "measure") { @@ -188,7 +197,9 @@ OpenLayers.Control.MouseToolbar.prototype = this.measureStart = null; } this.mode = mode; - OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation); + if (this.buttons[mode]) { + OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation); + } } }, @@ -205,8 +216,8 @@ OpenLayers.Control.MouseToolbar.prototype = case "zoombox": var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); - this.zoomBox.style.width = deltaX+"px"; - this.zoomBox.style.height = deltaY+"px"; + this.zoomBox.style.width = Math.max(1, deltaX) + "px"; + this.zoomBox.style.height = Math.max(1, deltaY) + "px"; if (evt.xy.x < this.mouseDragStart.x) { this.zoomBox.style.left = evt.xy.x+"px"; } @@ -235,21 +246,8 @@ OpenLayers.Control.MouseToolbar.prototype = if (!Event.isLeftClick(evt)) return; switch (this.mode) { case "zoombox": - 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(); + this.zoomBoxEnd(evt); + if (this.startViaKeyboard) this.leaveMode(); break; case "pan": if (this.performedDrag) { @@ -266,6 +264,12 @@ 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; + } } -}); +})); diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index 8a7e01de43..707ee1bd09 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -25,19 +25,33 @@ 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; + px = this.position.clone(); // place the controls this.buttons = new Array(); @@ -63,9 +77,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, - (this.map.getMaxZoomLevel())*this.zoomStopHeight), + centered.add(-1, zoomsToEnd * this.zoomStopHeight), new OpenLayers.Size(20,9), imgLocation+"slider.png", "absolute"); @@ -79,7 +93,7 @@ OpenLayers.Control.PanZoomBar.prototype = this.sliderEvents.register("click", this, this.doubleClick); sz = new OpenLayers.Size(); - sz.h = this.zoomStopHeight*(this.map.getMaxZoomLevel()+1); + sz.h = this.zoomStopHeight * this.map.getNumZoomLevels(); sz.w = this.zoomStopWidth; var div = null @@ -115,7 +129,7 @@ OpenLayers.Control.PanZoomBar.prototype = this.map.events.register("zoomend", this, this.moveZoomBar); centered = centered.add(0, - this.zoomStopHeight*(this.map.getMaxZoomLevel()+1)); + this.zoomStopHeight * this.map.getNumZoomLevels()); return centered; }, /* @@ -136,7 +150,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.getMaxZoomLevel() - levels); + this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels); Event.stop(evt); }, @@ -170,8 +184,8 @@ OpenLayers.Control.PanZoomBar.prototype = this.slider.style.top = newTop+"px"; } this.mouseDragStart = evt.xy.clone(); + Event.stop(evt); } - Event.stop(evt); }, /* @@ -183,8 +197,8 @@ OpenLayers.Control.PanZoomBar.prototype = if (!Event.isLeftClick(evt)) return; if (this.zoomStart) { this.div.style.cursor="default"; - this.map.events.remove("mousemove"); - this.map.events.remove("mouseup"); + this.map.events.unregister("mouseup", this, this.passEventToSlider); + this.map.events.unregister("mousemove", this, this.passEventToSlider); var deltaY = this.zoomStart.y - evt.xy.y this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight)); this.moveZoomBar(); @@ -198,8 +212,8 @@ OpenLayers.Control.PanZoomBar.prototype = */ moveZoomBar:function() { var newTop = - (this.map.getMaxZoomLevel() - this.map.getZoom()) * this.zoomStopHeight - + this.startTop + 1; + ((this.map.getNumZoomLevels()-1) - this.map.getZoom()) * + this.zoomStopHeight + this.startTop + 1; this.slider.style.top = newTop + "px"; }, diff --git a/lib/OpenLayers/Feature/WFS.js b/lib/OpenLayers/Feature/WFS.js index c92469f6be..7255e61636 100644 --- a/lib/OpenLayers/Feature/WFS.js +++ b/lib/OpenLayers/Feature/WFS.js @@ -48,9 +48,8 @@ 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]); + var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]); var floats = text.split(","); - return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]), parseFloat(floats[1])), id: null}; diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 483c53930d..686dc83426 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -51,10 +51,7 @@ OpenLayers.Layer.prototype = { maxResolution: null, /** @type int */ - minZoomLevel: null, - - /** @type int */ - maxZoomLevel: null, + numZoomLevels: null, /** @type float */ minScale: null, @@ -148,6 +145,12 @@ OpenLayers.Layer.prototype = { Object.extend(this, this.options); }, + /** + * + */ + onMapResize: function() { + //this function can be implemented by subclasses + }, /** * @param {OpenLayers.Bounds} bound @@ -163,19 +166,25 @@ 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', 'minExtent', 'maxExtent', - 'minScale', 'maxScale', + 'projection', 'units', + 'scales', 'resolutions', + 'maxScale', 'minScale', 'maxResolution', 'minResolution', - 'minZoomLevel', 'maxZoomLevel', 'units', - 'scales', 'resolutions' - + 'minExtent', 'maxExtent', + 'numZoomLevels' ); + if (this.map.maxZoomLevel && !this.numZoomLevels) { + this.numZoomLevels = this.map.maxZoomLevel + 1; + } for(var i=0; i < properties.length; i++) { if (this[properties[i]] == null) { this[properties[i]] = this.map[properties[i]]; @@ -220,6 +229,16 @@ OpenLayers.Layer.prototype = { /* */ /********************************************************/ + /** + * @param {Boolean} isBaseLayer + */ + setIsBaseLayer: function(isBaseLayer) { + this.isBaseLayer = isBaseLayer; + if (this.map != null) { + this.map.events.triggerEvent("changelayer"); + } + }, + /** * @type String */ @@ -242,19 +261,11 @@ OpenLayers.Layer.prototype = { }, /** - * @returns The minimum zoom level that can be reached in this layer + * @returns The total number of zoom levels this layer can reach * @type int */ - getMinZoomLevel: function() { - return this.minZoomLevel; - }, - - /** - * @returns The maximum zoom level that can be reached in this layer - * @type int - */ - getMaxZoomLevel: function() { - return this.maxZoomLevel; + getNumZoomLevels: function() { + return this.numZoomLevels; }, /********************************************************/ @@ -272,7 +283,7 @@ OpenLayers.Layer.prototype = { */ getResolution: function() { var viewSize = this.map.getSize(); - var extent = this.map.getExtent(); + var extent = this.getExtent(); return Math.max( extent.getWidth() / viewSize.w, extent.getHeight() / viewSize.h ); }, @@ -316,7 +327,7 @@ OpenLayers.Layer.prototype = { */ getLonLatFromViewPortPx: function (viewPortPx) { var size = this.map.getSize(); - var center = this.map.getCenter(); //map center lon/lat + var center = this.map.getCenter(); var res = this.map.getResolution(); var delta_x = viewPortPx.x - (size.w / 2); diff --git a/lib/OpenLayers/Layer/EventPane.js b/lib/OpenLayers/Layer/EventPane.js index da2102dbc0..4d7ef493e8 100644 --- a/lib/OpenLayers/Layer/EventPane.js +++ b/lib/OpenLayers/Layer/EventPane.js @@ -37,9 +37,6 @@ 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"; } } }, @@ -52,9 +49,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 { diff --git a/lib/OpenLayers/Layer/GeoRSS.js b/lib/OpenLayers/Layer/GeoRSS.js index c9a6285a9b..49d44df71b 100644 --- a/lib/OpenLayers/Layer/GeoRSS.js +++ b/lib/OpenLayers/Layer/GeoRSS.js @@ -11,11 +11,6 @@ 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, diff --git a/lib/OpenLayers/Layer/Google.js b/lib/OpenLayers/Layer/Google.js index 922b069a9d..e59a49862b 100644 --- a/lib/OpenLayers/Layer/Google.js +++ b/lib/OpenLayers/Layer/Google.js @@ -2,31 +2,8 @@ * 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 @@ -49,7 +26,7 @@ OpenLayers.Layer.Google.prototype = // OPTIONS /** @type int */ - minZoomLevel: -1, + minZoomLevel: 0, /** @type int */ maxZoomLevel: 16, @@ -65,6 +42,8 @@ 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; }, /** @@ -147,6 +126,13 @@ 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. * @@ -259,6 +245,12 @@ 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; @@ -287,7 +279,7 @@ OpenLayers.Layer.Google.prototype = getOLZoomFromGZoom: function(gZoom) { var zoom = null; if (gZoom != null) { - zoom = gZoom; + zoom = gZoom - this.minZoomLevel; } return zoom; }, @@ -302,7 +294,7 @@ OpenLayers.Layer.Google.prototype = getGZoomFromOLZoom: function(olZoom) { var zoom = null; if (olZoom != null) { - zoom = olZoom; + zoom = olZoom + this.minZoomLevel; } return zoom; }, @@ -416,8 +408,34 @@ 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" }); diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 46edf0b99d..59a417b943 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -42,7 +42,6 @@ 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); }, @@ -88,30 +87,6 @@ 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. @@ -150,6 +125,8 @@ 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) @@ -170,7 +147,7 @@ OpenLayers.Layer.Grid.prototype = }, /** - * + * @private */ _initTiles:function() { var viewSize = this.map.getSize(); @@ -246,8 +223,16 @@ 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(); @@ -279,6 +264,8 @@ 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)) { @@ -286,12 +273,16 @@ 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++; } @@ -301,6 +292,7 @@ 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; } }, @@ -320,67 +312,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.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 * @@ -462,6 +393,65 @@ 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" }); diff --git a/lib/OpenLayers/Layer/HTTPRequest.js b/lib/OpenLayers/Layer/HTTPRequest.js index b6ba775398..b1ef76f2e2 100644 --- a/lib/OpenLayers/Layer/HTTPRequest.js +++ b/lib/OpenLayers/Layer/HTTPRequest.js @@ -36,10 +36,17 @@ 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(); }, + /** * */ @@ -131,31 +138,83 @@ 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 = new Array(); - 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; + + 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 + 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)); + + // 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)); } } }, + /** + * @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(); diff --git a/lib/OpenLayers/Layer/KaMap.js b/lib/OpenLayers/Layer/KaMap.js index 212621f86b..ba024cbf36 100644 --- a/lib/OpenLayers/Layer/KaMap.js +++ b/lib/OpenLayers/Layer/KaMap.js @@ -49,7 +49,7 @@ OpenLayers.Layer.KaMap.prototype = */ getURL: function (bounds) { var mapRes = this.map.getResolution(); - var scale = this.map.getScale(); + var scale = Math.round((this.map.getScale() * 10000)) / 10000; 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); diff --git a/lib/OpenLayers/Layer/Text.js b/lib/OpenLayers/Layer/Text.js index 6fb4adfc85..034ead100b 100644 --- a/lib/OpenLayers/Layer/Text.js +++ b/lib/OpenLayers/Layer/Text.js @@ -11,12 +11,6 @@ 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 */ diff --git a/lib/OpenLayers/Layer/VirtualEarth.js b/lib/OpenLayers/Layer/VirtualEarth.js index 9ba8dbc01c..360cdcff82 100644 --- a/lib/OpenLayers/Layer/VirtualEarth.js +++ b/lib/OpenLayers/Layer/VirtualEarth.js @@ -14,6 +14,12 @@ OpenLayers.Layer.VirtualEarth.prototype = /** @type VEMap */ vemap: null, + /** @type int */ + minZoomLevel: 1, + + /** @type int */ + maxZoomLevel: 17, + /** * @constructor * @@ -21,6 +27,8 @@ OpenLayers.Layer.VirtualEarth.prototype = */ initialize:function(name) { OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments); + + this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1; }, /** @@ -200,24 +208,26 @@ OpenLayers.Layer.VirtualEarth.prototype = */ 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(); + var zoom = null; + if (this.vemap != null) { + var maxRes = this.map.getMaxResolution(); + var viewSize = this.map.getSize(); - //make sure zoom is within bounds - zoom = Math.min( Math.max(zoom, minZoomLevel), - maxZoomLevel ); - + 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); + } return zoom; }, @@ -245,7 +255,7 @@ OpenLayers.Layer.VirtualEarth.prototype = getOLZoomFromVEZoom: function(veZoom) { var zoom = null; if (veZoom != null) { - zoom = veZoom; + zoom = veZoom - this.minZoomLevel; } return zoom; }, @@ -260,7 +270,7 @@ OpenLayers.Layer.VirtualEarth.prototype = getVEZoomFromOLZoom: function(olZoom) { var zoom = null; if (olZoom != null) { - zoom = olZoom; + zoom = olZoom + this.minZoomLevel; } return zoom; }, diff --git a/lib/OpenLayers/Layer/WFS.js b/lib/OpenLayers/Layer/WFS.js index d7a6641d81..acd315437e 100644 --- a/lib/OpenLayers/Layer/WFS.js +++ b/lib/OpenLayers/Layer/WFS.js @@ -18,6 +18,8 @@ OpenLayers.Layer.WFS.prototype = * @type Boolean */ isBaseLayer: false, + + buffer: 1, /** Allow the user to specify special classes for features and tiles. * @@ -157,10 +159,10 @@ OpenLayers.Layer.WFS.prototype = * * Once params have been changed, we will need to re-init our tiles * - * @param {Object} params Hashtable of new params to use + * @param {Object} newParams Hashtable of new params to use */ - mergeNewParams:function(params) { - var upperParams = OpenLayers.Util.upperCaseObject(params); + mergeNewParams:function(newParams) { + var upperParams = OpenLayers.Util.upperCaseObject(newParams); var newArguments = [upperParams]; OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments); diff --git a/lib/OpenLayers/Layer/WMS.js b/lib/OpenLayers/Layer/WMS.js index 91852d61fa..af83b29278 100644 --- a/lib/OpenLayers/Layer/WMS.js +++ b/lib/OpenLayers/Layer/WMS.js @@ -121,10 +121,10 @@ OpenLayers.Layer.WMS.prototype = * * Once params have been changed, we will need to re-init our tiles * - * @param {Object} params Hashtable of new params to use + * @param {Object} newParams Hashtable of new params to use */ - mergeNewParams:function(params) { - var upperParams = OpenLayers.Util.upperCaseObject(params); + mergeNewParams:function(newParams) { + var upperParams = OpenLayers.Util.upperCaseObject(newParams); var newArguments = [upperParams]; OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments); diff --git a/lib/OpenLayers/Layer/WMS/Untiled.js b/lib/OpenLayers/Layer/WMS/Untiled.js index 11c2a8770b..0ef19e26c0 100644 --- a/lib/OpenLayers/Layer/WMS/Untiled.js +++ b/lib/OpenLayers/Layer/WMS/Untiled.js @@ -177,8 +177,11 @@ 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, - arguments); + newArguments); + //redraw this.moveTo(); }, diff --git a/lib/OpenLayers/Layer/WorldWind.js b/lib/OpenLayers/Layer/WorldWind.js index acf786a94e..76a19f179c 100644 --- a/lib/OpenLayers/Layer/WorldWind.js +++ b/lib/OpenLayers/Layer/WorldWind.js @@ -25,11 +25,11 @@ OpenLayers.Layer.WorldWind.prototype = zoomLevels: null, - initialize: function(name, url, lzd, zoomLevels, params) { + initialize: function(name, url, lzd, zoomLevels, params, options) { this.lzd = lzd; this.zoomLevels = zoomLevels; var newArguments = new Array(); - newArguments.push(name, url, params); + newArguments.push(name, url, params, options); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); this.params = (params ? params : {}); if (arguments.length > 0 && params) { diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 4aea80fff5..0cba536751 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -78,33 +78,38 @@ OpenLayers.Map.prototype = { // Options + /** @type OpenLayers.Size */ + tileSize: null, + /** @type String */ projection: "EPSG:4326", - /** @type OpenLayers.Bounds */ - maxExtent: null, - + /** @type String */ + units: 'degrees', + /** default max is 360 deg / 256 px, which corresponds to * zoom level 0 on gmaps * * @type float */ maxResolution: 1.40625, - /** @type int */ - minZoomLevel: 0, - - /** @type int */ - maxZoomLevel: 16, + /** @type float */ + minResolution: null, - /** @type OpenLayers.Size */ - tileSize: null, + /** @type float */ + maxScale: null, - /** @type String */ - units: 'degrees', - - /** @type Float */ + /** @type float */ minScale: null, + + /** @type OpenLayers.Bounds */ + maxExtent: null, + /** @type OpenLayers.Bounds */ + minExtent: null, + + /** @type int */ + numZoomLevels: 16, /** @@ -129,6 +134,8 @@ 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); @@ -148,7 +155,7 @@ OpenLayers.Map.prototype = { Event.observe(window, 'resize', this.updateSize.bindAsEventListener(this)); } - + //set the default options this.setOptions(options); @@ -207,16 +214,6 @@ 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 ); - } }, /** @@ -374,9 +371,12 @@ OpenLayers.Map.prototype = { if (center != null) { var zoom = this.getZoom(); this.zoom = null; + if (zoom > this.baseLayer.numZoomLevels - 1) { + zoom = this.baseLayer.numZoomLevels - 1; + } this.setCenter(center, zoom); + } - if ((noEvent == null) || (noEvent == false)) { this.events.triggerEvent("changebaselayer"); } @@ -470,14 +470,18 @@ OpenLayers.Map.prototype = { if (oldSize == null) this.size = oldSize = newSize; if (!newSize.equals(oldSize)) { - // 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(); + + //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); + // store the new size this.size = newSize; // the div might have moved on the page, also @@ -561,7 +565,6 @@ OpenLayers.Map.prototype = { * trigger movestart/end events */ setCenter: function (lonlat, zoom, minor) { - var zoomChanged = (this.isValidZoomLevel(zoom)) && (zoom != this.getZoom()); @@ -598,7 +601,7 @@ OpenLayers.Map.prototype = { this.popups[i].updatePosition(); } } - + //send the move call to the baselayer and all the overlays var bounds = this.getExtent(); for (var i = 0; i < this.layers.length; i++) { @@ -643,8 +646,8 @@ OpenLayers.Map.prototype = { */ isValidZoomLevel: function(zoomLevel) { return ( (zoomLevel != null) && - (zoomLevel >= this.getMinZoomLevel()) && - (zoomLevel <= this.getMaxZoomLevel()) ); + (zoomLevel >= 0) && + (zoomLevel < this.getNumZoomLevels()) ); }, /** @@ -680,15 +683,9 @@ OpenLayers.Map.prototype = { */ getProjection: function() { var projection = null; - if (this.baseLayer != null) { projection = this.baseLayer.getProjection(); } - - if (projection == null) { - projection = this.projection; - } - return projection; }, @@ -698,15 +695,9 @@ OpenLayers.Map.prototype = { */ getMaxResolution: function() { var maxResolution = null; - if (this.baseLayer != null) { maxResolution = this.baseLayer.getMaxResolution(); } - - if (maxResolution == null) { - maxResolution = this.maxResolution; - } - return maxResolution; }, @@ -715,55 +706,25 @@ 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 maximum zoom level that can be reached in the map + * @returns The total number of zoom levels that can be displayed by the + * current baseLayer. * @type int */ - getMaxZoomLevel: function() { - var maxZoomLevel = null; - + getNumZoomLevels: function() { + var numZoomLevels = null; if (this.baseLayer != null) { - maxZoomLevel = this.baseLayer.getMaxZoomLevel(); + numZoomLevels = this.baseLayer.getNumZoomLevels(); } - - if (maxZoomLevel == null) { - maxZoomLevel = this.maxZoomLevel; - } - - return maxZoomLevel; + return numZoomLevels; }, - /** - * @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 */ @@ -783,7 +744,6 @@ OpenLayers.Map.prototype = { */ getExtent: function () { var extent = null; - if (this.baseLayer != null) { extent = this.baseLayer.getExtent(); } @@ -797,7 +757,6 @@ OpenLayers.Map.prototype = { */ getResolution: function () { var resolution = null; - if (this.baseLayer != null) { resolution = this.baseLayer.getResolution(); } @@ -811,9 +770,8 @@ OpenLayers.Map.prototype = { */ getScale: function () { var scale = null; - if (this.baseLayer != null) { - var res = this.baseLayer.getResolution(); + var res = this.getResolution(); var units = this.baseLayer.units; scale = res * OpenLayers.INCHES_PER_UNIT[units] * OpenLayers.DOTS_PER_INCH; @@ -831,7 +789,6 @@ OpenLayers.Map.prototype = { */ getZoomForExtent: function (bounds) { zoom = null; - if (this.baseLayer != null) { zoom = this.baseLayer.getZoomForExtent(bounds); } @@ -853,7 +810,9 @@ OpenLayers.Map.prototype = { * @param {int} zoom */ zoomTo: function(zoom) { - this.setCenter(null, zoom); + if (this.isValidZoomLevel(zoom)) { + this.setCenter(null, zoom); + } }, /** @@ -927,7 +886,11 @@ OpenLayers.Map.prototype = { * @private */ getLonLatFromViewPortPx: function (viewPortPx) { - return this.baseLayer.getLonLatFromViewPortPx(viewPortPx); + var lonlat = null; + if (this.baseLayer != null) { + lonlat = this.baseLayer.getLonLatFromViewPortPx(viewPortPx); + } + return lonlat; }, /** @@ -940,7 +903,11 @@ OpenLayers.Map.prototype = { * @private */ getViewPortPxFromLonLat: function (lonlat) { - return this.baseLayer.getViewPortPxFromLonLat(lonlat); + var px = null; + if (this.baseLayer != null) { + px = this.baseLayer.getViewPortPxFromLonLat(lonlat); + } + return px; }, diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 8d8d3a861e..021a6553b5 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -64,7 +64,9 @@ OpenLayers.Tile.Image.prototype = */ clear: function() { OpenLayers.Tile.prototype.clear.apply(this, arguments); - this.imgDiv.style.display = "none"; + if(this.imgDiv) { + this.imgDiv.style.display = "none"; + } }, /** diff --git a/lib/OpenLayers/Tile/WFS.js b/lib/OpenLayers/Tile/WFS.js index 3cdc6338b6..e4b7040f71 100644 --- a/lib/OpenLayers/Tile/WFS.js +++ b/lib/OpenLayers/Tile/WFS.js @@ -79,8 +79,8 @@ OpenLayers.Tile.WFS.prototype = if (this.urls != null) { for(var i=0; i < this.urls.length; i++) { - var params = { BBOX:bounds.toBBOX() }; - var url = this.urls[i] + + var params = { BBOX:this.bounds.toBBOX() }; + var url = this.urls[i] + "&" + OpenLayers.Util.getParameterString(params); OpenLayers.loadURL(url, null, this, success, failure); } diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 8af02a43fb..3357b6e762 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -355,6 +355,8 @@ OpenLayers.Util.getXmlNodeValue = function(node) { Try.these( function() { val = node.text; + if (!val) + val = node.textContent; }, function() { val = node.textContent; diff --git a/news.txt b/news.txt new file mode 100644 index 0000000000..133510689c --- /dev/null +++ b/news.txt @@ -0,0 +1,56 @@ +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. diff --git a/readme.txt b/readme.txt index 9be96171eb..f73b3faf09 100644 --- a/readme.txt +++ b/readme.txt @@ -38,7 +38,10 @@ Using OpenLayers in Your Own Website The examples/ directory is full of useful examples. -There is some documentation at http://trac.openlayers.org/ as well. +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. -------------------------- Contributing to OpenLayers diff --git a/tests/list-tests.html b/tests/list-tests.html index 8944612c4a..f199f0aa7f 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -22,6 +22,7 @@
  • test_Tile.html
  • test_Tile_Image.html
  • test_Control.html
  • +
  • test_Control_MouseToolbar.html
  • test_Control_LayerSwitcher.html
  • test_Control_PanZoom.html
  • test_Control_PanZoomBar.html
  • diff --git a/tests/test_Control_MouseToolbar.html b/tests/test_Control_MouseToolbar.html new file mode 100644 index 0000000000..59955acb7f --- /dev/null +++ b/tests/test_Control_MouseToolbar.html @@ -0,0 +1,55 @@ + + + + + + +
    + + diff --git a/tests/test_Control_Permalink.html b/tests/test_Control_Permalink.html index 1d7f64a338..d98fd532a8 100644 --- a/tests/test_Control_Permalink.html +++ b/tests/test_Control_Permalink.html @@ -20,7 +20,11 @@ if (!map.getCenter()) map.zoomToMaxExtent(); map.addControl(control); map.pan(5, 0); - t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink"); + 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"); + } } function test_03_Control_Permalink_updateLinksBase (t) { t.plan( 2 ); diff --git a/tests/test_Layer.html b/tests/test_Layer.html index 0959e8d9c1..f473cee5dd 100644 --- a/tests/test_Layer.html +++ b/tests/test_Layer.html @@ -89,19 +89,17 @@ function test_04_Layer_StandardOptionsAccessors (t) { - t.plan( 5 ); + t.plan( 4 ); var projection = "chicken"; var maxExtent = new OpenLayers.Bounds(50,50,100,100); var maxResolution = 1.5726; - var minZoomLevel = 5; - var maxZoomLevel = 15; + var numZoomLevels = 11; var options = { projection: projection, maxExtent: maxExtent, maxResolution: maxResolution, - minZoomLevel: minZoomLevel, - maxZoomLevel: maxZoomLevel + numZoomLevels: numZoomLevels }; var layer = new OpenLayers.Layer('Test Layer', options); @@ -109,8 +107,7 @@ 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.getMinZoomLevel(), minZoomLevel, "getMinZoomLevel() works"); - t.eq(layer.getMaxZoomLevel(), maxZoomLevel, "getMaxZoomLevel() works"); + t.eq(layer.getNumZoomLevels(), numZoomLevels, "getNumZoomLevels() works"); } function test_05_Layer_visibility(t) { diff --git a/tests/test_Layer_EventPane.html b/tests/test_Layer_EventPane.html index 71cc8a8151..d1d5f1f6e9 100644 --- a/tests/test_Layer_EventPane.html +++ b/tests/test_Layer_EventPane.html @@ -56,7 +56,11 @@ // MOUSEMOVE test does not seem to work... // t.plan( 2 ); - t.plan(1); + if (document.createEventObject) { + t.plan(3); + } else { + t.plan(1); + } var map = new OpenLayers.Map('map'); layer = new OpenLayers.Layer.EventPane('Test Layer'); diff --git a/tests/test_Layer_Grid.html b/tests/test_Layer_Grid.html index e7975e2082..0e57706646 100644 --- a/tests/test_Layer_Grid.html +++ b/tests/test_Layer_Grid.html @@ -114,13 +114,13 @@ * -insertColumn * -insertRow - function test_07_Layer_Grid_moveTo(t) { + function 07_Layer_Grid_moveTo(t) { } - function test_08_Layer_Grid_insertColumn(t) { + function 08_Layer_Grid_insertColumn(t) { } - function test_09_Layer_Grid_insertRow(t) { + function 09_Layer_Grid_insertRow(t) { } * @@ -166,41 +166,15 @@ } - 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( 4 ); + t.plan( 3 ); 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" ); diff --git a/tests/test_Layer_KaMap.html b/tests/test_Layer_KaMap.html index 0cd24a6a2c..ce310d9e67 100644 --- a/tests/test_Layer_KaMap.html +++ b/tests/test_Layer_KaMap.html @@ -107,13 +107,13 @@ * -insertColumn * -insertRow - function test_07_Layer_KaMap_moveTo(t) { + function 07_Layer_KaMap_moveTo(t) { } - function test_08_Layer_KaMap_insertColumn(t) { + function 08_Layer_KaMap_insertColumn(t) { } - function test_09_Layer_KaMap_insertRow(t) { + function 09_Layer_KaMap_insertRow(t) { } * @@ -158,42 +158,15 @@ 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( 4 ); + t.plan( 3 ); 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" ); diff --git a/tests/test_Map.html b/tests/test_Map.html index 11ccc79ec9..314453e065 100644 --- a/tests/test_Map.html +++ b/tests/test_Map.html @@ -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.getMaxZoomLevel() > 0, "map.maxZoomLevel is set" ); + t.ok( map.getNumZoomLevels() > 0, "map has a default numZoomLevels" ); } 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'), {maxZoomLevel: 5, maxResolution: 3.14159}); - t.eq( map.maxZoomLevel, 5, "map.maxZoomLevel set correctly via options hashtable" ); + map = new OpenLayers.Map($('map'), {numZoomLevels: 6, maxResolution: 3.14159}); + t.eq( map.numZoomLevels, 6, "map.numZoomLevels 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,18 +151,10 @@ } 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 test_08_Map_px_lonlat_translation (t) { + function 08_Map_px_lonlat_translation (t) { t.plan( 6 ); map = new OpenLayers.Map($('map')); var baseLayer = new OpenLayers.Layer.WMS("Test Layer",