Merge branch 'master' of github.com:openlayers/openlayers into utfgrid

This commit is contained in:
Tim Schaub
2012-03-06 00:06:15 -07:00
101 changed files with 2619 additions and 690 deletions

View File

@@ -51,10 +51,14 @@ def build(config_file = None, output_file = None, options = None):
outputFilename = output_file
print "Merging libraries."
if use_compressor == "closure":
sourceFiles = mergejs.getNames(sourceDirectory, configFilename)
else:
merged = mergejs.run(sourceDirectory, None, configFilename)
try:
if use_compressor == "closure":
sourceFiles = mergejs.getNames(sourceDirectory, configFilename)
else:
merged = mergejs.run(sourceDirectory, None, configFilename)
except mergejs.MissingImport, E:
print "\nAbnormal termination."
sys.exit("ERROR: %s" % E)
print "Compressing using %s" % use_compressor
if use_compressor == "jsmin":

32
build/light.cfg Normal file
View File

@@ -0,0 +1,32 @@
[first]
[last]
[include]
OpenLayers/Map.js
OpenLayers/Kinetic.js
OpenLayers/Projection.js
OpenLayers/Layer/Vector.js
OpenLayers/Layer/OSM.js
OpenLayers/Layer/Bing.js
OpenLayers/Layer/WMS.js
OpenLayers/Layer/Google/v3.js
OpenLayers/Popup/FramedCloud.js
OpenLayers/Control/Navigation.js
OpenLayers/Control/ZoomPanel.js
OpenLayers/Control/Attribution.js
OpenLayers/Control/SelectFeature.js
OpenLayers/Control/Panel.js
OpenLayers/Control/LayerSwitcher.js
OpenLayers/Renderer/SVG.js
OpenLayers/Renderer/VML.js
OpenLayers/Format/GeoJSON.js
OpenLayers/Protocol/HTTP.js
OpenLayers/Strategy/Fixed.js
OpenLayers/Strategy/BBOX.js
OpenLayers/StyleMap.js
OpenLayers/Rule.js
OpenLayers/Filter/Comparison.js
OpenLayers/Filter/Logical.js
[exclude]

View File

@@ -1,5 +1,4 @@
[first]
OpenLayers/SingleFile.js
[last]

View File

@@ -1,96 +0,0 @@
<html>
<head>
<title>OpenLayers examples walkthrough</title>
<style type="text/css">
a { color:blue; text-decoration: none; }
a:hover { text-decoration: underline; }
</style>
<base href="http://openlayers.org/dev/examples/">
</head>
<body style="font-family: sans-serif">
<h1><pre style="font-size: larger">&lt;ol&gt;</pre></h1>
<p>API documentation: <a href="http://dev.openlayers.org/docs/">http://dev.openlayers.org/docs/</a></p>
<p>Examples: <a href="http://dev.openlayers.org/examples/">http://openlayers.org/dev/examples/</a></p>
<h2>Maps</h2>
<ol>
<li><a href="../examples/lite.html">Basic example</a></li>
<li><a href="../examples/layerswitcher.html">Layer switcher (aka legend)</a></li>
<li><a href="../examples/example.html">Base layers versus overlays</a></li>
<li><a href="../examples/multiserver.html">Multiple WMS mirrors</a></li>
<li><a href="../examples/fullScreen.html">Full screen map</a></li>
<li><a href="../examples/wrapDateLine.html">Wrapping the date line</a></li>
<li><a href="../examples/projected-map.html">Other cartographic projections</a></li>
<li><a href="../examples/layer-opacity.html">Translucent overlays</a></li>
</ol>
<h2>Raster Layers</h2>
<ol>
<li><a href="../examples/wms-untiled.html">Untiled WMS layer</a></li>
<li><a href="../examples/kamap.html">Ka-Map layer</a></li>
<li><a href="../examples/mapserver.html">MapServer layer</a></li>
<li><a href="../examples/worldwind.html">Worldwind layer</a></li>
<li><a href="../examples/tms.html">TMS layer</a></li>
<li><a href="../examples/image-layer.html">Image layer</a></li>
<li><a href="../examples/google.html">Google layer</a></li>
<li><a href="../examples/ve.html">VirtualEarth layer</a></li>
<li><a href="../examples/spherical-mercator.html">Spherical Mercator ("EPSG:900913")</a></li>
<li><a href="http://tilecache.org/">TileCache</a></li>
</ol>
<h2>Marker Layers</h2>
<ol>
<li><a href="../examples/markers.html">Markers</a></li>
<li><a href="../examples/markerResize.html">Changing marker properties dynamically</a></li>
<li><a href="../examples/popups.html">Popups</a></li>
<li><a href="../examples/georss.html">GeoRSS</a> (<a href="georss.xml">example data</a>)</a></li>
<li><a href="../examples/georss-markers.html">GeoRSS with custom markers</a></li>
<li><a href="../examples/wfs.html">Point layer from WFS</a></li>
<li><a href="../examples/getfeatureinfo.html">WFS GetFeatureInfo example</a></li>
</ol>
<h2>Events and Controls</h2>
<ol>
<li><a href="../examples/navtoolbar.html">Navigation tools on the map</a></li>
<li><a href="../examples/navtoolbar-outsidemap.html">Navigation toolbar off the map</a></li>
<li><a href="../examples/mouse-position.html">Tracking the mouse position</a></li>
<li><a href="../examples/overview.html">Overview map</a></li>
<li><a href="../examples/attribution.html">Layer attribution</a></li>
<li><a href="../examples/controls.html">Full range of controls</a></li>
<li><a href="../examples/custom-control.html">Custom controls #1</a></li>
<li><a href="../examples/custom-control.html">Custom controls #2</a></li>
<li><a href="../examples/custom-style.html">Custom control styles</a></li>
<li><a href="../examples/click.html">Trapping click events</a></li>
<li><a href="../examples/layerLoadMonitoring.html">Tracking map events</a></li>
</ol>
<h2>Vector Layers</h2>
<ol>
<li><a href="../examples/vector-features.html">Generating features in JavaScript</a></li>
<li><a href="../examples/gml-layer.html">Loading features from GML</a></li>
<li><a href="../examples/kml-layer.html">Loading features from KML</a></li>
<li><a href="../examples/gml-serialize.html">Serializing features to GML</a></li>
<li><a href="../examples/vector-formats.html">Serializing to other formats</a></li>
<li><a href="../examples/select-feature.html">Selecting features</a></li>
<li><a href="../examples/select-feature-openpopup.html">Attaching popups to features</a></li>
</ol>
<h2>Editing Tools</h2>
<ol>
<li><a href="../examples/draw-feature.html">Drawing features</a></li>
<li><a href="../examples/editingtoolbar.html">Editing toolbar</a> (<a href="editingtoolbar-outside.html">outside the map</a>)</li>
<li><a href="../examples/regular-polygons.html">Creating regular polygons</a></li>
<li><a href="../examples/modify-feature.html">Modifying features</a></li>
<li><a href="../examples/resize-features.html">Resizing features</a></li>
<li><a href="../examples/rotate-features.html">Rotating features</a></li>
<li><a href="../examples/wfs-t.html">Transactional WFS example</a></li>
<li><a href="http://featureserver.org/">FeatureServer</a></li>
</ol>
<h2>Testing</h2>
<ol>
<li><a href="../tests/run-tests.html">Test.AnotherWay suite</a></li>
</ol>
<h1><pre style="font-size: larger">&lt;/ol&gt;</pre></h1>
</body>
</html>

View File

@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>Accessible Custom Click Control</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
<style type="text/css">
a {
text-decoration: none;
font-size: 1.2em;
}
a em {
font-style: normal;
font-weight: normal;
text-decoration: underline;
}
a:hover {
text-decoration: underline;
}
a.api {
font-size:1em;
text-decoration:underline;
}
a.accesskey {
color: white;
}
a.accesskey:focus {
color: #436976;
}
a.zoom {
padding-right: 20px;
}
</style>
<script src="../lib/Firebug/firebug.js"></script>
<script src="../lib/OpenLayers.js"></script>
<script src="accessible-click-control.js"></script>
</head>
<body onload="init()">
<h1 id="title">An accessible click control implementation</h1>
<div id="tags">
click, control, accessibility
</div>
<a class="accesskey"
href=""
accesskey="1"
onclick="document.getElementById('map').focus();return false;">
Jump to map
</a>
<div id="map" class="smallmap" tabindex="0"></div>
<p id="desc">
Demonstrate the KeyboardDefaults control as well as a control that
allows clicking on the map using the keyboard.
First focus the map (using tab key or mouse), then press the 'i'
key to activate the query control. You can then move the point
using arrow keys. Press 'RETURN' to get the coordinate. Press 'i'
again to deactivate the control.
</p>
</body>
</html>

View File

@@ -0,0 +1,199 @@
var map, navigationControl, queryControl;
function init(){
map = new OpenLayers.Map('map', {controls: []});
var layer = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'}
);
map.addLayers([layer]);
navigationControl = new OpenLayers.Control.KeyboardDefaults({
observeElement: 'map'
});
map.addControl(navigationControl);
queryControl = new OpenLayers.Control.KeyboardClick({
observeElement: 'map'
});
map.addControl(queryControl);
map.zoomToMaxExtent();
}
/**
* Class: OpenLayers.Control.KeyboardClick
*
* A custom control that (a) adds a vector point that can be moved using the
* arrow keys of the keyboard, and (b) displays a browser alert window when the
* RETURN key is pressed. The control can be activated/deactivated using the
* "i" key. When activated the control deactivates any KeyboardDefaults control
* in the map so that the map is not moved when the arrow keys are pressed.
*
* This control relies on the OpenLayers.Handler.KeyboardPoint custom handler.
*/
OpenLayers.Control.KeyboardClick = OpenLayers.Class(OpenLayers.Control, {
initialize: function(options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
var observeElement = this.observeElement || document;
this.handler = new OpenLayers.Handler.KeyboardPoint(this, {
done: this.onClick,
cancel: this.deactivate
}, {
observeElement: observeElement
});
OpenLayers.Event.observe(
observeElement,
"keydown",
OpenLayers.Function.bindAsEventListener(
function(evt) {
if (evt.keyCode == 73) { // "i"
if (this.active) {
this.deactivate();
} else {
this.activate();
}
}
},
this
)
);
},
onClick: function(geometry) {
alert("You clicked near " + geometry.x + " N, " +
geometry.y + " E");
},
activate: function() {
if(!OpenLayers.Control.prototype.activate.apply(this, arguments)) {
return false;
}
// deactivate any KeyboardDefaults control
var keyboardDefaults = this.map.getControlsByClass(
'OpenLayers.Control.KeyboardDefaults')[0];
if (keyboardDefaults) {
keyboardDefaults.deactivate();
}
return true;
},
deactivate: function() {
if(!OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {
return false;
}
// reactivate any KeyboardDefaults control
var keyboardDefaults = this.map.getControlsByClass(
'OpenLayers.Control.KeyboardDefaults')[0];
if (keyboardDefaults) {
keyboardDefaults.activate();
}
return true;
}
});
/**
* Class: OpenLayers.Handler.KeyboardPoint
*
* A custom handler that displays a vector point that can be moved
* using the arrow keys of the keyboard.
*/
OpenLayers.Handler.KeyboardPoint = OpenLayers.Class(OpenLayers.Handler, {
KEY_EVENTS: ["keydown"],
initialize: function(control, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
// cache the bound event listener method so it can be unobserved later
this.eventListener = OpenLayers.Function.bindAsEventListener(
this.handleKeyEvent, this
);
},
activate: function() {
if(!OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
return false;
}
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME);
this.map.addLayer(this.layer);
this.observeElement = this.observeElement || document;
for (var i=0, len=this.KEY_EVENTS.length; i<len; i++) {
OpenLayers.Event.observe(
this.observeElement, this.KEY_EVENTS[i], this.eventListener);
}
if(!this.point) {
this.createFeature();
}
return true;
},
deactivate: function() {
if (!OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
return false;
}
for (var i=0, len=this.KEY_EVENTS.length; i<len; i++) {
OpenLayers.Event.stopObserving(
this.observeElement, this.KEY_EVENTS[i], this.eventListener);
}
this.map.removeLayer(this.layer);
this.destroyFeature();
return true;
},
handleKeyEvent: function (evt) {
switch(evt.keyCode) {
case OpenLayers.Event.KEY_LEFT:
this.modifyFeature(-3, 0);
break;
case OpenLayers.Event.KEY_RIGHT:
this.modifyFeature(3, 0);
break;
case OpenLayers.Event.KEY_UP:
this.modifyFeature(0, 3);
break;
case OpenLayers.Event.KEY_DOWN:
this.modifyFeature(0, -3);
break;
case OpenLayers.Event.KEY_RETURN:
this.callback('done', [this.point.geometry.clone()]);
break;
case OpenLayers.Event.KEY_ESC:
this.callback('cancel');
break;
}
},
modifyFeature: function(lon, lat) {
if(!this.point) {
this.createFeature();
}
var resolution = this.map.getResolution();
this.point.geometry.x = this.point.geometry.x + lon * resolution;
this.point.geometry.y = this.point.geometry.y + lat * resolution;
this.callback("modify", [this.point.geometry, this.point, false]);
this.point.geometry.clearBounds();
this.drawFeature();
},
createFeature: function() {
var center = this.map.getCenter();
var geometry = new OpenLayers.Geometry.Point(
center.lon, center.lat
);
this.point = new OpenLayers.Feature.Vector(geometry);
this.callback("create", [this.point.geometry, this.point]);
this.point.geometry.clearBounds();
this.layer.addFeatures([this.point], {silent: true});
},
destroyFeature: function() {
this.layer.destroyFeatures([this.point]);
this.point = null;
},
drawFeature: function() {
this.layer.drawFeature(this.point, this.style);
}
});

View File

@@ -0,0 +1,130 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>Custom and accessible panel</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
.olControlPanel button {
position: relative;
display: block;
margin: 2px;
border: 1px solid;
padding: 0 5px;
border-radius: 4px;
height: 35px;
background-color: white;
float: left;
overflow: visible; /* needed to remove padding from buttons in IE */
}
.olControlPanel button span {
padding-left: 25px;
}
.olControlPanel button span:first-child {
padding-left: 0;
display: block;
position: absolute;
left: 2px;
}
.olControlPanel .olControlDrawFeatureItemActive span:first-child {
background-image: url("../theme/default/img/draw_line_on.png");
height: 22px;
width: 24px;
top: 5px;
}
.olControlPanel .olControlDrawFeatureItemInactive span:first-child {
background-image: url("../theme/default/img/draw_line_off.png");
height: 22px;
width: 24px;
top: 5px;
}
.olControlPanel .olControlZoomBoxItemInactive span:first-child {
background-image: url("../img/drag-rectangle-off.png");
height: 29px;
width: 29px;
top: 2px;
}
.olControlPanel .olControlZoomBoxItemActive span:first-child {
background-image: url("../img/drag-rectangle-on.png");
height: 29px;
width: 29px;
top: 2px;
}
.olControlPanel .olControlZoomToMaxExtentItemInactive span:first-child {
background-image: url("../img/zoom-world-mini.png");
height: 18px;
width: 18px;
top: 8px;
}
.olControlPanel .navHistory span:first-child {
background-image: url("../theme/default/img/navigation_history.png");
height: 24px;
width: 24px;
top: 4px;
}
.olControlPanel .navHistoryPreviousItemActive span:first-child {
background-position: 0 0;
}
.olControlPanel .navHistoryPreviousItemInactive span:first-child {
background-position: 0 -24px;
}
.olControlPanel .navHistoryNextItemActive span:first-child {
background-position: -24px 0;
}
.olControlPanel .navHistoryNextItemInactive span:first-child {
background-position: -24px -24px;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script src="accessible-panel.js"></script>
</head>
<body onload="init()">
<h1 id="title">Custom and accessible panel</h1>
<div id="tags">
panels, CSS, style, accessibility, button
</div>
<p id="shortdesc">
Create a custom and accessible panel, styled entirely with
CSS.
</p>
<div id="panel"></div>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>An accessible panel:
<ul>
<li>The buttons are actual HTML buttons. You can therefore
use the TAB key to give the focus to the panel's buttons, and the "ENTER"
key to activate or trigger the corresponding control.</li>
<li>The buttons include text and titles (displayed when a button
is hovered).</li>
<li>If you remove colors from the page (for example using FireFox's <a
href="https://addons.mozilla.org/en-US/firefox/addon/no-color/">No
Color extension</a>) the buttons are still visible, and
accessible using the keyboard.</li>
</ul>
</p>
<p>By default a panel creates buttons as divs. In this example the
<code>createControlMarkup</code> panel function is overridden to create
a more accessible markup for the buttons. See the <a
href="accessible-panel.js" target="_blank"> accessible-panel.js
source</a> to see how this is done.</p>
<p>Note: in IE 8, when a button is pressed its content shifts by 1 pixel.
This is a <a
href="http://labs.findsubstance.com/2009/05/21/ie8-form-button-with-background-image-on-click-css-bug/">known
IE8 bug</a>, with known workarounds. No workaround is applied in this
example though.</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,64 @@
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init() {
map = new OpenLayers.Map( 'map', { controls: [] } );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
vlayer = new OpenLayers.Layer.Vector( "Editable" );
map.addLayer(vlayer);
zb = new OpenLayers.Control.ZoomBox({
title: "Zoom box: zoom clicking and dragging",
text: "Zoom"
});
var panel = new OpenLayers.Control.Panel({
defaultControl: zb,
createControlMarkup: function(control) {
var button = document.createElement('button'),
iconSpan = document.createElement('span'),
textSpan = document.createElement('span');
iconSpan.innerHTML = '&nbsp;';
button.appendChild(iconSpan);
if (control.text) {
textSpan.innerHTML = control.text;
}
button.appendChild(textSpan);
return button;
}
});
panel.addControls([
zb,
new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path,
{title:'Draw a feature', text: 'Draw'}),
new OpenLayers.Control.ZoomToMaxExtent({
title:"Zoom to the max extent",
text: "World"
})
]);
nav = new OpenLayers.Control.NavigationHistory({
previousOptions: {
title: "Go to previous map position",
text: "Prev"
},
nextOptions: {
title: "Go to next map position",
text: "Next"
},
displayClass: "navHistory"
});
// parent control must be added to the map
map.addControl(nav);
panel.addControls([nav.next, nav.previous]);
map.addControl(panel);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}

View File

@@ -31,13 +31,26 @@
font-size:1em;
text-decoration:underline;
}
a.accesskey {
color: white;
}
a.accesskey:focus {
color: #436976;
}
a.zoom {
padding-right: 20px;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map = null;
function init(){
var options = {
controls: [new OpenLayers.Control.KeyboardDefaults()]
controls: [
new OpenLayers.Control.KeyboardDefaults({
observeElement: 'map'
})
]
};
map = new OpenLayers.Map('map', options);
var wms = new OpenLayers.Layer.WMS(
@@ -57,31 +70,37 @@
keyboard, pan, panning, zoom, zooming, accesskey
</div>
<a class="accesskey"
href=""
accesskey="1"
onclick="document.getElementById('map').focus(); return false;">
Go to map
</a>
<p id="shortdesc">
Demonstrate how to use the KeyboardDefaults option parameter for layer types.
Demonstrate the KeyboardDefaults control and how to use links
with Access Keys to navigate the map with the keyboard.
</p>
<a class="zoom"
href="javascript: void map.zoomIn();"
accesskey="i">
zoom <em>i</em>n</a>
<a class="zoom"
href="javascript: void map.zoomOut();"
accesskey="o">
zoom <em>o</em>ut</a>
<table>
<tbody>
<tr>
<td>
<a href="javascript: void map.zoomOut();"
accesskey="o">
zoom <em>o</em>ut
</a>
</td>
<td>&nbsp;</td>
<td>
<a href="javascript: void map.pan(0, -map.getSize().h / 4);"
accesskey="n">
pan <em>n</em>orth
</a>
</td>
<td>
<a href="javascript: void map.zoomIn();"
accesskey="i">
zoom <em>i</em>n
</a>
</td>
</tr>
<tr>
<td>
@@ -90,7 +109,7 @@
pan <em>w</em>est
</a>
</td>
<td id="map" class="smallmap"></td>
<td id="map" class="smallmap" tabindex="0"></td>
<td>
<a href="javascript: void map.pan(map.getSize().w / 4, 0);"
accesskey="e">
@@ -113,9 +132,9 @@
<div id="docs">
<p>Navigate the map in one of three ways:</p>
<ul>
<li>Click on the named links to zoom and pan</li>
<li>Use following keys to pan and zoom:
<ol>
<li>Use Access Key "1" (alt + 1) to focus the map element, and
use following keys to pan and zoom:
<ul>
<li>+ (zoom in)</li>
<li>- (zoom out)</li>
@@ -124,8 +143,12 @@
<li>left-arrow (pan east)</li>
<li>right-arrow (pan west)</li>
</ul>
See <a href=http://en.wikipedia.org/wiki/Access_key>wikipedia</a> for
more detail about Access Keys.
</li>
<li>If access keys work for links in your browser, use:
<li>Navigate to pan and zoom links using the "tab" key, and
press "enter" to pan and zoom</li>
<li>If Access Keys work for links in your browser, use:
<ul>
<li>i (zoom in)</li>
<li>o (zoom out)</li>
@@ -135,7 +158,7 @@
<li>w (pan west)</li>
</ul>
</li>
</ul>
</ol>
<p>
This is an example of using alternate methods to control panning and zooming. This approach uses map.pan() and map.zoom(). You'll note that to pan, additional math is necessary along with map.size() in order to set the distance to pan.

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script>
<script src="../lib/OpenLayers.js"></script>
<script src="all-overlays-google.js"></script>
</head>

View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>OpenLayers Script Protocol XML Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../lib/OpenLayers.js"></script>
</head>
<body>
<h1 id="title">Script Protocol With XML</h1>
<div id="tags">
protocol, script, cross origin, xml, advanced
</div>
<p id="shortdesc">
Demonstrates how, with a custom parseFeatures method, the script protocol can be used with YQL for cross-origin loading of files in any of the XML formats supported by OpenLayers.
</p>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>
YQL can wrap a jsonp callback around an XML file, which effectively means Yahoo's servers are acting as a proxy for cross-origin feature loading. This example uses a GPX file, but the same technique can be used for other formats such as KML.
</p>
<p>
View the <a href="cross-origin-xml.js" target="_blank">cross-origin-xml.js</a>
source to see how this is done
</p>
</div>
<script src="cross-origin-xml.js"></script>
</body>
</html>

View File

@@ -0,0 +1,25 @@
var map = new OpenLayers.Map({
div: "map",
layers: [
new OpenLayers.Layer.OSM(),
new OpenLayers.Layer.Vector("Vectors", {
projection: new OpenLayers.Projection("EPSG:4326"),
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.Script({
url: "http://query.yahooapis.com/v1/public/yql",
params: {
q: "select * from xml where url='http://www.topografix.com/fells_loop.gpx'"
},
format: new OpenLayers.Format.GPX(),
parseFeatures: function(data) {
return this.format.read(data.results[0]);
}
}),
eventListeners: {
"featuresadded": function () {
this.map.zoomToExtent(this.getDataExtent());
}
}
})
]
});

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script>
<script src="../lib/OpenLayers.js"></script>
<script src="google-v3.js"></script>
</head>

View File

@@ -45,7 +45,7 @@
"http://demo.opengeo.org/geoserver/wms",
{layers: 'topp:states'},
{gutter: 15});
var states = new OpenLayers.Layer.WMS( "Roads (no gutter)",
var states = new OpenLayers.Layer.WMS( "States (no gutter)",
"http://demo.opengeo.org/geoserver/wms",
{layers: 'topp:states'});
map.addLayers([states, states15]);

73
examples/mapbox.html Normal file
View File

@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers MapBox Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style>
.olControlAttribution {
bottom: 5px;
font-size: 9px;
}
div.olControlZoomPanel {
top: 10px;
left: 10px;
}
div.olControlZoomPanel .olControlZoomInItemInactive,
div.olControlZoomPanel .olControlZoomOutItemInactive {
background: rgba(0, 0, 0, 0.2);
position: absolute;
}
div.olControlZoomPanel .olControlZoomInItemInactive {
border-radius: 3px 3px 0 0;
}
div.olControlZoomPanel .olControlZoomOutItemInactive {
border-radius: 0 0 3px 3px ;
top: 20px;
}
div.olControlZoomPanel div:hover {
background: rgba(0, 0, 0, 0.5);
}
div.olControlZoomPanel .olControlZoomOutItemInactive:after ,
div.olControlZoomPanel .olControlZoomInItemInactive:after {
font-weight: bold;
content: '+';
font-size: 18px;
padding: 0 2px;
z-index: 2000;
color: #fff;
line-height: 1em;
}
div.olControlZoomPanel .olControlZoomOutItemInactive:after {
content: '';
line-height: 0.9em;
padding: 0 5px;
}
div.olControlZoomPanel .olControlZoomToMaxExtentItemInactive {
display: none;
}
</style>
</head>
<body>
<h1 id="title">Basic MapBox OSM Example</h1>
<div id="tags">mapbox xyz osm</div>
<div id="shortdesc">Shows how to use MapBox tiles in an OpenLayers map.</div>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>This example demonstrates the use of an XYZ layer that accesses tiles from MapBox.</p>
<p>
See the <a href="mapbox.js" target="_blank">mapbox.js</a> source
for details. Make sure to read the <a href="http://mapbox.com/tos/">Terms of Service</a>
before using MapBox tiles in your application.
</p>
</div>
<script src="../lib/OpenLayers.js"></script>
<script src="mapbox.js"></script>
</body>
</html>

34
examples/mapbox.js Normal file
View File

@@ -0,0 +1,34 @@
var streets = new OpenLayers.Layer.XYZ(
"MapBox Streets",
[
"http://a.tiles.mapbox.com/v3/mapbox.mapbox-streets/${z}/${x}/${y}.png",
"http://b.tiles.mapbox.com/v3/mapbox.mapbox-streets/${z}/${x}/${y}.png",
"http://c.tiles.mapbox.com/v3/mapbox.mapbox-streets/${z}/${x}/${y}.png",
"http://d.tiles.mapbox.com/v3/mapbox.mapbox-streets/${z}/${x}/${y}.png"
], {
attribution: "Tiles © <a href='http://mapbox.com/'>MapBox</a> | " +
"Data © <a href='http://www.openstreetmap.org/'>OpenStreetMap</a> " +
"and contributors, CC-BY-SA",
sphericalMercator: true,
transitionEffect: "resize",
buffer: 1,
numZoomLevels: 16
}
);
var map = new OpenLayers.Map({
div: "map",
layers: [streets],
controls: [
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
}),
new OpenLayers.Control.ZoomPanel(),
new OpenLayers.Control.Permalink({anchor: true})
],
center: [0, 0],
zoom: 1
});

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="http://maps.google.com/maps/api/js?v=3.3&amp;sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script>
<script src="../lib/OpenLayers.js"></script>
<script src="osm-google.js"></script>
</head>

View File

@@ -22,7 +22,7 @@
}
</style>
<script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script>
<script src="../lib/OpenLayers.js"></script>
</head>

68
examples/zoom.html Normal file
View File

@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers Zoom Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style>
.olControlAttribution {
bottom: 5px;
font-size: 9px;
}
#customZoom {
z-index: 1001;
position: relative;
top: 10px;
left: 10px;
}
#customZoom a {
text-decoration: none;
position: absolute;
display: block;
width: 50px;
text-align: center;
font-weight: bold;
color: #fff;
background: #369;
border: 1px solid #ccc;
border-radius: 3px;
}
#customZoom a:hover {
background: #036;
}
#customZoomOut {
top: 25px;
}
</style>
</head>
<body>
<h1 id="title">Zoom Control Example</h1>
<div id="tags">zoom control</div>
<div id="shortdesc">Shows how to use a simple zoom control.</div>
<div id="map" class="smallmap"></div>
<p>The map above uses the default control configuration and style.</p>
<p>The map below uses the custom zoom elements and styling.</p>
<div id="map2" class="smallmap">
<div id="customZoom">
<a href="#customZoomIn" id="customZoomIn">in</a>
<a href="#customZoomIn" id="customZoomOut">out</a>
</div>
</div>
<div id="docs">
<p>This example demonstrates the use of a Zoom control.</p>
<p>
See the <a href="zoom.js" target="_blank">zoom.js</a> source
for details.
</p>
</div>
<script src="../lib/OpenLayers.js"></script>
<script src="zoom.js"></script>
</body>
</html>

34
examples/zoom.js Normal file
View File

@@ -0,0 +1,34 @@
var map = new OpenLayers.Map({
div: "map",
layers: [new OpenLayers.Layer.OSM()],
controls: [
new OpenLayers.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
}),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Zoom()
],
center: [0, 0],
zoom: 1
});
var map2 = new OpenLayers.Map({
div: "map2",
layers: [new OpenLayers.Layer.OSM()],
controls: [
new OpenLayers.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
}),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Zoom({
zoomInId: "customZoomIn",
zoomOutId: "customZoomOut"
})
],
center: [0, 0],
zoom: 1
});

View File

@@ -207,6 +207,7 @@
"OpenLayers/Control/TransformFeature.js",
"OpenLayers/Control/UTFGrid.js",
"OpenLayers/Control/SLDSelect.js",
"OpenLayers/Control/Zoom.js",
"OpenLayers/Geometry.js",
"OpenLayers/Geometry/Collection.js",
"OpenLayers/Geometry/Point.js",
@@ -272,6 +273,10 @@
"OpenLayers/Format/KML.js",
"OpenLayers/Format/GeoRSS.js",
"OpenLayers/Format/WFS.js",
"OpenLayers/Format/OWSCommon.js",
"OpenLayers/Format/OWSCommon/v1.js",
"OpenLayers/Format/OWSCommon/v1_0_0.js",
"OpenLayers/Format/OWSCommon/v1_1_0.js",
"OpenLayers/Format/WFSCapabilities.js",
"OpenLayers/Format/WFSCapabilities/v1.js",
"OpenLayers/Format/WFSCapabilities/v1_0_0.js",

View File

@@ -3,6 +3,10 @@
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/SingleFile.js
*/
/**
* Header: OpenLayers Base Types
* OpenLayers custom string, number and function functions are described here.

View File

@@ -3,6 +3,10 @@
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/SingleFile.js
*/
/**
* Namespace: OpenLayers.Date
* Contains implementations of Date.parse and date.toISOString that match the

View File

@@ -34,6 +34,15 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
*/
slideFactor: 75,
/**
* APIProperty: observeElement
* {DOMelement|String} The DOM element to handle keys for. You
* can use the map div here, to have the navigation keys
* work when the map div has the focus. If undefined the
* document is used.
*/
observeElement: null,
/**
* Constructor: OpenLayers.Control.KeyboardDefaults
*/
@@ -43,8 +52,11 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
* Create handler.
*/
draw: function() {
this.handler = new OpenLayers.Handler.Keyboard( this, {
"keydown": this.defaultKeyPress });
var observeElement = this.observeElement || document;
this.handler = new OpenLayers.Handler.Keyboard( this,
{"keydown": this.defaultKeyPress},
{observeElement: observeElement}
);
},
/**
@@ -62,7 +74,7 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
* evt - {Event}
*/
defaultKeyPress: function (evt) {
var size;
var size, handled = true;
switch(evt.keyCode) {
case OpenLayers.Event.KEY_LEFT:
this.map.pan(-this.slideFactor, 0);
@@ -106,7 +118,14 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
case 95: // -/_ (some ASCII)
this.map.zoomOut();
break;
}
default:
handled = false;
}
if (handled) {
// prevent browser default not to move the page
// when moving the page with the keyboard
OpenLayers.Event.stop(evt);
}
},
CLASS_NAME: "OpenLayers.Control.KeyboardDefaults"

View File

@@ -120,7 +120,7 @@ OpenLayers.Control.LayerSwitcher =
initialize: function(options) {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.layerStates = [];
if(this.roundedCorner) {
OpenLayers.Console.warn('roundedCorner option is deprecated');
}
@@ -143,6 +143,7 @@ OpenLayers.Control.LayerSwitcher =
changebaselayer: this.redraw,
scope: this
});
this.events.unregister("buttonclick", this, this.onButtonClick);
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},
@@ -157,13 +158,18 @@ OpenLayers.Control.LayerSwitcher =
OpenLayers.Control.prototype.setMap.apply(this, arguments);
this.map.events.on({
buttonclick: this.onButtonClick,
addlayer: this.redraw,
changelayer: this.redraw,
removelayer: this.redraw,
changebaselayer: this.redraw,
scope: this
});
if (this.outsideViewport) {
this.events.attachToElement(this.div);
this.events.register("buttonclick", this, this.onButtonClick);
} else {
this.map.events.register("buttonclick", this, this.onButtonClick);
}
},
/**

View File

@@ -231,8 +231,8 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
* mouseposition. feature - {<OpenLayers.Feature.Vector>} The sketch feature.
*/
measureImmediate : function(point, feature, drawing) {
if (drawing && this.delayedTrigger === null &&
!this.handler.freehandMode(this.handler.evt)) {
if (drawing && !this.handler.freehandMode(this.handler.evt)) {
this.cancelDelay();
this.measure(feature.geometry, "measurepartial");
}
},

View File

@@ -246,7 +246,6 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
// configure the drag control
var dragOptions = {
geometryTypes: ["OpenLayers.Geometry.Point"],
snappingOptions: this.snappingOptions,
onStart: function(feature, pixel) {
control.dragStart.apply(control, [feature, pixel]);
},

View File

@@ -245,26 +245,58 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
controls = [controls];
}
this.controls = this.controls.concat(controls);
// Give each control a panel_div which will be used later.
// Access to this div is via the panel_div attribute of the
// control added to the panel.
// Also, stop mousedowns and clicks, but don't stop mouseup,
// since they need to pass through.
for (var i=0, len=controls.length; i<len; i++) {
var element = document.createElement("div");
element.className = controls[i].displayClass + "ItemInactive olButton";
controls[i].panel_div = element;
if (controls[i].title != "") {
controls[i].panel_div.title = controls[i].title;
var control = controls[i],
element = this.createControlMarkup(control);
OpenLayers.Element.addClass(element,
control.displayClass + "ItemInactive");
OpenLayers.Element.addClass(element, "olButton");
if (control.title != "" && !element.title) {
element.title = control.title;
}
}
control.panel_div = element;
}
if (this.map) { // map.addControl() has already been called on the panel
this.addControlsToMap(controls);
this.redraw();
}
},
/**
* APIMethod: createControlMarkup
* This function just creates a div for the control. If specific HTML
* markup is needed this function can be overridden in specific classes,
* or at panel instantiation time:
*
* Example:
* (code)
* var panel = new OpenLayers.Control.Panel({
* defaultControl: control,
* // ovverride createControlMarkup to create actual buttons
* // including texts wrapped into span elements.
* createControlMarkup: function(control) {
* var button = document.createElement('button'),
* span = document.createElement('span');
* if (control.text) {
* span.innerHTML = control.text;
* }
* return button;
* }
* });
* (end)
*
* Parameters:
* control - {<OpenLayers.Control>} The control to create the HTML
* markup for.
*
* Returns:
* {DOMElement} The markup.
*/
createControlMarkup: function(control) {
return document.createElement("div");
},
/**
* Method: addControlsToMap

View File

@@ -94,12 +94,13 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
* APIMethod: destroy
*/
destroy: function() {
if (this.element.parentNode == this.div) {
if (this.element && this.element.parentNode == this.div) {
this.div.removeChild(this.element);
this.element = null;
}
if (this.map) {
this.map.events.unregister('moveend', this, this.updateLink);
}
this.element = null;
this.map.events.unregister('moveend', this, this.updateLink);
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},

View File

@@ -341,6 +341,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
service: "WMS",
version: firstLayer.params.VERSION,
request: "GetFeatureInfo",
exceptions: firstLayer.params.EXCEPTIONS,
bbox: this.map.getExtent().toBBOX(null,
firstLayer.reverseAxisOrder()),
feature_count: this.maxFeatures,

View File

@@ -0,0 +1,139 @@
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Control.js
* @requires OpenLayers/Events/buttonclick.js
*/
/**
* Class: OpenLayers.Control.Zoom
* The Zoom control is a pair of +/- links for zooming in and out.
*
* Inherits from:
* - <OpenLayers.Control>
*/
OpenLayers.Control.Zoom = OpenLayers.Class(OpenLayers.Control, {
/**
* APIProperty: zoomInText
* {String}
* Text for zoom-in link. Default is "+".
*/
zoomInText: "+",
/**
* APIProperty: zoomInId
* {String}
* Instead of having the control create a zoom in link, you can provide
* the identifier for an anchor element already added to the document.
* By default, an element with id "olZoomInLink" will be searched for
* and used if it exists.
*/
zoomInId: "olZoomInLink",
/**
* APIProperty: zoomOutText
* {String}
* Text for zoom-out link. Default is "-".
*/
zoomOutText: "-",
/**
* APIProperty: zoomOutId
* {String}
* Instead of having the control create a zoom out link, you can provide
* the identifier for an anchor element already added to the document.
* By default, an element with id "olZoomOutLink" will be searched for
* and used if it exists.
*/
zoomOutId: "olZoomOutLink",
/**
* Method: draw
*
* Returns:
* {DOMElement} A reference to the DOMElement containing the zoom links.
*/
draw: function() {
var div = OpenLayers.Control.prototype.draw.apply(this),
links = this.getOrCreateLinks(div),
zoomIn = links.zoomIn,
zoomOut = links.zoomOut,
bind = OpenLayers.Function.bind,
eventsInstance = this.map.events;
if (zoomOut.parentNode !== div) {
eventsInstance = this.events;
eventsInstance.attachToElement(zoomOut.parentNode);
}
eventsInstance.register("buttonclick", this, this.onZoomClick);
this.zoomInLink = zoomIn;
this.zoomOutLink = zoomOut;
return div;
},
/**
* Method: getOrCreateLinks
*
* Parameters:
* el - {DOMElement}
*
* Return:
* {Object} Object with zoomIn and zoomOut properties referencing links.
*/
getOrCreateLinks: function(el) {
var zoomIn = document.getElementById(this.zoomInId),
zoomOut = document.getElementById(this.zoomOutId);
if (!zoomIn) {
zoomIn = document.createElement("a");
zoomIn.href = "#zoomIn";
zoomIn.appendChild(document.createTextNode(this.zoomInText));
zoomIn.className = "olControlZoomIn";
el.appendChild(zoomIn);
}
OpenLayers.Element.addClass(zoomIn, "olButton");
if (!zoomOut) {
zoomOut = document.createElement("a");
zoomOut.href = "#zoomOut";
zoomOut.appendChild(document.createTextNode(this.zoomOutText));
zoomOut.className = "olControlZoomOut";
el.appendChild(zoomOut);
}
OpenLayers.Element.addClass(zoomOut, "olButton");
return {
zoomIn: zoomIn, zoomOut: zoomOut
};
},
/**
* Method: onZoomClick
* Called when zoomin/out link is clicked.
*/
onZoomClick: function(evt) {
var button = evt.buttonElement;
if (button === this.zoomInLink) {
this.map.zoomIn();
} else if (button === this.zoomOutLink) {
this.map.zoomOut();
}
},
/**
* Method: destroy
* Clean up.
*/
destroy: function() {
if (this.map) {
this.map.events.unregister("buttonclick", this, this.onZoomClick);
}
delete this.zoomInLink;
delete this.zoomOutLink;
OpenLayers.Control.prototype.destroy.apply(this);
},
CLASS_NAME: "OpenLayers.Control.Zoom"
});

View File

@@ -20,6 +20,12 @@ OpenLayers.Event = {
* element._eventCacheID
*/
observers: false,
/**
* Constant: KEY_SPACE
* {int}
*/
KEY_SPACE: 32,
/**
* Constant: KEY_BACKSPACE
@@ -388,7 +394,8 @@ OpenLayers.Events = OpenLayers.Class({
"mousedown", "mouseup", "mousemove",
"click", "dblclick", "rightclick", "dblrightclick",
"resize", "focus", "blur",
"touchstart", "touchmove", "touchend"
"touchstart", "touchmove", "touchend",
"keydown"
],
/**

View File

@@ -39,7 +39,7 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({
*/
events: [
'mousedown', 'mouseup', 'click', 'dblclick',
'touchstart', 'touchmove', 'touchend'
'touchstart', 'touchmove', 'touchend', 'keydown'
],
/**
@@ -97,6 +97,31 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({
delete this.target;
},
/**
* Method: getPressedButton
* Get the pressed button, if any. Returns undefined if no button
* was pressed.
*
* Arguments:
* element - {DOMElement} The event target.
*
* Returns:
* {DOMElement} The button element, or undefined.
*/
getPressedButton: function(element) {
var depth = 3, // limit the search depth
button;
do {
if(OpenLayers.Element.hasClass(element, "olButton")) {
// hit!
button = element;
break;
}
element = element.parentNode;
} while(--depth > 0 && element);
return button;
},
/**
* Method: buttonClick
* Check if a button was clicked, and fire the buttonclick event
@@ -108,15 +133,25 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({
var propagate = true,
element = OpenLayers.Event.element(evt);
if (element && (OpenLayers.Event.isLeftClick(evt) || !~evt.type.indexOf("mouse"))) {
if (element.nodeType === 3 || OpenLayers.Element.hasClass(element, "olAlphaImg")) {
element = element.parentNode;
}
if (OpenLayers.Element.hasClass(element, "olButton")) {
if (this.startEvt) {
if (this.completeRegEx.test(evt.type)) {
var pos = OpenLayers.Util.pagePosition(element);
// was a button pressed?
var button = this.getPressedButton(element);
if (button) {
if (evt.type === "keydown") {
switch (evt.keyCode) {
case OpenLayers.Event.KEY_RETURN:
case OpenLayers.Event.KEY_SPACE:
this.target.triggerEvent("buttonclick", {
buttonElement: element,
buttonElement: button
});
OpenLayers.Event.stop(evt);
propagate = false;
break;
}
} else if (this.startEvt) {
if (this.completeRegEx.test(evt.type)) {
var pos = OpenLayers.Util.pagePosition(button);
this.target.triggerEvent("buttonclick", {
buttonElement: button,
buttonXY: {
x: this.startEvt.clientX - pos[0],
y: this.startEvt.clientY - pos[1]

View File

@@ -64,9 +64,25 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
* APIProperty: extractAttributes
* {Boolean} Extract attributes from KML. Default is true.
* Extracting styleUrls requires this to be set to true
* Note that currently only Data and SimpleData
* elements are handled.
*/
extractAttributes: true,
/**
* APIProperty: kvpAttributes
* {Boolean} Only used if extractAttributes is true.
* If set to true, attributes will be simple
* key-value pairs, compatible with other formats,
* Any displayName elements will be ignored.
* If set to false, attributes will be objects,
* retaining any displayName elements, but not
* compatible with other formats. Any CDATA in
* displayName will be read in as a string value.
* Default is false.
*/
kvpAttributes: false,
/**
* Property: extractStyles
* {Boolean} Extract styles from KML. Default is false.
@@ -1078,12 +1094,16 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
var valueNode = data.getElementsByTagName("value");
if (valueNode.length) {
ed['value'] = this.getChildValue(valueNode[0]);
}
var nameNode = data.getElementsByTagName("displayName");
if (nameNode.length) {
ed['displayName'] = this.getChildValue(nameNode[0]);
}
attributes[key] = ed;
if (this.kvpAttributes) {
attributes[key] = ed['value'];
} else {
var nameNode = data.getElementsByTagName("displayName");
if (nameNode.length) {
ed['displayName'] = this.getChildValue(nameNode[0]);
}
attributes[key] = ed;
}
}
var simpleDataNodes = node.getElementsByTagName("SimpleData");
for (i = 0, len = simpleDataNodes.length; i < len; i++) {
@@ -1091,8 +1111,12 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
data = simpleDataNodes[i];
key = data.getAttribute("name");
ed['value'] = this.getChildValue(data);
ed['displayName'] = key;
attributes[key] = ed;
if (this.kvpAttributes) {
attributes[key] = ed['value'];
} else {
ed['displayName'] = key;
attributes[key] = ed;
}
}
return attributes;
@@ -1209,7 +1233,14 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
var geometryNode = this.buildGeometryNode(feature.geometry);
placemarkNode.appendChild(geometryNode);
// TBD - deal with remaining (non name/description) attributes.
// output attributes as extendedData
if (feature.attributes) {
var edNode = this.buildExtendedData(feature.attributes);
if (edNode) {
placemarkNode.appendChild(edNode);
}
}
return placemarkNode;
},
@@ -1440,5 +1471,48 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
return point.x + "," + point.y;
},
/**
* Method: buildExtendedData
*
* Parameters:
* attributes - {Object}
*
* Returns
* {DOMElement} A KML ExtendedData node or {null} if no attributes.
*/
buildExtendedData: function(attributes) {
var extendedData = this.createElementNS(this.kmlns, "ExtendedData");
for (var attributeName in attributes) {
// empty, name, description, styleUrl attributes ignored
if (attributes[attributeName] && attributeName != "name" && attributeName != "description" && attributeName != "styleUrl") {
var data = this.createElementNS(this.kmlns, "Data");
data.setAttribute("name", attributeName);
var value = this.createElementNS(this.kmlns, "value");
if (typeof attributes[attributeName] == "object") {
// cater for object attributes with 'value' properties
// other object properties will output an empty node
if (attributes[attributeName].value) {
value.appendChild(this.createTextNode(attributes[attributeName].value));
}
if (attributes[attributeName].displayName) {
var displayName = this.createElementNS(this.kmlns, "displayName");
// displayName always written as CDATA
displayName.appendChild(this.getXMLDoc().createCDATASection(attributes[attributeName].displayName));
data.appendChild(displayName);
}
} else {
value.appendChild(this.createTextNode(attributes[attributeName]));
}
data.appendChild(value);
extendedData.appendChild(data);
}
}
if (this.isSimpleContent(extendedData)) {
return null;
} else {
return extendedData;
}
},
CLASS_NAME: "OpenLayers.Format.KML"
});

View File

@@ -220,6 +220,78 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
);
}
},
"LabelPlacement": function(node, symbolizer) {
this.readChildNodes(node, symbolizer);
},
"PointPlacement": function(node, symbolizer) {
var config = {};
this.readChildNodes(node, config);
config.labelRotation = config.rotation;
delete config.rotation;
var labelAlign,
x = symbolizer.labelAnchorPointX,
y = symbolizer.labelAnchorPointY;
if (x <= 1/3) {
labelAlign = 'l';
} else if (x > 1/3 && x < 2/3) {
labelAlign = 'c';
} else if (x >= 2/3) {
labelAlign = 'r';
}
if (y <= 1/3) {
labelAlign += 'b';
} else if (y > 1/3 && y < 2/3) {
labelAlign += 'm';
} else if (y >= 2/3) {
labelAlign += 't';
}
config.labelAlign = labelAlign;
OpenLayers.Util.applyDefaults(symbolizer, config);
},
"AnchorPoint": function(node, symbolizer) {
this.readChildNodes(node, symbolizer);
},
"AnchorPointX": function(node, symbolizer) {
var labelAnchorPointX = this.readers.ogc._expression.call(this, node);
// always string, could be empty string
if(labelAnchorPointX) {
symbolizer.labelAnchorPointX = labelAnchorPointX;
}
},
"AnchorPointY": function(node, symbolizer) {
var labelAnchorPointY = this.readers.ogc._expression.call(this, node);
// always string, could be empty string
if(labelAnchorPointY) {
symbolizer.labelAnchorPointY = labelAnchorPointY;
}
},
"Displacement": function(node, symbolizer) {
this.readChildNodes(node, symbolizer);
},
"DisplacementX": function(node, symbolizer) {
var labelXOffset = this.readers.ogc._expression.call(this, node);
// always string, could be empty string
if(labelXOffset) {
symbolizer.labelXOffset = labelXOffset;
}
},
"DisplacementY": function(node, symbolizer) {
var labelYOffset = this.readers.ogc._expression.call(this, node);
// always string, could be empty string
if(labelYOffset) {
symbolizer.labelYOffset = labelYOffset;
}
},
"LinePlacement": function(node, symbolizer) {
this.readChildNodes(node, symbolizer);
},
"PerpendicularOffset": function(node, symbolizer) {
var labelPerpendicularOffset = this.readers.ogc._expression.call(this, node);
// always string, could be empty string
if(labelPerpendicularOffset) {
symbolizer.labelPerpendicularOffset = labelPerpendicularOffset;
}
},
"Label": function(node, symbolizer) {
var value = this.readers.ogc._expression.call(this, node);
if (value) {
@@ -481,7 +553,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
* Method: getGraphicFormat
* Given a href for an external graphic, try to determine the mime-type.
* This method doesn't try too hard, and will fall back to
* <defautlGraphicFormat> if one of the known <graphicFormats> is not
* <defaultGraphicFormat> if one of the known <graphicFormats> is not
* the file extension of the provided href.
*
* Parameters:
@@ -498,7 +570,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
break;
}
}
return format || this.defautlGraphicFormat;
return format || this.defaultGraphicFormat;
},
/**
@@ -885,16 +957,26 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
}
// add in optional Font
if(symbolizer.fontFamily != null ||
symbolizer.fontSize != null ||
symbolizer.fontWeight != null ||
symbolizer.fontStyle != null) {
this.writeNode("Font", symbolizer, node);
symbolizer.fontSize != null ||
symbolizer.fontWeight != null ||
symbolizer.fontStyle != null) {
this.writeNode("Font", symbolizer, node);
}
// add in optional LabelPlacement
if (symbolizer.labelAnchorPointX != null ||
symbolizer.labelAnchorPointY != null ||
symbolizer.labelAlign != null ||
symbolizer.labelXOffset != null ||
symbolizer.labelYOffset != null ||
symbolizer.labelRotation != null ||
symbolizer.labelPerpendicularOffset != null) {
this.writeNode("LabelPlacement", symbolizer, node);
}
// add in optional Halo
if(symbolizer.haloRadius != null ||
symbolizer.haloColor != null ||
symbolizer.haloOpacity != null) {
this.writeNode("Halo", symbolizer, node);
symbolizer.haloColor != null ||
symbolizer.haloOpacity != null) {
this.writeNode("Halo", symbolizer, node);
}
// add in optional Fill
if(symbolizer.fontColor != null ||
@@ -906,6 +988,111 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
}
return node;
},
"LabelPlacement": function(symbolizer) {
var node = this.createElementNSPlus("sld:LabelPlacement");
// PointPlacement and LinePlacement are choices, so don't output both
if ((symbolizer.labelAnchorPointX != null ||
symbolizer.labelAnchorPointY != null ||
symbolizer.labelAlign != null ||
symbolizer.labelXOffset != null ||
symbolizer.labelYOffset != null ||
symbolizer.labelRotation != null) &&
symbolizer.labelPerpendicularOffset == null) {
this.writeNode("PointPlacement", symbolizer, node);
}
if (symbolizer.labelPerpendicularOffset != null) {
this.writeNode("LinePlacement", symbolizer, node);
}
return node;
},
"LinePlacement": function(symbolizer) {
var node = this.createElementNSPlus("sld:LinePlacement");
this.writeNode("PerpendicularOffset", symbolizer.labelPerpendicularOffset, node);
return node;
},
"PerpendicularOffset": function(value) {
return this.createElementNSPlus("sld:PerpendicularOffset", {
value: value
});
},
"PointPlacement": function(symbolizer) {
var node = this.createElementNSPlus("sld:PointPlacement");
if (symbolizer.labelAnchorPointX != null ||
symbolizer.labelAnchorPointY != null ||
symbolizer.labelAlign != null) {
this.writeNode("AnchorPoint", symbolizer, node);
}
if (symbolizer.labelXOffset != null ||
symbolizer.labelYOffset != null) {
this.writeNode("Displacement", symbolizer, node);
}
if (symbolizer.labelRotation != null) {
this.writeNode("Rotation", symbolizer.labelRotation, node);
}
return node;
},
"AnchorPoint": function(symbolizer) {
var node = this.createElementNSPlus("sld:AnchorPoint");
var x = symbolizer.labelAnchorPointX,
y = symbolizer.labelAnchorPointY;
if (x != null) {
this.writeNode("AnchorPointX", x, node);
}
if (y != null) {
this.writeNode("AnchorPointY", y, node);
}
if (x == null && y == null) {
var xAlign = symbolizer.labelAlign.substr(0, 1),
yAlign = symbolizer.labelAlign.substr(1, 1);
if (xAlign === "l") {
x = 0;
} else if (xAlign === "c") {
x = 0.5;
} else if (xAlign === "r") {
x = 1;
}
if (yAlign === "b") {
y = 0;
} else if (yAlign === "m") {
y = 0.5;
} else if (yAlign === "t") {
y = 1;
}
this.writeNode("AnchorPointX", x, node);
this.writeNode("AnchorPointY", y, node);
}
return node;
},
"AnchorPointX": function(value) {
return this.createElementNSPlus("sld:AnchorPointX", {
value: value
});
},
"AnchorPointY": function(value) {
return this.createElementNSPlus("sld:AnchorPointY", {
value: value
});
},
"Displacement": function(symbolizer) {
var node = this.createElementNSPlus("sld:Displacement");
if (symbolizer.labelXOffset != null) {
this.writeNode("DisplacementX", symbolizer.labelXOffset, node);
}
if (symbolizer.labelYOffset != null) {
this.writeNode("DisplacementY", symbolizer.labelYOffset, node);
}
return node;
},
"DisplacementX": function(value) {
return this.createElementNSPlus("sld:DisplacementX", {
value: value
});
},
"DisplacementY": function(value) {
return this.createElementNSPlus("sld:DisplacementY", {
value: value
});
},
"Font": function(symbolizer) {
var node = this.createElementNSPlus("sld:Font");
// add in CssParameters

View File

@@ -58,12 +58,9 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class(
},
"VendorOption": function(node, obj) {
if (!obj.vendorOptions) {
obj.vendorOptions = [];
obj.vendorOptions = {};
}
obj.vendorOptions.push({
name: node.getAttribute("name"),
value: this.getChildValue(node)
});
obj.vendorOptions[node.getAttribute("name")] = this.getChildValue(node);
}
}, OpenLayers.Format.SLD.v1_0_0.prototype.readers["sld"])
}, OpenLayers.Format.SLD.v1_0_0.prototype.readers),
@@ -130,8 +127,11 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class(
addVendorOptions: function(node, symbolizer) {
var options = symbolizer.vendorOptions;
if (options) {
for (var i=0, ii=options.length; i<ii; ++i) {
this.writeNode("VendorOption", options[i], node);
for (var key in symbolizer.vendorOptions) {
this.writeNode("VendorOption", {
name: key,
value: symbolizer.vendorOptions[key]
}, node);
}
}
return node;

View File

@@ -15,7 +15,23 @@
* - <OpenLayers.Format.XML>
*/
OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class(
OpenLayers.Format.WFSCapabilities, {
OpenLayers.Format.XML, {
/**
* Property: namespaces
* {Object} Mapping of namespace aliases to namespace URIs.
*/
namespaces: {
wfs: "http://www.opengis.net/wfs",
xlink: "http://www.w3.org/1999/xlink",
xsi: "http://www.w3.org/2001/XMLSchema-instance",
ows: "http://www.opengis.net/ows"
},
/**
* Property: defaultPrefix
*/
defaultPrefix: "wfs",
/**
* Constructor: OpenLayers.Format.WFSCapabilities.v1_1
@@ -25,10 +41,6 @@ OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class(
* options - {Object} An optional object whose properties will be set on
* this instance.
*/
initialize: function(options) {
OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
this.options = options;
},
/**
* APIMethod: read
@@ -44,83 +56,64 @@ OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class(
if(typeof data == "string") {
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
}
var raw = data;
if(data && data.nodeType == 9) {
data = data.documentElement;
}
var capabilities = {};
var root = data.documentElement;
this.runChildNodes(capabilities, root);
this.readNode(data, capabilities);
return capabilities;
},
/**
* Method: runChildNodes
* Property: readers
* Contains public functions, grouped by namespace prefix, that will
* be applied when a namespaced node is found matching the function
* name. The function will be applied in the scope of this parser
* with two arguments: the node being read and a context object passed
* from the parent.
*/
runChildNodes: function(obj, node) {
var children = node.childNodes;
var childNode, processor;
for(var i=0; i<children.length; ++i) {
childNode = children[i];
if(childNode.nodeType == 1) {
processor = this["read_cap_" + childNode.nodeName];
if(processor) {
processor.apply(this, [obj, childNode]);
readers: {
"wfs": {
"WFS_Capabilities": function(node, obj) {
this.readChildNodes(node, obj);
},
"FeatureTypeList": function(node, request) {
request.featureTypeList = {
featureTypes: []
};
this.readChildNodes(node, request.featureTypeList);
},
"FeatureType": function(node, featureTypeList) {
var featureType = {};
this.readChildNodes(node, featureType);
featureTypeList.featureTypes.push(featureType);
},
"Name": function(node, obj) {
var name = this.getChildValue(node);
if(name) {
var parts = name.split(":");
obj.name = parts.pop();
if(parts.length > 0) {
obj.featureNS = this.lookupNamespaceURI(node, parts[0]);
}
}
},
"Title": function(node, obj) {
var title = this.getChildValue(node);
if(title) {
obj.title = title;
}
},
"Abstract": function(node, obj) {
var abst = this.getChildValue(node);
if(abst) {
obj["abstract"] = abst;
}
}
}
},
/**
* Method: read_cap_FeatureTypeList
*/
read_cap_FeatureTypeList: function(request, node) {
var featureTypeList = {
featureTypes: []
};
this.runChildNodes(featureTypeList, node);
request.featureTypeList = featureTypeList;
},
/**
* Method: read_cap_FeatureType
*/
read_cap_FeatureType: function(featureTypeList, node, parentLayer) {
var featureType = {};
this.runChildNodes(featureType, node);
featureTypeList.featureTypes.push(featureType);
},
/**
* Method: read_cap_Name
*/
read_cap_Name: function(obj, node) {
var name = this.getChildValue(node);
if(name) {
var parts = name.split(":");
obj.name = parts.pop();
if(parts.length > 0) {
obj.featureNS = this.lookupNamespaceURI(node, parts[0]);
}
}
},
/**
* Method: read_cap_Title
*/
read_cap_Title: function(obj, node) {
var title = this.getChildValue(node);
if(title) {
obj.title = title;
}
},
/**
* Method: read_cap_Abstract
*/
read_cap_Abstract: function(obj, node) {
var abst = this.getChildValue(node);
if(abst) {
obj["abstract"] = abst;
}
},
CLASS_NAME: "OpenLayers.Format.WFSCapabilities.v1"
});

View File

@@ -25,136 +25,89 @@ OpenLayers.Format.WFSCapabilities.v1_0_0 = OpenLayers.Class(
* options - {Object} An optional object whose properties will be set on
* this instance.
*/
/**
* Method: read_cap_Service
*/
read_cap_Service: function(capabilities, node) {
var service = {};
this.runChildNodes(service, node);
capabilities.service = service;
},
/**
* Method: read_cap_Fees
* Property: readers
* Contains public functions, grouped by namespace prefix, that will
* be applied when a namespaced node is found matching the function
* name. The function will be applied in the scope of this parser
* with two arguments: the node being read and a context object passed
* from the parent.
*/
read_cap_Fees: function(service, node) {
var fees = this.getChildValue(node);
if (fees && fees.toLowerCase() != "none") {
service.fees = fees;
}
},
/**
* Method: read_cap_AccessConstraints
*/
read_cap_AccessConstraints: function(service, node) {
var constraints = this.getChildValue(node);
if (constraints && constraints.toLowerCase() != "none") {
service.accessConstraints = constraints;
}
},
/**
* Method: read_cap_OnlineResource
*/
read_cap_OnlineResource: function(service, node) {
var onlineResource = this.getChildValue(node);
if (onlineResource && onlineResource.toLowerCase() != "none") {
service.onlineResource = onlineResource;
}
},
/**
* Method: read_cap_Keywords
*/
read_cap_Keywords: function(service, node) {
var keywords = this.getChildValue(node);
if (keywords && keywords.toLowerCase() != "none") {
service.keywords = keywords.split(', ');
}
},
/**
* Method: read_cap_Capability
*/
read_cap_Capability: function(capabilities, node) {
var capability = {};
this.runChildNodes(capability, node);
capabilities.capability = capability;
},
/**
* Method: read_cap_Request
*/
read_cap_Request: function(obj, node) {
var request = {};
this.runChildNodes(request, node);
obj.request = request;
},
/**
* Method: read_cap_GetFeature
*/
read_cap_GetFeature: function(request, node) {
var getfeature = {
href: {}, // DCPType
formats: [] // ResultFormat
};
this.runChildNodes(getfeature, node);
request.getfeature = getfeature;
},
/**
* Method: read_cap_ResultFormat
*/
read_cap_ResultFormat: function(obj, node) {
var children = node.childNodes;
var childNode;
for(var i=0; i<children.length; i++) {
childNode = children[i];
if(childNode.nodeType == 1) {
obj.formats.push(childNode.nodeName);
readers: {
"wfs": OpenLayers.Util.applyDefaults({
"Service": function(node, capabilities) {
capabilities.service = {};
this.readChildNodes(node, capabilities.service);
},
"Fees": function(node, service) {
var fees = this.getChildValue(node);
if (fees && fees.toLowerCase() != "none") {
service.fees = fees;
}
},
"AccessConstraints": function(node, service) {
var constraints = this.getChildValue(node);
if (constraints && constraints.toLowerCase() != "none") {
service.accessConstraints = constraints;
}
},
"OnlineResource": function(node, service) {
var onlineResource = this.getChildValue(node);
if (onlineResource && onlineResource.toLowerCase() != "none") {
service.onlineResource = onlineResource;
}
},
"Keywords": function(node, service) {
var keywords = this.getChildValue(node);
if (keywords && keywords.toLowerCase() != "none") {
service.keywords = keywords.split(', ');
}
},
"Capability": function(node, capabilities) {
capabilities.capability = {};
this.readChildNodes(node, capabilities.capability);
},
"Request": function(node, obj) {
obj.request = {};
this.readChildNodes(node, obj.request);
},
"GetFeature": function(node, request) {
request.getfeature = {
href: {}, // DCPType
formats: [] // ResultFormat
};
this.readChildNodes(node, request.getfeature);
},
"ResultFormat": function(node, obj) {
var children = node.childNodes;
var childNode;
for(var i=0; i<children.length; i++) {
childNode = children[i];
if(childNode.nodeType == 1) {
obj.formats.push(childNode.nodeName);
}
}
},
"DCPType": function(node, obj) {
this.readChildNodes(node, obj);
},
"HTTP": function(node, obj) {
this.readChildNodes(node, obj.href);
},
"Get": function(node, obj) {
obj.get = node.getAttribute("onlineResource");
},
"Post": function(node, obj) {
obj.post = node.getAttribute("onlineResource");
},
"SRS": function(node, obj) {
var srs = this.getChildValue(node);
if (srs) {
obj.srs = srs;
}
}
}
},
/**
* Method: read_cap_DCPType
*/
read_cap_DCPType: function(obj, node) {
this.runChildNodes(obj, node);
},
/**
* Method: read_cap_HTTP
*/
read_cap_HTTP: function(obj, node) {
this.runChildNodes(obj.href, node);
},
/**
* Method: read_cap_Get
*/
read_cap_Get: function(obj, node) {
obj.get = node.getAttribute("onlineResource");
},
/**
* Method: read_cap_Post
*/
read_cap_Post: function(obj, node) {
obj.post = node.getAttribute("onlineResource");
},
/**
* Method: read_cap_SRS
*/
read_cap_SRS: function(obj, node) {
var srs = this.getChildValue(node);
if (srs) {
obj.srs = srs;
}
}, OpenLayers.Format.WFSCapabilities.v1.prototype.readers["wfs"])
},
CLASS_NAME: "OpenLayers.Format.WFSCapabilities.v1_0_0"

View File

@@ -5,6 +5,7 @@
/**
* @requires OpenLayers/Format/WFSCapabilities/v1.js
* @requires OpenLayers/Format/OWSCommon/v1.js
*/
/**
@@ -16,6 +17,17 @@
*/
OpenLayers.Format.WFSCapabilities.v1_1_0 = OpenLayers.Class(
OpenLayers.Format.WFSCapabilities.v1, {
/**
* Property: regExes
* Compiled regular expressions for manipulating strings.
*/
regExes: {
trimSpace: (/^\s*|\s*$/g),
removeSpace: (/\s*/g),
splitSpace: (/\s+/),
trimComma: (/\s*,\s*/g)
},
/**
* Constructor: OpenLayers.Format.WFSCapabilities.v1_1_0
@@ -27,13 +39,23 @@ OpenLayers.Format.WFSCapabilities.v1_1_0 = OpenLayers.Class(
*/
/**
* Method: read_cap_DefaultSRS
* Property: readers
* Contains public functions, grouped by namespace prefix, that will
* be applied when a namespaced node is found matching the function
* name. The function will be applied in the scope of this parser
* with two arguments: the node being read and a context object passed
* from the parent.
*/
read_cap_DefaultSRS: function(obj, node) {
var defaultSRS = this.getChildValue(node);
if (defaultSRS) {
obj.srs = defaultSRS;
}
readers: {
"wfs": OpenLayers.Util.applyDefaults({
"DefaultSRS": function(node, obj) {
var defaultSRS = this.getChildValue(node);
if (defaultSRS) {
obj.srs = defaultSRS;
}
}
}, OpenLayers.Format.WFSCapabilities.v1.prototype.readers["wfs"]),
"ows": OpenLayers.Format.OWSCommon.v1.prototype.readers.ows
},
CLASS_NAME: "OpenLayers.Format.WFSCapabilities.v1_1_0"

View File

@@ -33,6 +33,13 @@ OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {
*/
eventListener: null,
/**
* Property: observeElement
* {DOMElement|String} The DOM element on which we listen for
* key events. Default to the document.
*/
observeElement: null,
/**
* Constructor: OpenLayers.Handler.Keyboard
* Returns a new keyboard handler.
@@ -71,9 +78,10 @@ OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {
*/
activate: function() {
if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
this.observeElement = this.observeElement || document;
for (var i=0, len=this.KEY_EVENTS.length; i<len; i++) {
OpenLayers.Event.observe(
document, this.KEY_EVENTS[i], this.eventListener);
this.observeElement, this.KEY_EVENTS[i], this.eventListener);
}
return true;
} else {
@@ -89,7 +97,7 @@ OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {
if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
for (var i=0, len=this.KEY_EVENTS.length; i<len; i++) {
OpenLayers.Event.stopObserving(
document, this.KEY_EVENTS[i], this.eventListener);
this.observeElement, this.KEY_EVENTS[i], this.eventListener);
}
deactivated = true;
}

View File

@@ -1,8 +1,9 @@
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license.
*
* full text of the license. */
/**
* @requires OpenLayers/BaseTypes/Class.js
* @requires OpenLayers/Animation.js
*/

View File

@@ -34,7 +34,7 @@ OpenLayers.Layer = OpenLayers.Class({
div: null,
/**
* Property: opacity
* APIProperty: opacity
* {Float} The layer's opacity. Float number between 0.0 and 1.0. Default
* is 1.
*/
@@ -159,13 +159,6 @@ OpenLayers.Layer = OpenLayers.Class({
*/
imageSize: null,
/**
* Property: imageOffset
* {<OpenLayers.Pixel>} For layers with a gutter, the image offset
* represents displacement due to the gutter.
*/
imageOffset: null,
// OPTIONS
/**
@@ -693,7 +686,7 @@ OpenLayers.Layer = OpenLayers.Class({
/**
* APIMethod: setTileSize
* Set the tile size based on the map size. This also sets layer.imageSize
* and layer.imageOffset for use by Tile.Image.
* or use by Tile.Image.
*
* Parameters:
* size - {<OpenLayers.Size>}
@@ -710,8 +703,6 @@ OpenLayers.Layer = OpenLayers.Class({
// this.name + ": layers with " +
// "gutters need non-null tile sizes");
//}
this.imageOffset = new OpenLayers.Pixel(-this.gutter,
-this.gutter);
this.imageSize = new OpenLayers.Size(tileSize.w + (2*this.gutter),
tileSize.h + (2*this.gutter));
}

View File

@@ -452,7 +452,9 @@ OpenLayers.Layer.ArcGISCache = OpenLayers.Class(OpenLayers.Layer.XYZ, {
// Write the values into our formatted url
url = OpenLayers.String.format(url, {'x': x, 'y': y, 'z': z});
return url;
return OpenLayers.Util.urlAppend(
url, OpenLayers.Util.getParameterString(this.params)
);
},
/**

View File

@@ -202,6 +202,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* track of the loading progress. Listeners are called with an object
* with a tile property as first argument, making the loded tile
* available to the listener.
* tileerror - Triggered before the tileloaded event (i.e. when the tile is
* still hidden) if a tile failed to load. Listeners receive an object
* as first argument, which has a tile property that references the
* tile that could not be loaded.
*/
/**
@@ -969,7 +973,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
}
this.numLoadingTiles++;
};
tile.events.register("loadstart", this, tile.onLoadStart);
tile.onLoadEnd = function() {
this.numLoadingTiles--;
@@ -987,8 +990,18 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
}
}
};
tile.events.register("loadend", this, tile.onLoadEnd);
tile.events.register("unload", this, tile.onLoadEnd);
tile.onLoadError = function() {
this.events.triggerEvent("tileerror", {tile: tile});
};
tile.events.on({
"loadstart": tile.onLoadStart,
"loadend": tile.onLoadEnd,
"unload": tile.onLoadEnd,
"loaderror": tile.onLoadError,
scope: this
});
},
/**
@@ -1005,6 +1018,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
"loadstart": tile.onLoadStart,
"loadend": tile.onLoadEnd,
"unload": tile.onLoadEnd,
"loaderror": tile.onLoadError,
scope: this
});
},

View File

@@ -60,7 +60,9 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
initialize: function(name, url, params, options) {
OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
this.url = url;
this.params = OpenLayers.Util.extend( {}, params);
if (!this.params) {
this.params = OpenLayers.Util.extend({}, params);
}
},
/**

View File

@@ -34,7 +34,7 @@ OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
/**
* APIProperty: url
* {String} The tileset URL scheme. Defaults to
* : http://tile.openstreetmap.org/${z}/${x}/${y}.png
* : http://[a|b|c].tile.openstreetmap.org/${z}/${x}/${y}.png
* (the official OSM tileset) if the second argument to the constructor
* is null or undefined. To use another tileset you can have something
* like this:
@@ -43,7 +43,11 @@ OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
* "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png");
* (end)
*/
url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png',
url: [
'http://a.tile.openstreetmap.org/${z}/${x}/${y}.png',
'http://b.tile.openstreetmap.org/${z}/${x}/${y}.png',
'http://c.tile.openstreetmap.org/${z}/${x}/${y}.png'
],
/**
* Property: attribution

View File

@@ -239,6 +239,12 @@ OpenLayers.Map = OpenLayers.Class({
*/
panRatio: 1.5,
/**
* APIProperty: options
* {Object} The options object passed to the class constructor. Read-only.
*/
options: null,
// Options
/**
@@ -480,6 +486,9 @@ OpenLayers.Map = OpenLayers.Class({
this.theme = OpenLayers._getScriptLocation() +
'theme/default/style.css';
// backup original options
this.options = OpenLayers.Util.extend({}, options);
// now override default options
OpenLayers.Util.extend(this, options);
@@ -487,13 +496,16 @@ OpenLayers.Map = OpenLayers.Class({
this.projection.projCode : this.projection;
OpenLayers.Util.applyDefaults(this, OpenLayers.Projection.defaults[projCode]);
// allow extents to be arrays
// allow extents and center to be arrays
if (this.maxExtent && !(this.maxExtent instanceof OpenLayers.Bounds)) {
this.maxExtent = new OpenLayers.Bounds(this.maxExtent);
}
if (this.restrictedExtent && !(this.restrictedExtent instanceof OpenLayers.Bounds)) {
this.restrictedExtent = new OpenLayers.Bounds(this.restrictedExtent);
}
if (this.center && !(this.center instanceof OpenLayers.LonLat)) {
this.center = new OpenLayers.LonLat(this.center);
}
// initialize layers array
this.layers = [];
@@ -616,9 +628,9 @@ OpenLayers.Map = OpenLayers.Class({
* be properly set below.
*/
delete this.center;
this.addLayers(options.layers);
this.addLayers(options.layers);
// set center (and optionally zoom)
if (options.center) {
if (options.center && !this.getCenter()) {
// zoom can be undefined here
this.setCenter(options.center, options.zoom);
}
@@ -731,6 +743,7 @@ OpenLayers.Map = OpenLayers.Class({
this.events.destroy();
this.events = null;
this.options = null;
},
/**

View File

@@ -685,7 +685,9 @@ OpenLayers.Popup = OpenLayers.Class({
// 'img' properties in the context.
//
var onImgLoad = function() {
if (this.popup.id === null) { // this.popup has been destroyed!
return;
}
this.popup.updateSize();
if ( this.popup.visible() && this.popup.panMapIfOutOfView ) {

View File

@@ -62,12 +62,27 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
scope: null,
/**
* Property: readWithPOST
* APIProperty: readWithPOST
* {Boolean} true if read operations are done with POST requests
* instead of GET, defaults to false.
*/
readWithPOST: false,
/**
* APIProperty: updateWithPOST
* {Boolean} true if update operations are done with POST requests
* defaults to false.
*/
updateWithPOST: false,
/**
* APIProperty: deleteWithPOST
* {Boolean} true if delete operations are done with POST requests
* defaults to false.
* if true, POST data is set to output of format.write().
*/
deleteWithPOST: false,
/**
* Property: wildcarded.
* {Boolean} If true percent signs are added around values
@@ -99,7 +114,7 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
* Valid options include:
* url - {String}
* headers - {Object}
* params - {Object}
* params - {Object} URL parameters for GET requests
* format - {<OpenLayers.Format>}
* callback - {Function}
* scope - {Object}
@@ -293,7 +308,8 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
requestType: "update"
});
resp.priv = OpenLayers.Request.PUT({
var method = this.updateWithPOST ? "POST" : "PUT";
resp.priv = OpenLayers.Request[method]({
url: url,
callback: this.createCallback(this.handleUpdate, resp, options),
headers: options.headers,
@@ -344,11 +360,16 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
requestType: "delete"
});
resp.priv = OpenLayers.Request.DELETE({
var method = this.deleteWithPOST ? "POST" : "DELETE";
var requestOptions = {
url: url,
callback: this.createCallback(this.handleDelete, resp, options),
headers: options.headers
});
};
if (this.deleteWithPOST) {
requestOptions.data = this.format.write(feature);
}
resp.priv = OpenLayers.Request[method](requestOptions);
return resp;
},

View File

@@ -54,20 +54,12 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
callback: null,
/**
* APIProperty: scope
* {Object} Optional ``this`` object for the callback. Read-only, set
* through the options passed to the constructor.
* APIProperty: callbackTemplate
* {String} Template for creating a unique callback function name
* for the registry. Should include ${id}.
* Default is "OpenLayers.Protocol.Script.registry[${id}]".
*/
scope: null,
/**
* APIProperty: format
* {<OpenLayers.Format>} Format for parsing features. Default is an
* <OpenLayers.Format.GeoJSON> format. If an alternative is provided,
* the format's read method must take an object and return an array
* of features.
*/
format: null,
callbackTemplate: "OpenLayers.Protocol.Script.registry[${id}]",
/**
* APIProperty: callbackKey
@@ -88,6 +80,22 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
*/
callbackPrefix: "",
/**
* APIProperty: scope
* {Object} Optional ``this`` object for the callback. Read-only, set
* through the options passed to the constructor.
*/
scope: null,
/**
* APIProperty: format
* {<OpenLayers.Format>} Format for parsing features. Default is an
* <OpenLayers.Format.GeoJSON> format. If an alternative is provided,
* the format's read method must take an object and return an array
* of features.
*/
format: null,
/**
* Property: pendingRequests
* {Object} References all pending requests. Property names are script
@@ -135,7 +143,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
});
this.filterToParams = function(filter, params) {
return format.write(filter, params);
}
};
}
},
@@ -212,7 +220,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
*/
createRequest: function(url, params, callback) {
var id = OpenLayers.Protocol.Script.register(callback);
var name = "OpenLayers.Protocol.Script.registry[" + id + "]";
var name = OpenLayers.String.format(this.callbackTemplate, {id: id});
params = OpenLayers.Util.extend({}, params);
params[this.callbackKey] = this.callbackPrefix + name;
url = OpenLayers.Util.urlAppend(
@@ -333,7 +341,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
(function() {
var o = OpenLayers.Protocol.Script;
var counter = 0;
o.registry = [];
o.registry = {};
/**
* Function: OpenLayers.Protocol.Script.register
@@ -345,12 +353,11 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
* that is the JSON returned by the service.
*
* Returns:
* {Number} An identifier for retreiving the registered callback.
* {Number} An identifier for retrieving the registered callback.
*/
o.register = function(callback) {
var id = ++counter;
var id = "c"+(++counter);
o.registry[id] = function() {
o.unregister(id);
callback.apply(this, arguments);
};
return id;

View File

@@ -415,3 +415,18 @@ OpenLayers.Renderer.defaultSymbolizer = {
labelAlign: 'cm'
};
/**
* Constant: OpenLayers.Renderer.symbol
* Coordinate arrays for well known (named) symbols.
*/
OpenLayers.Renderer.symbol = {
"star": [350,75, 379,161, 469,161, 397,215, 423,301, 350,250, 277,301,
303,215, 231,161, 321,161, 350,75],
"cross": [4,0, 6,0, 6,4, 10,4, 10,6, 6,6, 6,10, 4,10, 4,6, 0,6, 0,4, 4,4,
4,0],
"x": [0,0, 25,0, 50,35, 75,0, 100,0, 65,50, 100,100, 75,100, 50,65, 25,100, 0,100, 35,50, 0,0],
"square": [0,0, 0,1, 1,1, 1,0, 0,0],
"triangle": [0,10, 10,10, 5,0, 0,10]
};

View File

@@ -434,28 +434,6 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
}
},
/**
* Method: setCanvasStyle
* Prepare the canvas for drawing by setting various global settings.
*
* Parameters:
* type - {String} one of 'stroke', 'fill', or 'reset'
* style - {Object} Symbolizer hash
*/
setCanvasStyle: function(type, style) {
if (type === "fill") {
this.canvas.globalAlpha = style['fillOpacity'];
this.canvas.fillStyle = style['fillColor'];
} else if (type === "stroke") {
this.canvas.globalAlpha = style['strokeOpacity'];
this.canvas.strokeStyle = style['strokeColor'];
this.canvas.lineWidth = style['strokeWidth'];
} else {
this.canvas.globalAlpha = 0;
this.canvas.lineWidth = 1;
}
},
/**
* Method: featureIdToHex
* Convert a feature ID string into an RGB hex string.
@@ -787,7 +765,8 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
*/
getFeatureIdFromEvent: function(evt) {
var featureId, feature;
if (this.hitDetection) {
if (this.hitDetection && this.root.style.display !== "none") {
// this dragging check should go in the feature handler
if (!this.map.dragging) {
var xy = evt.xy;

View File

@@ -1051,17 +1051,3 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, {
CLASS_NAME: "OpenLayers.Renderer.Elements"
});
/**
* Constant: OpenLayers.Renderer.symbol
* Coordinate arrays for well known (named) symbols.
*/
OpenLayers.Renderer.symbol = {
"star": [350,75, 379,161, 469,161, 397,215, 423,301, 350,250, 277,301,
303,215, 231,161, 321,161, 350,75],
"cross": [4,0, 6,0, 6,4, 10,4, 10,6, 6,6, 6,10, 4,10, 4,6, 0,6, 0,4, 4,4,
4,0],
"x": [0,0, 25,0, 50,35, 75,0, 100,0, 65,50, 100,100, 75,100, 50,65, 25,100, 0,100, 35,50, 0,0],
"square": [0,0, 0,1, 1,1, 1,0, 0,0],
"triangle": [0,10, 10,10, 5,0, 0,10]
};

View File

@@ -3,6 +3,10 @@
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/SingleFile.js
*/
/**
* Namespace: Spherical
* The OpenLayers.Spherical namespace includes utility functions for

View File

@@ -40,6 +40,8 @@ OpenLayers.Tile = OpenLayers.Class({
* to call <draw>(true) to actually draw the tile.
* loadstart - Triggered when tile loading starts.
* loadend - Triggered when tile loading ends.
* loaderror - Triggered before the loadend event (i.e. when the tile is
* still hidden) if the tile could not be loaded.
* reload - Triggered when an already loading tile is reloaded.
* unload - Triggered before a tile is unloaded.
*/

View File

@@ -208,11 +208,12 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
* code.
*/
positionTile: function() {
var style = this.getTile().style;
var style = this.getTile().style,
size = this.layer.getImageSize(this.bounds);
style.left = this.position.x + "%";
style.top = this.position.y + "%";
style.width = this.size.w + "%";
style.height = this.size.h + "%";
style.width = size.w + "%";
style.height = size.h + "%";
},
/**
@@ -256,11 +257,6 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
var top = this.layer.gutter / this.layer.tileSize.h * 100;
style.left = -left + "%";
style.top = -top + "%";
style.width = (2 * left + 100) + "%";
style.height = (2 * top + 100) + "%";
} else {
style.width = "100%";
style.height = "100%";
}
style.visibility = "hidden";
style.opacity = 0;
@@ -429,6 +425,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
this.setImgSrc(this.layer.getURL(this.bounds));
} else {
OpenLayers.Element.addClass(img, "olImageLoadError");
this.events.triggerEvent("loaderror");
this.onImageLoad();
}
}

View File

@@ -65,7 +65,11 @@ OpenLayers.Tile.Image.IFrame = {
// And if we had an iframe we also remove the event pane.
if(fromIFrame) {
this.blankImageUrl = this._blankImageUrl;
this.frame.removeChild(this.frame.firstChild);
} else {
this._blankImageUrl = this.blankImageUrl;
this.blankImageUrl = "about:blank";
}
}
}
@@ -85,7 +89,7 @@ OpenLayers.Tile.Image.IFrame = {
style.width = "100%";
style.height = "100%";
style.zIndex = 1;
style.backgroundImage = "url(" + this.blankImageUrl + ")";
style.backgroundImage = "url(" + this._blankImageUrl + ")";
this.frame.appendChild(eventPane);
}
@@ -133,7 +137,7 @@ OpenLayers.Tile.Image.IFrame = {
return OpenLayers.Tile.Image.prototype.getImage.apply(this, arguments);
}
},
/**
* Method: createRequestForm
* Create the html <form> element with width, height, bbox and all

View File

@@ -1,8 +1,9 @@
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license.
*
* full text of the license. */
/**
* @requires OpenLayers/BaseTypes/Class.js
* @requires OpenLayers/Animation.js
*/

View File

@@ -560,8 +560,10 @@ OpenLayers.Util.urlAppend = function(url, paramStr) {
};
/**
* Property: ImgPath
* {String} Default is ''.
* APIProperty: ImgPath
* {String} Set this to the path where control images are stored.
* If set to '' OpenLayers will use script location + "img/"
* Default is ''.
*/
OpenLayers.ImgPath = '';

View File

@@ -84,8 +84,39 @@ The `OpenLayers.Tile.Image` class now has a method to get a canvas context for p
tileOptions: {crossOriginKeyword: null}
Both `OpenLayers.Layer.OSM` and `OpenLayers.Layer.Bing` do not have defaults for `maxExtent`, `maxResolutions` and `units` any more. This may break maps that are configured with a `maxResolution` of `156543.0339`, which was used in examples before 2.11, but is incorrect. The correct value is `156543.03390625`, but it is no longer necessary to specify a maxResolution, maxExtent and units if the correct resolution is set. See "Projection and Spherical Mercator" below.
## Projection & SphericalMercator
When working with Web Mercator layers (e.g. Google, Bing, OSM), it was previously necessary to configure the map or the base layer with the correct `projection`, `maxExtent`, `maxResolutions` and `units`. Now OpenLayers has defaults for WGS84 and Web Mercator in `OpenLayers.Projection.defaults`, so it is enough to provide the `projection`.
Old:
new OpenLayers.Map({
div: "map",
projection: "EPSG:900913",
maxResolution: 156543.03390625,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
units: "m",
layers: [
new OpenLayers.Layer.Google("Google Streets"),
new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opacity: 0.7})
],
zoom: 1
});
New:
new OpenLayers.Map({
div: "map",
projection: "EPSG:900913",
layers: [
new OpenLayers.Layer.Google("Google Streets"),
new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opacity: 0.7})
],
zoom: 1
});
In previous releases, coordinate transforms between EPSG:4326 and EPSG:900913 were defined in the SphericalMercator.js script. In 2.12, these default transforms are included in the Projection.js script. The Projection.js script is included as a dependency in builds with any layer types, so no special build configuration is necessary to get the web mercator transforms.
If you were previously using the `OpenLayers.Layer.SphericalMercator.forwardMercator` or `inverseMercator` methods, you may have to explicitly include the SphericalMercator.js script in your build. The Google layer is the only layer that depends on the SphericalMercator mixin. If you are not using the Google layer but want to use the SphericalMercator methods listed above, you have to explicitly include the SphericalMercator.js script in your build.
@@ -98,6 +129,16 @@ If you were previously using the `OpenLayers.Layer.SphericalMercator.forwardMerc
The internal `OpenLayers.Layer.getURLasync` function now take a bound, a callback and a scope. The function no longer needs update the passed property but simply to return to url.
## Changes when base layer configured with wrapDateLine: true
Vector editing across the date line works reliably now. To make this work, OpenLayers won't zoom out to resolutions where more than one world is visible any more. For maps that have base layers with wrapDateLine set to false, no zoom restrictions apply.
## OpenLayers.Util.onImageLoadError no longer exists
To replace a tile that couldn't be loaded with a static image, create a css selector for the `.olImageLoadError` class (e.g. a `background-image`).
For more complex tile loading error handling, register a listener to the layer's `tileerror` event.
## Deprecated Components
A number of properties, methods, and constructors have been marked as deprecated for multiple releases in the 2.x series. For the 2.12 release this deprecated functionality has been moved to a separate deprecated.js file. If you use any of the constructors or methods below, you will have to explicitly include the deprecated.js file in your build (or add it in a separate `<script>` tag after OpenLayers.js).

View File

@@ -9,7 +9,7 @@ Please see license.txt in this distribution for more details.
## Getting OpenLayers
OpenLayers lives at http://www.openlayers.org/. Find details on downloading stable releases or the development version the [development site](http://trac.osgeo.org/openlayers/wiki/HowToDownload.)
OpenLayers lives at http://www.openlayers.org/. Find details on downloading stable releases or the development version the [development site](http://trac.osgeo.org/openlayers/wiki/HowToDownload).
## Installing OpenLayers
@@ -48,7 +48,7 @@ As an example, using bash (with the release files in ~/openlayers):
The [examples directory](http://openlayers.org/dev/examples/) is full of useful examples.
Documentation is available at http://trac.osgeo.org/openlayers/wiki/Documentation.
You can generate the API documentation with http://www.naturaldocs.org/:
You can generate the API documentation with http://www.naturaldocs.org/
As an example, using bash (with the release files in ~/openlayers):
$ cd ~/openlayers/

View File

@@ -17,12 +17,22 @@
function test_all(t) {
t.plan(8);
t.ok(OpenLayers.Animation.isNative !== undefined, "isNative is set.");
t.open_window("Animation.html", function(win) {
function doIt(win) {
win.requestFrame(t);
win.start(t);
win.startDuration(t);
win.stop(t);
});
}
// Test in an extra window in Firefox, and directly in other browsers.
// This is needed because requestAnimationFrame does not work
// correctly in Firefox in a hidden IFrame.
if (window.mozRequestAnimationFrame) {
t.open_window("Animation.html", doIt);
} else {
doIt(window);
}
}
function requestFrame(t) {

View File

@@ -25,15 +25,17 @@
t.ok( div != null, "draw returns its div" );
}
function test_Control_LayerSwitcher_outsideViewport (t) {
t.plan( 2 );
t.plan( 4 );
map = new OpenLayers.Map('map');
control = new OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('layerswitcher')});
map.addControl(control);
t.eq(control.div.style.width, "250px", "Div is not minimized when added.");
t.eq(control.div.style.width, "250px", "Div is not minimized when added.");
t.ok(control.events.element && control.events.listeners.buttonclick, "[outside] Events instance attached to div and has buttonclick event");
control = new OpenLayers.Control.LayerSwitcher();
map.addControl(control);
t.eq(control.div.style.width, "0px", "Div is minimized when added.");
t.ok(!control.events.element && map.events.listeners.buttonclick, "[inside] Events instance not attached to div and buttonclick event registered on map");
}
function test_Control_LayerSwitcher_loadContents(t) {

View File

@@ -289,16 +289,16 @@
// move 10 pixels
trigger("mousemove", 0, 10);
t.eq(log.length, 0, "a) no event fired yet");
t.eq(log.length, 1, "a) has fired an event");
t.delay_call(
delay, function() {
// confirm measurepartial is fired
t.eq(log.length, 1, "a) event logged");
t.eq(log.length, 1, "a) one event logged");
t.ok(log[0] && log[0].type == "measurepartial", "a) correct type");
// mousemove within the partialDelay fires no event, so the
// measure below is the one of the initial point
t.ok(log[0] && log[0].measure == 0, "a) correct measure");
t.eq(log[0]?log[0].measure:-1 , 10, "a) correct measure");
// b) move 10 pixels
trigger("mousemove", 0, 20);

View File

@@ -3,19 +3,23 @@
<script src="../OLLoader.js"></script>
<script type="text/javascript">
var map, control;
function test_initialize(t) {
t.plan( 2 );
control = new OpenLayers.Control.OverviewMap();
t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
t.eq( control.displayClass, "olControlOverviewMap", "displayClass is correct" );
t.ok( control instanceof OpenLayers.Control.OverviewMap,
"new OpenLayers.Control.OverviewMap returns object" );
t.eq( control.displayClass,
"olControlOverviewMap", "displayClass is correct" );
}
function test_setMap(t) {
t.plan(4);
var setMapTest = function(map) {
t.ok(true, "Handler.setMap called for " + this.CLASS_NAME);
t.ok(true,
"Handler.setMap called for " + this.CLASS_NAME);
this.map = map;
};
var drag_setMap = OpenLayers.Handler.Drag.prototype.setMap;
@@ -32,8 +36,10 @@
map.addControl(control);
map.zoomToMaxExtent();
t.eq(control.handlers.drag.map.id, control.ovmap.id, "drag.map is correct");
t.eq(control.handlers.click.map.id, control.ovmap.id, "click.map is correct");
t.eq(control.handlers.drag.map.id, control.ovmap.id,
"drag.map is correct");
t.eq(control.handlers.click.map.id, control.ovmap.id,
"click.map is correct");
map.destroy();
OpenLayers.Handler.Drag.prototype.setMap = drag_setMap;
@@ -66,85 +72,112 @@
control.destroy();
t.eq(log_drag.length, 2,
"destroy() destroys drag handler twice, expected");
"destroy() destroys drag handler twice, expected");
if (log_drag.length == 2) {
t.eq(log_drag[0].map, true,
"destroy() destroys drag handler before ovmap is destroyed (0)");
"destroy() destroys drag handler before ovmap is destroyed (0)");
t.eq(log_drag[1].map, false,
"destroy() destroys drag handler after ovmap is destroyed (1)");
"destroy() destroys drag handler after ovmap is destroyed (1)");
}
t.eq(log_click.length, 2,
"destroy() destroys click handler twice, expected");
"destroy() destroys click handler twice, expected");
if (log_click.length == 2) {
t.eq(log_click[0].map, true,
"destroy() destroys click handler before ovmap is destroyed (0)");
"destroy() destroys click handler before ovmap is destroyed (0)");
t.eq(log_click[1].map, false,
"destroy() destroys click handler after ovmap is destroyed (1)");
"destroy() destroys click handler after ovmap is destroyed (1)");
}
// tear down
map.destroy();
}
function test_addControl (t) {
t.plan( 6 );
map = new OpenLayers.Map('map');
control = new OpenLayers.Control.OverviewMap();
t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
t.ok( control instanceof OpenLayers.Control.OverviewMap,
"new OpenLayers.Control.OverviewMap returns object" );
t.ok( map instanceof OpenLayers.Map,
"new OpenLayers.Map creates map" );
map.addControl(control);
t.ok( control.map === map, "Control.map is set to the map object" );
t.ok( map.controls[4] === control, "map.controls contains control" );
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Control div zIndexed properly" );
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Viewport div contains control div" );
t.ok( control.map === map,
"Control.map is set to the map object" );
t.ok( map.controls[4] === control,
"map.controls contains control" );
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 5,
"Control div zIndexed properly" );
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5,
"Viewport div contains control div" );
map.destroy();
}
function test_control_events (t) {
t.plan( 10 );
var evt = {which: 1}; // control expects left-click
map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(layer);
map = new OpenLayers.Map('map', {
// when we recenter, don't waste time animating the panning
// without this, the test fails in Firefox 10.0.1 on Linux
panMethod: null,
layers: [ new OpenLayers.Layer('Test Layer', {isBaseLayer: true}) ]
});
control = new OpenLayers.Control.OverviewMap();
map.addControl(control, new OpenLayers.Pixel(20,20));
var centerLL = new OpenLayers.LonLat(-71,42);
map.setCenter(centerLL, 11);
t.delay_call(1, function() {
var overviewCenter = control.ovmap.getCenter();
var overviewZoom = control.ovmap.getZoom();
t.eq(overviewCenter.lon, -71, "Overviewmap center lon correct");
t.eq(overviewCenter.lat, 42, "Overviewmap center lat correct");
t.eq(overviewZoom, 8, "Overviewmap zoomcorrect");
control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
}, 2, function() {
var cent = map.getCenter();
t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon");
t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat");
control.handlers.drag = {
last: new OpenLayers.Pixel(5,5),
destroy: function() {}
};
control.rectDrag(new OpenLayers.Pixel(15, 15));
control.updateMapToRect();
}, 2, function() {
var cent = map.getCenter();
t.eq(cent.lon, -71.2734375, "Dragging on the Overview Map has the correct effect on map lon");
t.eq(cent.lat, 42.09765625, "Dragging on the Overview Map has the correct effect on map lat");
t.delay_call(
0.1,
function() {
var overviewCenter = control.ovmap.getCenter();
var overviewZoom = control.ovmap.getZoom();
t.eq(overviewCenter.lon, -71,
"OverviewMap center lon correct");
t.eq(overviewCenter.lat, 42,
"OverviewMap center lat correct");
t.eq(overviewZoom, 8,
"OverviewMap zoom correct");
control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
},
0.1,
function() {
var cent = map.getCenter();
t.eq(cent.lon, -71.3515625,
"Clicking on OverviewMap has correct effect on map lon");
t.eq(cent.lat, 42.17578125,
"Clicking on OverviewMap has correct effect on map lat");
map.setCenter(new OpenLayers.LonLat(0,0), 0);
var overviewCenter = control.ovmap.getCenter();
var overviewZoom = control.ovmap.getZoom();
t.eq(overviewCenter.lon, 0, "Overviewmap center lon correct -- second zoom");
t.eq(overviewCenter.lat, 0, "Overviewmap center lat correct -- second zoom");
t.eq(overviewZoom, 0, "Overviewmap zoomcorrect -- second zoom");
map.destroy();
});
control.handlers.drag = {
last: new OpenLayers.Pixel(5,5),
destroy: function() {}
};
control.rectDrag(new OpenLayers.Pixel(15, 15));
control.updateMapToRect();
},
0.1,
function() {
var cent = map.getCenter();
t.eq(cent.lon, -71.2734375,
"Dragging on OverviewMap has correct effect on map lon");
t.eq(cent.lat, 42.09765625,
"Dragging on OverviewMap has correct effect on map lat");
map.setCenter(new OpenLayers.LonLat(0,0), 0);
var overviewCenter = control.ovmap.getCenter();
var overviewZoom = control.ovmap.getZoom();
t.eq(overviewCenter.lon, 0,
"OverviewMap center lon correct -- second zoom");
t.eq(overviewCenter.lat, 0,
"OverviewMap center lat correct -- second zoom");
t.eq(overviewZoom, 0,
"OverviewMap zoomcorrect -- second zoom");
map.destroy();
}
);
}
function test_initialize_maximized(t) {
@@ -156,8 +189,10 @@
controls: [control]
});
t.eq(control.maximized, false, "OverviewMap is not maximized by default");
t.eq(control.element.style.display, 'none', "OverviewMap.element is not visible");
t.eq(control.maximized, false,
"OverviewMap is not maximized by default");
t.eq(control.element.style.display, 'none',
"OverviewMap.element is not visible");
map.destroy();
control = new OpenLayers.Control.OverviewMap({
@@ -167,8 +202,10 @@
layers : [new OpenLayers.Layer("layer", {isBaseLayer: true})],
controls: [control]
});
t.eq(control.maximized, true, "OverviewMap.maximized is set");
t.eq(control.element.style.display, '', "OverviewMap.element is visible");
t.eq(control.maximized, true,
"OverviewMap.maximized is set");
t.eq(control.element.style.display, '',
"OverviewMap.element is visible");
map.destroy();
}
@@ -176,6 +213,6 @@
</script>
</head>
<body>
<div id="map" style="width: 1024px; height: 512px;"/>
<div id="map" style="width: 1024px; height: 512px;"></div>
</body>
</html>

View File

@@ -11,6 +11,7 @@
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink('permalink', 'test.html');
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -18,6 +19,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink('permalink');
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -25,6 +27,7 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -32,6 +35,7 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({anchor: true});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -39,18 +43,21 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(control.element == null, "element is null");
t.ok(control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({anchor: false});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html'});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -58,6 +65,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html', anchor: true});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -65,6 +73,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(control.anchor, "anchor is correct");
control.destroy();
}
function test_Control_Permalink_uncentered (t) {
t.plan( 1 );
@@ -74,12 +83,14 @@
map.addControl(control);
map.events.triggerEvent("changelayer", {});
t.ok(true, "permalink didn't bomb out.");
map.destroy();
}
function test_Control_Permalink_initwithelem (t) {
t.plan( 1 );
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
t.ok(true, "If the above line doesn't throw an error, we're safe.");
control.destroy();
}
function test_Control_Permalink_updateLinks (t) {
t.plan( 3 );
@@ -100,6 +111,7 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_Control_Permalink_updateLinksBase (t) {
t.plan( 2 );
@@ -114,6 +126,7 @@
map.pan(5, 0, {animate:false});
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base");
map.destroy();
}
function test_Control_Permalink_noElement (t) {
t.plan( 2 );
@@ -122,6 +135,7 @@
map = new OpenLayers.Map('map');
map.addControl(control);
t.eq(map.controls[4].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." );
map.destroy();
}
function test_Control_Permalink_base_with_query (t) {
t.plan( 3 );
@@ -147,6 +161,7 @@
map.pan(5, 0, {animate:false});
map.pan(-5, 0, {animate:false});
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'");
map.destroy();
}
@@ -163,6 +178,7 @@
map.pan(5, 0, {animate:false});
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with existing zoom in base");
map.destroy();
}
function test_Control_Permalink_customized(t) {
@@ -189,6 +205,7 @@
t.eq(this.map.controls[this.map.controls.length-1].CLASS_NAME, "CustomArgParser", "Custom ArgParser added correctly.");
t.eq(control.div.firstChild.getAttribute("href"), "./edit.html?zoom=2&lat=0&lon=1.75781&layers=B&customParam=foo", "Custom parameter encoded correctly.");
map.destroy();
}
function test_Control_Permalink_createParams(t) {
@@ -300,6 +317,7 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getParameterString(control.createParams()), "zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_Control_Permalink_AnchorBaseElement (t) {
@@ -320,7 +338,80 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"#zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_center_from_map(t) {
t.plan(7);
var previous = window.location.hash;
window.location.hash = "";
var err;
try {
var map = new OpenLayers.Map({
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
controls: [
new OpenLayers.Control.Permalink({anchor: true})
],
center: [1, 2],
zoom: 3
});
} catch (e) {
err = e;
}
if (err) {
t.fail("Map construction failure: " + err.message);
} else {
t.ok(true, "Map construction works");
}
// confirm that map center is correctly set
var center = map.getCenter();
t.eq(center.lon, 1, "map x");
t.eq(center.lat, 2, "map y")
t.eq(map.getZoom(), 3, "map z");
// confirm that location from map options has been added to url
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
t.eq(params.lon, "1", "url x");
t.eq(params.lat, "2", "url y");
t.eq(params.zoom, "3", "url z");
map.destroy();
window.location.hash = previous;
}
function test_center_from_url(t) {
t.plan(6);
// In cases where the location is specified in the URL and given in
// the map options, we respect the location in the URL.
var previous = window.location.hash;
window.location.hash = "#zoom=6&lat=5&lon=4&layers=B"
var map = new OpenLayers.Map({
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
controls: [new OpenLayers.Control.Permalink({anchor: true})],
center: [0, 0],
zoom: 0
});
// confirm that map center is correctly set
var center = map.getCenter();
t.eq(center.lon, 4, "map x");
t.eq(center.lat, 5, "map y")
t.eq(map.getZoom(), 6, "map z");
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
t.eq(params.lon, "4", "x set");
t.eq(params.lat, "5", "y set");
t.eq(params.zoom, "6", "z set");
map.destroy();
window.location.hash = previous;
}
</script>
</head>
<body>

View File

@@ -475,6 +475,35 @@
}
function test_exceptions(t) {
t.plan(1);
var map = new OpenLayers.Map("map", {
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
}
);
var a = new OpenLayers.Layer.WMS("dummy","http://myhost/wms", {
layers: "x",
exceptions: "text/xml"
});
map.addLayer(a);
var click = new OpenLayers.Control.WMSGetFeatureInfo({
});
map.addControl(click);
var _request = OpenLayers.Request.GET;
OpenLayers.Request.GET = function(options) {
t.eq(options.params["EXCEPTIONS"], "text/xml", "Exceptions parameter taken from the WMS layer if provided");
};
click.activate();
click.getInfoForClick({xy: {x: 50, y: 50}});
OpenLayers.Request.GET = _request;
map.destroy();
}
function test_drillDown(t) {
t.plan(6);
var map = new OpenLayers.Map("map", {

81
tests/Control/Zoom.html Normal file
View File

@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_constructor(t) {
t.plan(5);
var control = new OpenLayers.Control.Zoom();
t.ok(control instanceof OpenLayers.Control, "instance of Control");
t.ok(control instanceof OpenLayers.Control.Zoom, "instance of Zoom");
t.eq(control.displayClass, "olControlZoom", "displayClass");
control.destroy();
control = new OpenLayers.Control.Zoom({
zoomInText: "zoom in!",
zoomOutText: "zoom out!"
});
t.eq(control.zoomInText, "zoom in!", "zoomInText");
t.eq(control.zoomOutText, "zoom out!", "zoomOutText");
control.destroy();
}
function test_addControl(t) {
t.plan(3);
var map = new OpenLayers.Map("map");
var control = new OpenLayers.Control.Zoom();
map.addControl(control);
t.ok(control.map === map, "Control.map set");
t.ok(!!~OpenLayers.Util.indexOf(map.controls, control), "map.controls contains control");
control = new OpenLayers.Control.Zoom({zoomInId: "in", zoomOutId: "out"});
map.addControl(control);
var eventsEl = document.getElementById("out").parentNode;
t.ok(control.events.element === eventsEl, "Events instance listens to custom div's parentNode");
map.destroy();
}
function test_zoomIn(t) {
t.plan(2);
var map = new OpenLayers.Map({
div: "map",
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})]
});
var control = new OpenLayers.Control.Zoom();
map.addControl(control);
map.setCenter([0, 0], 0);
t.eq(map.getZoom(), 0, "initial center");
map.events.triggerEvent("buttonclick", {buttonElement: control.zoomInLink});
t.eq(map.getZoom(), 1, "after zoom in");
map.destroy();
}
function test_zoomOut(t) {
t.plan(2);
var map = new OpenLayers.Map({
div: "map",
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})]
});
var control = new OpenLayers.Control.Zoom();
map.addControl(control);
map.setCenter([0, 0], 1);
t.eq(map.getZoom(), 1, "initial center");
map.events.triggerEvent("buttonclick", {buttonElement: control.zoomOutLink});
t.eq(map.getZoom(), 0, "after zoom out");
map.destroy();
}
</script>
</head>
<body>
<div id="map" style="width: 512px; height: 256px;"/>
<div id="in">in</div><div id="out">out</out>
</body>
</html>

View File

@@ -27,9 +27,44 @@
buttonClick.destroy();
events.destroy();
}
function test_getPressedButton(t) {
t.plan(4);
// set up
events = new OpenLayers.Events({}, element);
buttonClick = new OpenLayers.Events.buttonclick(events);
var button = document.createElement('button'),
span1 = document.createElement('span'),
span2 = document.createElement('span'),
span3 = document.createElement('span');
button.className = 'olButton';
button.appendChild(span1);
span1.appendChild(span2);
span2.appendChild(span3);
t.ok(buttonClick.getPressedButton(button) === button,
'getPressedButton returns button when element is button');
t.ok(buttonClick.getPressedButton(span1) === button,
'getPressedButton returns button when element is button descendant level 1');
t.ok(buttonClick.getPressedButton(span2) === button,
'getPressedButton returns button when element is button descendant level 2');
t.eq(buttonClick.getPressedButton(span3), undefined,
'getPressedButton returns undefined when element is button descendant level 3');
// test
// tear down
buttonClick.destroy();
events.destroy();
}
function test_ButtonClick_buttonClick(t) {
t.plan(23);
t.plan(27);
events = new OpenLayers.Events({}, element);
events.on({
"buttonclick": logEvent,
@@ -38,7 +73,8 @@
"click": logEvent,
"dblclick": logEvent,
"touchstart": logEvent,
"touchend": logEvent
"touchend": logEvent,
"keydown": logEvent
});
buttonClick = events.extensions["buttonclick"];
@@ -111,12 +147,26 @@
t.eq(log[1].type, "buttonclick", "buttonclick for 2nd click IE");
// rightclick
log = []
log = [];
trigger({type: "mousedown", button: 2});
trigger({type: "mouseup", button: 2});
t.eq(log.length, 2, "two events fired for rightclick");
t.eq(log[0].type, "mousedown", "mousedown from rightclick goes through");
t.eq(log[1].type, "mouseup", "mouseup from rightclick goes through");
// keydown RETURN
log = [];
trigger({type: "keydown", keyCode: OpenLayers.Event.KEY_RETURN});
trigger({type: "click"});
t.eq(log.length, 1, "one event fired for RETURN keydown");
t.eq(log[0].type, "buttonclick", "buttonclick for RETURN keydown");
// keydown SPACE
log = [];
trigger({type: "keydown", keyCode: OpenLayers.Event.KEY_SPACE});
trigger({type: "click"});
t.eq(log.length, 1, "one event fired for SPACE keydown");
t.eq(log[0].type, "buttonclick", "buttonclick for SPACE keydown");
}
</script>
</head>

View File

@@ -198,21 +198,35 @@
t.ok(style.t, "getStyle returns copy of style rather than reference");
}
function test_Format_KML_extendedData(t) {
t.plan(2);
t.plan(6);
var f = new OpenLayers.Format.KML();
var features = f.read(OpenLayers.Util.getElement("kml_extendeddata").value);
t.eq(features[0].attributes.all_bridges.value, "3030", "read value from extendeddata correctly.");
t.eq(features[0].attributes.all_bridges.displayName, "all bridges", "read displayName from extendeddata correctly.");
t.eq(features[0].attributes.holeYardage.value, "234", "read value from extendeddata correctly.");
t.eq(features[0].attributes.holeYardage.displayName, "<b><i>The yardage is </i></b>", "read displayName from extendeddata correctly.");
t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage.value, features[0].attributes.holeYardage.value, "attribute value written correctly");
t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage.displayName, features[0].attributes.holeYardage.displayName, "attribute displayName written correctly");
f.kvpAttributes = true;
features = f.read(OpenLayers.Util.getElement("kml_extendeddata").value);
t.eq(features[0].attributes.holeYardage, "234", "read kvp value from extendeddata correctly.");
t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage, features[0].attributes.holeYardage, "kvp attribute value written correctly");
}
function test_Format_KML_extendedData_SchemaData(t) {
t.plan(4);
t.plan(10);
var f = new OpenLayers.Format.KML();
var features = f.read(OpenLayers.Util.getElement("kml_extendeddata2").value);
t.eq(features[0].attributes.TrailHeadName.value, "Pi in the sky", "read value from extendeddata (schema data) correctly.");
t.eq(features[0].attributes.TrailHeadName.displayName, "TrailHeadName", "read displayName from extendeddata correctly");
t.eq(features[0].attributes.ElevationGain.value, "10", "read value from extendeddata (schema data) correctly.");
t.eq(features[0].attributes.ElevationGain.displayName, "ElevationGain", "read displayName from extendeddata correctly");
t.eq(f.read(f.write(features[0]))[0].attributes.TrailHeadName.value, features[0].attributes.TrailHeadName.value, "attribute value from extendeddata (schema data) written correctly");
t.eq(f.read(f.write(features[0]))[0].attributes.ElevationGain.value, features[0].attributes.ElevationGain.value, "attribute value from extendeddata (schema data) written correctly");
f.kvpAttributes = true;
features = f.read(OpenLayers.Util.getElement("kml_extendeddata2").value);
t.eq(features[0].attributes.TrailHeadName, "Pi in the sky", "read kvp value from extendeddata (schema data) correctly.");
t.eq(features[0].attributes.ElevationGain, "10", "read kvp value from extendeddata (schema data) correctly.");
t.eq(f.read(f.write(features[0]))[0].attributes.TrailHeadName, features[0].attributes.TrailHeadName, "kvp attribute value from extendeddata (schema data) written correctly");
t.eq(f.read(f.write(features[0]))[0].attributes.ElevationGain, features[0].attributes.ElevationGain, "kvp attribute value from extendeddata (schema data) written correctly");
}
function test_Format_KML_placemarkName(t) {
@@ -287,49 +301,61 @@
</head>
<body>
<textarea id="kml_extendeddata" style="display:none">
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Placemark>
<styleUrl>#default</styleUrl>
<ExtendedData>
<Data name='all_bridges'>
<displayName><![CDATA[all bridges]]></displayName>
<value><![CDATA[3030]]></value>
</Data>
<Data name='latitude'>
<displayName><![CDATA[latitude]]></displayName>
<value><![CDATA[43]]></value>
</Data>
<Data name='longitude'>
<displayName><![CDATA[longitude]]></displayName>
<value><![CDATA[-107.55]]></value>
</Data>
<Data name='functionally_obsolete__percent'>
<displayName><![CDATA[functionally obsolete, percent]]></displayName>
<value><![CDATA[8]]></value>
</Data>
<Data name='structurally_deficient__percent'>
<displayName><![CDATA[structurally deficient, percent]]></displayName>
<value><![CDATA[13]]></value>
</Data>
<Data name='state'>
<displayName><![CDATA[state]]></displayName>
<value><![CDATA[Wyoming]]></value>
</Data>
</ExtendedData>
<Point>
<coordinates>-107.55,43.0</coordinates>
</Point>
</Placemark>
</Document>
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Entity-Replacement</name>
<Placemark>
<name>Club house</name>
<ExtendedData>
<Data name="holeNumber">
<displayName><![CDATA[
<b>This is hole </b>
]]></displayName>
<value>1</value>
</Data>
<Data name="holePar">
<displayName><![CDATA[
<i>The par for this hole is </i>
]]></displayName>
<value>4</value>
</Data>
<Data name="holeYardage">
<displayName><![CDATA[<b><i>The yardage is </i></b>]]></displayName>
<value>234</value>
</Data>
</ExtendedData>
<Point>
<coordinates>-111.956,33.5043</coordinates>
</Point>
</Placemark>
<Placemark>
<name>By the lake</name>
<ExtendedData>
<Data name="holeNumber">
<displayName><![CDATA[
<b>This is hole </b>
]]></displayName>
<value>5</value>
</Data>
<Data name="holePar">
<displayName><![CDATA[
<i>The par for this hole is </i>
]]></displayName>
<value>5</value>
</Data>
<Data name="holeYardage">
<displayName><![CDATA[
<b><i>The yardage is </i></b>
]]></displayName>
<value>523</value>
</Data>
</ExtendedData>
<Point>
<coordinates>-111.95,33.5024</coordinates>
</Point>
</Placemark>
</Document>
</kml>
</textarea>
<textarea id="kml_extendeddata2" style="display:none">

View File

@@ -47,6 +47,19 @@
'<CssParameter name="font-weight">bold</CssParameter>' +
'<CssParameter name="font-style">normal</CssParameter>' +
'</Font>' +
'<LabelPlacement>' +
'<PointPlacement>' +
'<AnchorPoint>' +
'<AnchorPointX>0.5</AnchorPointX>' +
'<AnchorPointY>0.5</AnchorPointY>' +
'</AnchorPoint>' +
'<Displacement>' +
'<DisplacementX>5</DisplacementX>' +
'<DisplacementY>5</DisplacementY>' +
'</Displacement>' +
'<Rotation>45</Rotation>' +
'</PointPlacement>' +
'</LabelPlacement>' +
'<Halo>' +
'<Radius>3</Radius>' +
'<Fill>' +
@@ -509,7 +522,57 @@
t.xml_eq(got, exp, "duplicated rules to write zIndex as FeatureTypeStyle elements");
}
function test_label_LinePlacement(t) {
t.plan(1);
var format = new OpenLayers.Format.SLD.v1_0_0({
multipleSymbolizers: true
});
// labelPerpendicularOffset takes precedence over labelAlign
var style = new OpenLayers.Style2({
rules: [
new OpenLayers.Rule({
symbolizers: [
new OpenLayers.Symbolizer.Line({
strokeColor: "red",
strokeWidth: 3
}),
new OpenLayers.Symbolizer.Text({
label: "${FOO}",
labelPerpendicularOffset: 10,
labelAlign: "rb"
})
]
})
]
});
var got = format.writeNode("sld:UserStyle", style);
var exp = readXML("label_lineplacement_test.sld").documentElement;
t.xml_eq(got, exp, "LinePlacement written out correctly");
}
function test_labelAlignToAnchorPosition(t) {
t.plan(1);
var format = new OpenLayers.Format.SLD.v1_0_0({
multipleSymbolizers: true
});
var style = new OpenLayers.Style2({
rules: [
new OpenLayers.Rule({
symbolizers: [
new OpenLayers.Symbolizer.Text({
label: "${FOO}",
labelAlign: "rb"
})
]
})
]
});
var got = format.writeNode("sld:UserStyle", style);
var exp = readXML("label_pointplacement_test.sld").documentElement;
t.xml_eq(got, exp, "PointPlacement with labelAlign written out correctly");
}
function test_read_FeatureTypeStyles(t) {
t.plan(13);
@@ -585,7 +648,6 @@
doc = readXML("polygon_labelhalo.sld");
out = format.write(format.read(doc));
t.xml_eq(out, doc.documentElement, "round-tripped polygon_labelhalo.sld");
}
</script>
@@ -867,5 +929,46 @@
</sld:FeatureTypeStyle>
</sld:UserStyle>
--></div>
<div id="label_lineplacement_test.sld"><!--
<sld:UserStyle xmlns:sld="http://www.opengis.net/sld">
<sld:FeatureTypeStyle>
<sld:Rule>
<sld:LineSymbolizer>
<sld:Stroke>
<sld:CssParameter name="stroke">red</sld:CssParameter>
<sld:CssParameter name="stroke-width">3</sld:CssParameter>
</sld:Stroke>
</sld:LineSymbolizer>
<sld:TextSymbolizer>
<sld:Label><ogc:PropertyName xmlns:ogc="http://www.opengis.net/ogc">FOO</ogc:PropertyName></sld:Label>
<sld:LabelPlacement>
<sld:LinePlacement>
<sld:PerpendicularOffset>10</sld:PerpendicularOffset>
</sld:LinePlacement>
</sld:LabelPlacement>
</sld:TextSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
--></div>
<div id="label_pointplacement_test.sld"><!--
<sld:UserStyle xmlns:sld="http://www.opengis.net/sld">
<sld:FeatureTypeStyle>
<sld:Rule>
<sld:TextSymbolizer>
<sld:Label><ogc:PropertyName xmlns:ogc="http://www.opengis.net/ogc">FOO</ogc:PropertyName></sld:Label>
<sld:LabelPlacement>
<sld:PointPlacement>
<sld:AnchorPoint>
<sld:AnchorPointX>1</sld:AnchorPointX>
<sld:AnchorPointY>0</sld:AnchorPointY>
</sld:AnchorPoint>
</sld:PointPlacement>
</sld:LabelPlacement>
</sld:TextSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
--></div>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@@ -254,21 +254,40 @@
t.plan(1);
var projections = {
src: new OpenLayers.Projection("EPSG:4326"),
dest: new OpenLayers.Projection("EPSG:900913")
};
var points = {
src: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-87.9, 41.9)),
dest: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665))
};
var format = new OpenLayers.Format.WKT({
externalProjection: projections["src"],
internalProjection: projections["dest"]
});
var feature = format.read("GEOMETRYCOLLECTION(POINT(" + points["src"].geometry.x + " " + points["src"].geometry.y + "))")[0];
t.eq(feature.geometry.toString(), points["dest"].geometry.toString(),
src: new OpenLayers.Projection("EPSG:4326"),
dest: new OpenLayers.Projection("EPSG:900913")
},
points = {
src: new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(-87.9, 41.9)
),
dest: new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665)
)
},
format = new OpenLayers.Format.WKT({
externalProjection: projections["src"],
internalProjection: projections["dest"]
}),
gc_wkt_parts = [
"GEOMETRYCOLLECTION(",
"POINT(",
points["src"].geometry.x,
" ",
points["src"].geometry.y,
")",
")"
],
feature = format.read( gc_wkt_parts.join("") )[0],
gotGeom = feature.geometry,
expectGeom = points["dest"].geometry,
// we don't use geometry::toString because we might run into
// precision issues
precision = 7,
got = gotGeom.x.toFixed(precision) + ' ' + gotGeom.y.toFixed(precision),
expected = expectGeom.x.toFixed(precision) + ' ' + expectGeom.y.toFixed(precision);
t.eq(got, expected,
"Geometry collections aren't transformed twice when reprojection.");
}
</script>

View File

@@ -147,7 +147,7 @@
var uri = "http://foo.com";
var prefix = "foo";
var localName = "bar";
var qualifiedName = prefix + ":" + name;
var qualifiedName = prefix + ":" + localName;
var node = format.createElementNS(uri, qualifiedName);
t.eq(node.nodeType, 1,
"node has correct type");

View File

@@ -42,59 +42,103 @@
}
function test_Handler_Keyboard_activate(t) {
t.plan(8);
t.plan(15);
var log;
var map = new OpenLayers.Map('map');
var control = new OpenLayers.Control();
map.addControl(control);
var handler = new OpenLayers.Handler.Keyboard(control);
handler.active = true;
var activated = handler.activate();
t.ok(!activated,
"activate returns false if the handler was already active");
handler.active = false;
handler.dragging = true;
// mock OpenLayers.Event.observe
var old = OpenLayers.Event.stopObserving;
var types = ["keydown", "keyup"];
OpenLayers.Event.observe = function(obj, type, method) {
t.ok(obj == document,
"activate calls observing with correct object");
var validType = (OpenLayers.Util.indexOf(types, type) != -1);
log[type] = obj;
var validType = OpenLayers.Util.indexOf(["keydown", "keyup"], type) != -1;
t.ok(validType, "activate calls observe for " + type);
t.ok(method == handler.eventListener,
"activate calls observing with correct method");
};
handler.active = true;
var activated = handler.activate();
t.ok(!activated,
"activate returns false if the handler was already active");
log = {};
handler.active = false;
handler.observeElement = map.div;
activated = handler.activate();
t.ok(log['keydown'] == map.div,
"activate calls observing for keydown with correct object");
t.ok(log['keyup'] == map.div,
"activate calls observing for keyup with correct object");
t.ok(activated,
"activate returns true if the handler was not already active");
log = {};
handler.active = false;
handler.observeElement = null;
activated = handler.activate();
t.ok(log['keydown'] == document,
"activate calls observing for keydown with correct object");
t.ok(log['keyup'] == document,
"activate calls observing for keyup with correct object");
t.ok(activated,
"activate returns true if the handler was not already active");
OpenLayers.Event.observe = old;
map.destroy();
}
function test_Handler_Keyboard_deactivate(t) {
t.plan(8);
t.plan(15);
var log;
var map = new OpenLayers.Map('map');
var control = new OpenLayers.Control();
map.addControl(control);
var handler = new OpenLayers.Handler.Keyboard(control);
handler.active = false;
var deactivated = handler.deactivate();
t.ok(!deactivated,
"deactivate returns false if the handler was not already active");
handler.active = true;
// mock OpenLayers.Event.stopObserving
var old = OpenLayers.Event.stopObserving;
var types = ["keydown", "keyup"];
OpenLayers.Event.stopObserving = function(obj, type, method) {
t.ok(obj == document,
"deactivate calls stopObserving with correct object");
var validType = (OpenLayers.Util.indexOf(types, type) != -1);
log[type] = obj;
var validType = OpenLayers.Util.indexOf(["keydown", "keyup"], type) != -1;
t.ok(validType, "deactivate calls stopObserving for " + type);
t.ok(method == handler.eventListener,
"deactivate calls stopObserving with correct method");
};
handler.active = false;
var deactivated = handler.deactivate();
t.ok(!deactivated,
"deactivate returns false if the handler was not already active");
log = {};
handler.active = true;
handler.observeElement = map.div;
deactivated = handler.deactivate();
t.ok(log['keydown'] == map.div,
"deactivate calls stopObserving for keydown with correct object");
t.ok(log['keyup'] == map.div,
"deactivate calls stopObserving for keyup with correct object");
t.ok(deactivated,
"deactivate returns true if the handler was active already");
log = {};
handler.active = true;
handler.observeElement = document;
deactivated = handler.deactivate();
t.ok(log['keydown'] == document,
"deactivate calls stopObserving for keydown with correct object");
t.ok(log['keyup'] == document,
"deactivate calls stopObserving for keyup with correct object");
t.ok(deactivated,
"deactivate returns true if the handler was active already");
OpenLayers.Event.stopObserving = old;
map.destroy();
}

View File

@@ -764,7 +764,7 @@
}
function test_layer_setTileSize(t) {
t.plan(6);
t.plan(4);
layer = new OpenLayers.Layer();
@@ -784,7 +784,6 @@
var size = new OpenLayers.Size(2,2);
layer.setTileSize(size);
t.ok(layer.tileSize.equals(size), "size paramater set correctly to layer's tile size");
t.ok(layer.imageOffset == null, "imageOffset and imageSize null when no gutters")
//set on layer
layer.tileSize = layerTileSize;
@@ -803,10 +802,8 @@
size = new OpenLayers.Size(10,100);
layer.setTileSize(size);
var desiredImageOffset = new OpenLayers.Pixel(-15, -15);
var desiredImageSize = new OpenLayers.Size(40, 130);
t.ok(layer.imageOffset.equals(desiredImageOffset), "image offset correctly calculated");
t.ok(layer.imageSize.equals(desiredImageSize), "image size correctly calculated");
}

View File

@@ -53,7 +53,8 @@
//initialize the layer using the JSON object from an arcgis server
//SEE: ArcGISCache.json
var layer = new OpenLayers.Layer.ArcGISCache(name, url, {
layerInfo: layerInfo
layerInfo: layerInfo,
params: {foo: "bar"}
});
var map = new OpenLayers.Map('map', {
maxExtent: layer.maxExtent,
@@ -98,14 +99,14 @@
}
];
t.plan( urlSets.length );
t.plan( urlSets.length );
for(var i=0;i<urlSets.length;i++)
{
var o = urlSets[i];
map.zoomToExtent(o.bounds, true);
var resultUrl = layer.getURL(o.bounds);
t.ok( resultUrl == o.url, "correct tile returned for " + o.bounds);
t.ok( resultUrl == o.url + "?foo=bar", "correct tile returned for " + o.bounds);
}
}

View File

@@ -1,6 +1,6 @@
<html>
<head>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false&amp;v=3.6"></script>
<script src="../../OLLoader.js"></script>
<script type="text/javascript">

View File

@@ -32,7 +32,7 @@
t.eq( layer.buffer, 0, "buffer default is 0");
t.eq( layer.ratio, 1.5, "ratio default is 1.5");
t.eq( layer.numLoadingTiles, 0, "numLoadingTiles starts at 0");
t.eq( layer.tileClass, OpenLayers.Tile.Image, "tileClass default is OpenLayers.Tile.Image");
t.ok( layer.tileClass === OpenLayers.Tile.Image, "tileClass default is OpenLayers.Tile.Image");
var obj = {};
var func = function() {};
@@ -63,7 +63,7 @@
});
map.addLayer(layer);
t.eq(layer.tileClass, myTileClass, "tileClass is set");
t.ok(layer.tileClass === myTileClass, "tileClass is set");
var instance = layer.addTile(new OpenLayers.Bounds(-10, 10, 50, 100),
new OpenLayers.Pixel(10, 12));
@@ -226,9 +226,10 @@
map.setCenter([-10, 0], 5);
var log = [];
var origDeferMoveGriddedTiles = layer.deferMoveGriddedTiles;
layer.deferMoveGriddedTiles = function() {
log.push("deferMoveGriddedTiles");
OpenLayers.Layer.WMS.prototype.deferMoveGriddedTiles.apply(this, arguments);
origDeferMoveGriddedTiles.apply(this, arguments);
}
layer.moveGriddedTiles = function() {
log.push("moveGriddedTiles");
@@ -505,7 +506,7 @@
}
function test_Layer_Grid_addTileMonitoringHooks(t) {
t.plan(15);
t.plan(17);
layer = new OpenLayers.Layer.Grid();
layer.events = {
@@ -518,6 +519,13 @@
events: {
register: function(name, obj, func) {
g_registered[name] = [obj, func];
},
on: function(obj) {
for (var o in obj) {
if (obj.hasOwnProperty(o)) {
tile.events.register(o, obj.scope, obj[o]);
}
}
}
}
}
@@ -550,6 +558,11 @@
entry = g_registered["loadend"];
t.ok( entry && entry[0] == layer && entry[1] == tile.onLoadEnd, "loadend correctly registered");
g_events = [];
tile.onLoadError.apply(layer);
t.eq(g_events[0][0], "tileerror", "tileerror triggered");
t.ok(g_events[0][1].tile === tile, "tile passed as tile property to event object");
layer.numLoadingTiles = 2;
g_events = [];
tile.onLoadEnd.apply(layer);

View File

@@ -12,7 +12,7 @@
var options = { chicken: 151, foo: "bar" };
function test_Layer_HTTPRequest_constructor (t) {
t.plan( 5 );
t.plan( 6 );
layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
@@ -27,8 +27,11 @@
t.ok( ((layer.params["map"] == '/mapdata/vmap_wms.map') &&
(layer.params["layers"] == "basic") &&
(layer.params["format"] == "image/png")), "layer.params correctly set" );
layer = new OpenLayers.Layer.HTTPRequest(name, url, null, {params: params});
t.ok( ((layer.params["map"] == '/mapdata/vmap_wms.map') &&
(layer.params["layers"] == "basic") &&
(layer.params["format"] == "image/png")), "layer.params correctly set from options" );
}
function test_Layer_HTTPRequest_clone (t) {

View File

@@ -2000,6 +2000,23 @@
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
}
function test_options(t) {
t.plan(2);
var map = new OpenLayers.Map('map');
t.eq(map.options, {}, 'map.options is empty with no options');
map.destroy();
var options = {
resolutions: [1,2,3,5],
projection: "EPSG:4326",
units: 'm'
};
var map = new OpenLayers.Map('map', options);
t.eq(map.options, options, 'map.options is a copy of the constructor option');
map.destroy();
}
function test_adjustZoom(t) {
t.plan(4);
var map = new OpenLayers.Map({

View File

@@ -6,7 +6,7 @@
function test_initialize(t) {
t.plan(3);
var protocol = new OpenLayers.Protocol.CSW({formatOptions: {foo: "bar"},});
var protocol = new OpenLayers.Protocol.CSW({formatOptions: {foo: "bar"}});
t.ok(protocol instanceof OpenLayers.Protocol.CSW.v2_0_2,
"initialize returns instance of default versioned protocol");
var format = protocol.format;

View File

@@ -135,7 +135,7 @@
}
function test_createRequest(t) {
t.plan(3);
t.plan(4);
var protocol = new OpenLayers.Protocol.Script({
callbackKey: 'cb_key',
callbackPrefix: 'cb_prefix:'
@@ -155,7 +155,13 @@
t.eq(script.id, 'OpenLayers_Protocol_Script_bar',
'created script has a correct id');
protocol.callbackTemplate = "OpenLayers.Protocol.Script.registry.${id}";
script = protocol.createRequest('http://bar_url/', {'k': 'bar_param'}, 'bar_callback');
t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.registry.bar',
'created script has a correct url with different template');
OpenLayers.Protocol.Script.register = _register;
}
function test_destroyRequest(t) {

View File

@@ -336,12 +336,18 @@
}
var num = cases.length;
t.plan(num);
t.plan(2 * num);
var c, feature;
for (var i=0; i<num; ++i) {
c = cases[i];
feature = layer.renderer.getFeatureIdFromEvent({xy: px(c.x, c.y)});
t.eq(feature && feature.id, c.id, c.msg);
// Extra test: hit detection on an invisible canvas should return undefined
layer.setVisibility(false);
feature = layer.renderer.getFeatureIdFromEvent({xy: px(c.x, c.y)});
t.eq(feature, undefined, c.msg + ' (invisible)');
layer.setVisibility(true);
}
map.destroy();

View File

@@ -79,7 +79,9 @@
// test extent changes
var extent = new OpenLayers.Bounds(4,3,2,1);
r.setExtent(extent);
t.eq(r.root.getAttributeNS(null, "transform").replace(/ /g, ""), "translate(-6,-6)", "rendererRoot viewBox is correct after a new setExtent");
var el = r.createNode("g");
el.setAttributeNS(null, "transform", "translate(-6,-6)");
t.eq(r.root.getAttributeNS(null, "transform"), el.getAttributeNS(null, "transform"), "rendererRoot viewBox is correct after a new setExtent");
OpenLayers.Renderer.Elements.prototype.setExtent =
OpenLayers.Renderer.Elements.prototype._setExtent;

View File

@@ -88,9 +88,26 @@
strategy.update({force: true});
var from = map.getProjectionObject();
var to = layer.projection;
t.eq(strategy.bounds.toString(), map.getExtent().transform(from, to).toString(), "[force update different proj] bounds transformed");
var strategyBounds = strategy.bounds,
mapExtent = map.getExtent().transform(from, to),
// we don't use bounds::toString because we might run into
// precision issues
precision = 7,
strategyBoundsGot = [
strategyBounds.left.toFixed( precision ),
strategyBounds.bottom.toFixed( precision ),
strategyBounds.right.toFixed( precision ),
strategyBounds.top.toFixed( precision )
].join(','),
mapExtentExpected = [
mapExtent.left.toFixed( precision ),
mapExtent.bottom.toFixed( precision ),
mapExtent.right.toFixed( precision ),
mapExtent.top.toFixed( precision )
].join(',');
t.eq(strategyBoundsGot, mapExtentExpected,
"[force update different proj] bounds transformed");
}
function test_events(t) {

View File

@@ -141,7 +141,7 @@ Test.AnotherWay.quicksearch = function(){
Test.AnotherWay.filterTestList = function(str){
Test.AnotherWay.unfilterTestList();
var re = new RegExp(str, 'i');
var candidates = document.querySelectorAll('#testtable tr td:nth-child(2) a');
var candidates = document.querySelectorAll('#testtable tr a');
for (var idx = 0, len = candidates.length; idx<len; idx++) {
var tr = candidates[idx].parentNode.parentNode;
var html = candidates[idx].innerHTML;
@@ -164,10 +164,10 @@ Test.AnotherWay.unfilterTestList = function() {
};
// bind our quicksearch init method to body onload.
(function(win){
(function(win) {
if (win.addEventListener) {
win.addEventListener('load', Test.AnotherWay.bindQuicksearchListener);
} else if (input.attachEvent) {
} else if (win.attachEvent) {
win.attachEvent('onload', Test.AnotherWay.bindQuicksearchListener);
} else {
win.onload = function(){

View File

@@ -295,9 +295,6 @@
t.ok(tile.layer.imageSize == null,
"zero size gutter doesn't set image size");
t.ok(tile.layer.imageOffset == null,
"zero size gutter doesn't set image offset");
var zero_gutter_bounds = tile.bounds;
map.destroy();
@@ -312,8 +309,12 @@
tile.size.h + (2 * gutter))),
"gutter properly changes image size");
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(-gutter, -gutter)),
"gutter properly sets image offset");
var offsetLeft = -(gutter / layer.tileSize.w * 100) | 0;
var offsetTop = -(gutter / layer.tileSize.h * 100) | 0;
t.eq(parseInt(tile.imgDiv.style.left, 10), offsetLeft,
"gutter properly sets image left style");
t.eq(parseInt(tile.imgDiv.style.top, 10), offsetTop,
"gutter properly sets image top style");
t.ok(tile.bounds.equals(zero_gutter_bounds),
"gutter doesn't affect tile bounds");
@@ -374,7 +375,7 @@
// test for https://github.com/openlayers/openlayers/pull/36
// (more an integration test than a unit test)
function test_olImageLoadError(t) {
t.plan(2);
t.plan(6);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS("invalid", "", {layers: 'basic'});
@@ -385,10 +386,25 @@
var bounds = new OpenLayers.Bounds(1, 2, 3, 4);
var tile = new OpenLayers.Tile.Image(layer, position, bounds, null, size);
var log = [];
tile.events.register("loaderror", this, function(e) {
log.push([
e.object.imgDiv.style.visibility,
OpenLayers.Element.hasClass(e.object.imgDiv, 'olImageLoadError')
]);
});
tile.events.register("loadend", this, function(e) {
log.push(e);
})
tile.draw();
t.delay_call(0.1, function() {
t.eq(log.length, 2, "loaderror and loadend events triggered");
t.eq(log[0][0], "hidden", "tile still hidden when loaderror is triggered");
t.eq(log[0][1], true, "tile has olImageLoadError class already when loaderror is triggered");
t.ok(log[1].object === tile, "loadend event triggered after loaderror");
// check initial state
t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError'),
'tile image has the olImageLoadError class (init state)');

View File

@@ -7,7 +7,7 @@
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
var isIE = (navigator.userAgent.indexOf("MSIE") != -1);
var isIElt9 = (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9);
var map, layer;
var position = new OpenLayers.Pixel(20,30);
@@ -96,17 +96,17 @@
var eventPane = tile.frame.childNodes[0];
t.ok(OpenLayers.String.contains(eventPane.style.backgroundImage,
tile.blankImageUrl),
tile._blankImageUrl),
"backgroundImage of eventPane is set.");
t.eq(parseInt(eventPane.style.zIndex, 10), 1, "zIndex of eventPane is set.");
if(isIE) {
if(isIElt9) {
t.ok(iFrame != null, "IFrame successfully created.");
t.eq(iFrame.style.backgroundColor, '#ffffff', "backgroundColor correctly set.");
t.eq(iFrame.style.filter, 'chroma(color=#FFFFFF)', "filter correctly set.");
} else {
t.ok(iFrame instanceof HTMLElement, "IFrame successfully created.");
t.ok(true, 'Skip IFrame backgroundColor test outside IE');
t.ok(true, 'Skip IFrame filter test outside IE');
t.ok(true, 'Skip IFrame backgroundColor test outside IE < 9');
t.ok(true, 'Skip IFrame filter test outside IE < 9');
}
t.eq( iFrame.scrolling, 'no', "no scrolling");
t.eq( parseFloat(iFrame.marginWidth), 0, "no margin width");

View File

@@ -1,5 +1,20 @@
<html>
<head>
<script>
/**
* Because browsers that implement requestAnimationFrame may not execute
* animation functions while a window is not displayed (e.g. in a hidden
* iframe as in these tests), we mask the native implementations here. The
* native requestAnimationFrame functionality is tested in Util.html and
* in PanZoom.html (where a popup is opened before panning). The panTo tests
* here will test the fallback setTimeout implementation for animation.
*/
window.requestAnimationFrame =
window.webkitRequestAnimationFrame =
window.mozRequestAnimationFrame =
window.oRequestAnimationFrame =
window.msRequestAnimationFrame = null;
</script>
<script src="OLLoader.js"></script>
<script type="text/javascript">

View File

@@ -1120,7 +1120,31 @@
t.eq(OpenLayers.Util.getFormattedLonLat(-181, "lon"), "179°00'00\"E", "crossing dateline from the west results in correct east coordinate");
t.eq(OpenLayers.Util.getFormattedLonLat(181, "lon"), "179°00'00\"W", "crossing dateline from the east results in correct west coordinate");
}
/**
* To test that we can safely call OpenLayers.Util.extend with an Event
* instance, we need to capture a real event.
*/
var loadEvent;
window.onload = function(evt) {
loadEvent = evt || window.event;
}
function test_extend_event(t) {
t.plan(2);
t.ok(loadEvent, "loadEvent recorded");
var extended, err;
try {
extended = OpenLayers.Util.extend({foo: "bar"}, loadEvent);
} catch (e) {
err = e;
}
if (err) {
t.fail("Failed to extend with an event: " + err.message);
} else {
t.eq(extended && extended.foo, "bar", "extended with event");
}
}
</script>
</head>
<body>

View File

@@ -31,6 +31,7 @@
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
var tile = layer.grid[0][0];
tile.draw(true); // the tile queue defers the drawing
t.eq( tile.bounds.left, -22.5, "left side matches" );
t.eq( tile.bounds.right, -11.25, "top side matches" );
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );

View File

@@ -31,6 +31,7 @@
map.addLayer(wmslayer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
var tile = wmslayer.grid[0][0];
tile.draw(true); // the tile queue defers the drawing
t.eq( tile.bounds.left, -22.5, "left side matches" );
t.eq( tile.bounds.right, -11.25, "right side matches" );
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );

View File

@@ -46,6 +46,7 @@
<li>Control/WMTSGetFeatureInfo.html</li>
<li>Control/PanPanel.html</li>
<li>Control/SLDSelect.html</li>
<li>Control/Zoom.html</li>
<li>Events.html</li>
<li>Events/buttonclick.html</li>
<li>Extras.html</li>

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="../../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="../../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="../../examples/style.css" type="text/css">
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false&amp;v=3.6"></script>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map;

View File

@@ -20,7 +20,7 @@
padding: 0 0.5em 0.5em 0.5em;
}
</style>
<script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script>
<script src="../../lib/OpenLayers.js"></script>
</head>
<body>

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="../../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="../../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="../../examples/style.css" type="text/css">
<script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script>
<script src="../../lib/OpenLayers.js"></script>
</head>
<body onload="init()">

View File

@@ -3,7 +3,7 @@
<title>Google v3 Resize Test</title>
<link rel="stylesheet" href="../../theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="../../examples/style.css" type="text/css" />
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false&amp;v=3.6"></script>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map;

View File

@@ -429,6 +429,44 @@ span.olGoogleAttribution.hybrid a, span.olGoogleAttribution.satellite a {
background-position: -26px -24px;
}
div.olControlZoom {
position: absolute;
top: 8px;
left: 8px;
}
div.olControlZoom a {
display: block;
margin: 2px;
padding: 0 4px;
color: white;
font-size: 18px;
font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
font-weight: bold;
text-decoration: none;
text-align: center;
height: 22px;
width: 15px;
line-height: 22px;
background: #666666; /* fallback for IE - IE6 requires background shorthand*/
background: rgba(0, 0, 0, 0.3);
border: 1px solid;
border-color: #ffffff; /* fallback for IE */
border-color: rgba(255, 255, 255, 0.6);
filter: alpha(opacity=60);
}
div.olControlZoom a:hover {
background: #444444; /* fallback for IE */
background: rgba(0, 0, 0, 0.5);
filter: alpha(opacity=80);
}
a.olControlZoomIn {
border-radius: 5px 5px 0 0;
}
a.olControlZoomOut {
border-radius: 0 0 5px 5px;
}
/**
* Animations
*/

View File

@@ -9,7 +9,13 @@ svn export http://svn.openlayers.org/tags/openlayers/release-$VERSION OpenLayers
cd OpenLayers-$VERSION/build
mv ../../compiler.jar ../tools/closure-compiler.jar
./build.py -c closure full
./build.py -c closure mobile OpenLayers.mobile.js
./build.py -c closure light OpenLayers.light.js
./build.py -c none full OpenLayers.debug.js
./build.py -c none mobile OpenLayers.mobile.debug.js
./build.py -c none light OpenLayers.light.debug.js
cp OpenLayers.js ..
cp OpenLayers.*.js ..
rm ../tools/closure-compiler.jar
cd ..

Some files were not shown because too many files have changed in this diff Show More