Merge branch 'master' of https://github.com/openlayers/openlayers into vendor-prefixes

This commit is contained in:
Gregers Gram Rygg
2012-06-24 02:38:05 +02:00
92 changed files with 1201 additions and 447 deletions

View File

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

View File

@@ -34,7 +34,7 @@
}, },
trigger: function(e) { trigger: function(e) {
var lonlat = map.getLonLatFromViewPortPx(e.xy); var lonlat = map.getLonLatFromPixel(e.xy);
alert("You clicked near " + lonlat.lat + " N, " + alert("You clicked near " + lonlat.lat + " N, " +
+ lonlat.lon + " E"); + lonlat.lon + " E");
} }
@@ -75,7 +75,7 @@
<p id="shortdesc"> <p id="shortdesc">
This example shows the use of the click handler and This example shows the use of the click handler and
getLonLatFromViewPortPx functions to trigger events on mouse click. getLonLatFromPixel functions to trigger events on mouse click.
</p> </p>
<div id="map" class="smallmap"></div> <div id="map" class="smallmap"></div>

View File

@@ -20,7 +20,7 @@ map.addControl(draw);
draw.activate(); draw.activate();
// handle clicks on method links // handle clicks on method links
$("insertXY").onclick = function() { document.getElementById("insertXY").onclick = function() {
var values = parseInput( var values = parseInput(
window.prompt( window.prompt(
"Enter map coordinates for new point (e.g. '-111, 46')", "x, y" "Enter map coordinates for new point (e.g. '-111, 46')", "x, y"
@@ -30,7 +30,7 @@ $("insertXY").onclick = function() {
draw.insertXY(values[0], values[1]); draw.insertXY(values[0], values[1]);
} }
}; };
$("insertDeltaXY").onclick = function() { document.getElementById("insertDeltaXY").onclick = function() {
var values = parseInput( var values = parseInput(
window.prompt( window.prompt(
"Enter offset values for new point (e.g. '15, -10')", "dx, dy" "Enter offset values for new point (e.g. '15, -10')", "dx, dy"
@@ -40,7 +40,7 @@ $("insertDeltaXY").onclick = function() {
draw.insertDeltaXY(values[0], values[1]); draw.insertDeltaXY(values[0], values[1]);
} }
}; };
$("insertDirectionLength").onclick = function() { document.getElementById("insertDirectionLength").onclick = function() {
var values = parseInput( var values = parseInput(
window.prompt( window.prompt(
"Enter direction and length offset values for new point (e.g. '-45, 10')", "direction, length" "Enter direction and length offset values for new point (e.g. '-45, 10')", "direction, length"
@@ -50,7 +50,7 @@ $("insertDirectionLength").onclick = function() {
draw.insertDirectionLength(values[0], values[1]); draw.insertDirectionLength(values[0], values[1]);
} }
}; };
$("insertDeflectionLength").onclick = function() { document.getElementById("insertDeflectionLength").onclick = function() {
var values = parseInput( var values = parseInput(
window.prompt( window.prompt(
"Enter deflection and length offset values for new point (e.g. '15, 20')", "deflection, length" "Enter deflection and length offset values for new point (e.g. '15, 20')", "deflection, length"
@@ -60,10 +60,10 @@ $("insertDeflectionLength").onclick = function() {
draw.insertDeflectionLength(values[0], values[1]); draw.insertDeflectionLength(values[0], values[1]);
} }
}; };
$("cancel").onclick = function() { document.getElementById("cancel").onclick = function() {
draw.cancel(); draw.cancel();
}; };
$("finishSketch").onclick = function() { document.getElementById("finishSketch").onclick = function() {
draw.finishSketch(); draw.finishSketch();
}; };

View File

@@ -35,7 +35,7 @@
function init() { function init() {
map = new OpenLayers.Map( 'map', map = new OpenLayers.Map( 'map',
{ {
'maxExtent': new OpenLayers.Bounds(0, 0, $("map").clientWidth, $("map").clientHeight), 'maxExtent': new OpenLayers.Bounds(0, 0, document.getElementById("map").clientWidth, document.getElementById("map").clientHeight),
controls: [], controls: [],
maxResolution: 'auto'} maxResolution: 'auto'}
); );

View File

@@ -92,16 +92,15 @@ geolocate.events.register("locationupdated",geolocate,function(e) {
geolocate.events.register("locationfailed",this,function() { geolocate.events.register("locationfailed",this,function() {
OpenLayers.Console.log('Location detection failed'); OpenLayers.Console.log('Location detection failed');
}); });
document.getElementById('locate').onclick = function() {
$('locate').onclick = function() {
vector.removeAllFeatures(); vector.removeAllFeatures();
geolocate.deactivate(); geolocate.deactivate();
$('track').checked = false; document.getElementById('track').checked = false;
geolocate.watch = false; geolocate.watch = false;
firstGeolocation = true; firstGeolocation = true;
geolocate.activate(); geolocate.activate();
}; };
$('track').onclick = function() { document.getElementById('track').onclick = function() {
vector.removeAllFeatures(); vector.removeAllFeatures();
geolocate.deactivate(); geolocate.deactivate();
if (this.checked) { if (this.checked) {
@@ -110,4 +109,4 @@ $('track').onclick = function() {
geolocate.activate(); geolocate.activate();
} }
}; };
$('track').checked = false; document.getElementById('track').checked = false;

View File

@@ -48,7 +48,6 @@
</style> </style>
<script defer="defer" type="text/javascript"> <script defer="defer" type="text/javascript">
OpenLayers.ProxyHost = "proxy.cgi?url="; OpenLayers.ProxyHost = "proxy.cgi?url=";
var map, infocontrols, water, highlightlayer; var map, infocontrols, water, highlightlayer;
function load() { function load() {
@@ -125,7 +124,7 @@
highlightLayer.addFeatures(evt.features); highlightLayer.addFeatures(evt.features);
highlightLayer.redraw(); highlightLayer.redraw();
} else { } else {
$('responseText').innerHTML = evt.text; document.getElementById('responseText').innerHTML = evt.text;
} }
} }

View File

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

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"> <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="../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css"> <link rel="stylesheet" href="style.css" type="text/css">
<script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script> <script src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>
<script src="../lib/OpenLayers.js"></script> <script src="../lib/OpenLayers.js"></script>
<script src="google-v3.js"></script> <script src="google-v3.js"></script>
</head> </head>
@@ -35,6 +35,17 @@
location, you must include the extra theme/default/google.css location, you must include the extra theme/default/google.css
stylesheet. stylesheet.
</p> </p>
<p>
<strong>Note on Google Maps API versioning:</strong>
This example uses the "nightly" version of Google Maps
API. This is specified by using <code>v=3</code> in the
the Google Maps API URL. Production applications should use the
"release" or "frozen" versions of Google Maps
API. See the <code>OpenLayers.Layer.Google.v3</code> API
docs, and the
<a href="https://developers.google.com/maps/documentation/javascript/basics#Versioning">Versioning Section</a>
of the Google Maps API docs, for more details.
</p>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -29,13 +29,14 @@ function init() {
var fid, points = [], feature; var fid, points = [], feature;
for (var i=0, len=e.features.length; i<len; i++) { for (var i=0, len=e.features.length; i<len; i++) {
feature = e.features[i]; feature = e.features[i];
if (feature.fid !== fid || i === len-1) { if ((fid && feature.fid !== fid) || i === len-1) {
fid = feature.fid;
this.addNodes(points, {silent: true}); this.addNodes(points, {silent: true});
points = []; points = [];
} } else {
points.push(feature); points.push(feature);
} }
fid = feature.fid;
}
return false; return false;
} }
} }

28
examples/mapquest.html Normal file
View File

@@ -0,0 +1,28 @@
<!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 MapQuest Demo</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<h1 id="title">OpenLayers with MapQuest Tiles</h1>
<div id="shortdesc">
This example demonstrates the use of MapQuest tiles with OpenLayers.
</div>
<div id="tags">
MapQuest, OSM, XYZ
</div>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>
See the <a href="mapquest.js" target="_blank">mapquest.js source</a> for
detail on using MapQuest tiles in OpenLayers.
</p>
</div>
<script src="../lib/OpenLayers.js"></script>
<script src="mapquest.js"></script>
</body>

36
examples/mapquest.js Normal file
View File

@@ -0,0 +1,36 @@
var map = new OpenLayers.Map({
div: "map",
projection: "EPSG:900913",
layers: [
new OpenLayers.Layer.XYZ(
"OpenStreetMap",
[
"http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
"http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
"http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
"http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png"
],
{
attribution: "Data, imagery and map information provided by <a href='http://www.mapquest.com/' target='_blank'>MapQuest</a>, <a href='http://www.openstreetmap.org/' target='_blank'>Open Street Map</a> and contributors, <a href='http://creativecommons.org/licenses/by-sa/2.0/' target='_blank'>CC-BY-SA</a> <img src='http://developer.mapquest.com/content/osm/mq_logo.png' border='0'>",
transitionEffect: "resize"
}
),
new OpenLayers.Layer.XYZ(
"Imagery",
[
"http://oatile1.mqcdn.com/naip/${z}/${x}/${y}.png",
"http://oatile2.mqcdn.com/naip/${z}/${x}/${y}.png",
"http://oatile3.mqcdn.com/naip/${z}/${x}/${y}.png",
"http://oatile4.mqcdn.com/naip/${z}/${x}/${y}.png"
],
{
attribution: "Tiles Courtesy of <a href='http://open.mapquest.co.uk/' target='_blank'>MapQuest</a>. Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency. <img src='http://developer.mapquest.com/content/osm/mq_logo.png' border='0'>",
transitionEffect: "resize"
}
)
],
center: [0, 0],
zoom: 1
});
map.addControl(new OpenLayers.Control.LayerSwitcher());

View File

@@ -99,7 +99,7 @@
var pixel = new OpenLayers.Pixel(center.x + x, center.y + y); var pixel = new OpenLayers.Pixel(center.x + x, center.y + y);
var lonLat = map.getLonLatFromViewPortPx(pixel); var lonLat = map.getLonLatFromPixel(pixel);
features.push( features.push(
new OpenLayers.Feature.Vector( new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat) new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)

View File

@@ -5,7 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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="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"> <meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="style.mobile.css" type="text/css"> <link rel="stylesheet" href="../theme/default/style.mobile.css" type="text/css">
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"> <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<script src="../lib/OpenLayers.js?mobile"></script> <script src="../lib/OpenLayers.js?mobile"></script>
<script src="mobile-drawing.js"></script> <script src="mobile-drawing.js"></script>

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css">
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<link rel="stylesheet" href="style.mobile.css" type="text/css"> <link rel="stylesheet" href="../theme/default/style.mobile.css" type="text/css">
<link rel="stylesheet" href="style.mobile-jq.css" type="text/css"> <link rel="stylesheet" href="style.mobile-jq.css" type="text/css">
<script src="../lib/OpenLayers.js?mobile"></script> <script src="../lib/OpenLayers.js?mobile"></script>
<script src="mobile-base.js"></script> <script src="mobile-base.js"></script>

View File

@@ -5,7 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <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="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"> <meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="style.mobile.css" type="text/css"> <link rel="stylesheet" href="../theme/default/style.mobile.css" type="text/css">
<script src="../lib/OpenLayers.js?mobile"></script> <script src="../lib/OpenLayers.js?mobile"></script>
<script src="mobile-layers.js"></script> <script src="mobile-layers.js"></script>
<style> <style>

View File

@@ -6,7 +6,7 @@
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<title>Mobile Navigation Example</title> <title>Mobile Navigation Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"> <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.mobile.css" type="text/css" /> <link rel="stylesheet" href="../theme/default/style.mobile.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css"> <link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="../lib/OpenLayers.js?mobile"></script> <script type="text/javascript" src="../lib/OpenLayers.js?mobile"></script>
<script type="text/javascript" src="mobile-navigation.js"></script> <script type="text/javascript" src="mobile-navigation.js"></script>

View File

@@ -6,7 +6,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>OpenLayers with Sencha Touch</title> <title>OpenLayers with Sencha Touch</title>
<script src="../lib/OpenLayers.js?mobile"></script> <script src="../lib/OpenLayers.js?mobile"></script>
<link rel="stylesheet" href="style.mobile.css" type="text/css"> <link rel="stylesheet" href="../theme/default/style.mobile.css" type="text/css">
<link rel="stylesheet" href="http://cdn.sencha.io/touch/1.1.0/resources/css/sencha-touch.css"> <link rel="stylesheet" href="http://cdn.sencha.io/touch/1.1.0/resources/css/sencha-touch.css">
<script src="http://cdn.sencha.io/touch/1.1.0/sencha-touch.js"></script> <script src="http://cdn.sencha.io/touch/1.1.0/sencha-touch.js"></script>
<script src="mobile-sencha.js"></script> <script src="mobile-sencha.js"></script>

View File

@@ -5,11 +5,14 @@ html, body, #map {
} }
#map { #map {
cursor: move; cursor: move;
background-color: #CCCCCC;
/* no highlighting of the map area when tapping the map on touch devices */
-webkit-tap-highlight-color: transparent;
} }
#title, #tags, #shortdesc { #title, #tags, #shortdesc {
display: none; display: none;
} }
.olTileImage { .olLayerGrid .olTileImage {
-webkit-transition: opacity 0.2s linear; -webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear;

View File

@@ -130,6 +130,17 @@ var map;
// Vector layer for the location cross and circle // Vector layer for the location cross and circle
var vector = new OpenLayers.Layer.Vector("Vector Layer"); var vector = new OpenLayers.Layer.Vector("Vector Layer");
// Defaults for the WMTS layers
var defaults = {
requestEncoding: "REST",
matrixSet: "google3857",
attribution: 'Datenquelle: Stadt Wien - <a href="http://data.wien.gv.at">data.wien.gv.at</a>'
};
// No fade transitions on Android 4, because they are buggy
if (/Android 4\.0.*Safari\/.*/.test(navigator.userAgent)) {
defaults.className = "nofade";
}
// The WMTS layers we're going to add // The WMTS layers we're going to add
var fmzk, aerial, labels; var fmzk, aerial, labels;
@@ -149,11 +160,6 @@ var map;
url: "http://maps.wien.gv.at/wmts/1.0.0/WMTSCapabilities.xml", url: "http://maps.wien.gv.at/wmts/1.0.0/WMTSCapabilities.xml",
success: function(request) { success: function(request) {
var format = new OpenLayers.Format.WMTSCapabilities(); var format = new OpenLayers.Format.WMTSCapabilities();
var defaults = {
requestEncoding: "REST",
matrixSet: "google3857",
attribution: 'Datenquelle: Stadt Wien - <a href="http://data.wien.gv.at">data.wien.gv.at</a>'
};
var doc = request.responseText, var doc = request.responseText,
caps = format.read(doc); caps = format.read(doc);
fmzk = format.createLayer(caps, OpenLayers.Util.applyDefaults( fmzk = format.createLayer(caps, OpenLayers.Util.applyDefaults(
@@ -163,7 +169,7 @@ var map;
{layer:"lb", requestEncoding:"REST", transitionEffect:"resize"}, defaults {layer:"lb", requestEncoding:"REST", transitionEffect:"resize"}, defaults
)); ));
labels = format.createLayer(caps, OpenLayers.Util.applyDefaults( labels = format.createLayer(caps, OpenLayers.Util.applyDefaults(
{layer:"beschriftung", requestEncoding:"REST", isBaseLayer: false}, {layer:"beschriftung", requestEncoding:"REST", className:"nofade", isBaseLayer: false},
defaults defaults
)); ));
map.addLayers([fmzk, aerial, labels]); map.addLayers([fmzk, aerial, labels]);
@@ -177,32 +183,28 @@ var map;
// and create layers" block above. // and create layers" block above.
/* /*
var extent = new OpenLayers.Bounds(1799448.394855, 6124949.74777, 1848250.442089, 6162571.828177); var extent = new OpenLayers.Bounds(1799448.394855, 6124949.74777, 1848250.442089, 6162571.828177);
var defaults = { defaults.tileFullExtent = extent;
requestEncoding: "REST",
matrixSet: "google3857",
tileFullExtent: extent,
attribution: 'Datenquelle: Stadt Wien - <a href="http://data.wien.gv.at">data.wien.gv.at</a>'
};
fmzk = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({ fmzk = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({
url: "http://www.wien.gv.at/wmts/fmzk/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg", url: "http://maps.wien.gv.at/wmts/fmzk/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg",
layer: "fmzk", layer: "fmzk",
style: "pastell", style: "pastell",
transitionEffect: "resize" transitionEffect: "resize"
}, },
defaults)); defaults));
aerial = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({ aerial = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({
url: "http://www.wien.gv.at/wmts/lb/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg", url: "http://maps.wien.gv.at/wmts/lb/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg",
layer: "lb", layer: "lb",
style: "farbe", style: "farbe",
transitionEffect: "resize" transitionEffect: "resize"
}, },
defaults)); defaults));
labels = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({ labels = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({
url: "http://www.wien.gv.at/wmts/beschriftung/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png", url: "http://maps.wien.gv.at/wmts/beschriftung/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png",
layer: "beschriftung", layer: "beschriftung",
style: "normal", style: "normal",
transitionEffect: null, transitionEffect: null,
isBaseLayer: false isBaseLayer: false,
className: "nofade"
}, },
defaults)); defaults));
map.addLayers([fmzk, aerial, labels]); map.addLayers([fmzk, aerial, labels]);

View File

@@ -5,7 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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="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"> <meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="style.mobile.css" type="text/css"> <link rel="stylesheet" href="../theme/default/style.mobile.css" type="text/css">
<script src="../lib/OpenLayers.js?mobile"></script> <script src="../lib/OpenLayers.js?mobile"></script>
<script src="mobile.js"></script> <script src="mobile.js"></script>
<style> <style>

View File

@@ -73,7 +73,7 @@
// from bottom to top so as to quickly signal whether or not y-ordering is working. // from bottom to top so as to quickly signal whether or not y-ordering is working.
while (bottom.y > top.y) { while (bottom.y > top.y) {
bottom.y -= POINT_DISTANCE; bottom.y -= POINT_DISTANCE;
var lonLat = map.getLonLatFromViewPortPx(bottom); var lonLat = map.getLonLatFromPixel(bottom);
orderingFeatures.push( orderingFeatures.push(
new OpenLayers.Feature.Vector( new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat) new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
@@ -89,7 +89,7 @@
var indexFeatures = []; var indexFeatures = [];
var useFirst = true; var useFirst = true;
while (left.x <= right.x) { while (left.x <= right.x) {
var lonLat = map.getLonLatFromViewPortPx(left); var lonLat = map.getLonLatFromPixel(left);
var point = new OpenLayers.Feature.Vector( var point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat) new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
); );
@@ -147,8 +147,8 @@
// and succomb to y-ordering. // and succomb to y-ordering.
var orderingFeatures = []; var orderingFeatures = [];
while (bottom.y > top.y && left.x < right.x) { while (bottom.y > top.y && left.x < right.x) {
var bottomLonLat = map.getLonLatFromViewPortPx(bottom); var bottomLonLat = map.getLonLatFromPixel(bottom);
var leftLonLat = map.getLonLatFromViewPortPx(left); var leftLonLat = map.getLonLatFromPixel(left);
orderingFeatures.push( orderingFeatures.push(
new OpenLayers.Feature.Vector( new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(leftLonLat.lon, bottomLonLat.lat), new OpenLayers.Geometry.Point(leftLonLat.lon, bottomLonLat.lat),

View File

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

View File

@@ -80,7 +80,9 @@
// create an overview map control with the default options // create an overview map control with the default options
var overview1 = new OpenLayers.Control.OverviewMap({ var overview1 = new OpenLayers.Control.OverviewMap({
maximized: true maximized: true,
maximizeTitle: 'Show the overview map',
minimizeTitle: 'Hide the overview map'
}); });
map1.addControl(overview1); map1.addControl(overview1);

View File

@@ -15,6 +15,7 @@
<script src="../lib/OpenLayers.js"></script> <script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var map, drawControls; var map, drawControls;
OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2'; OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
function init(){ function init(){
map = new OpenLayers.Map('map'); map = new OpenLayers.Map('map');
@@ -33,10 +34,10 @@
}); });
vectors.events.on({ vectors.events.on({
'featureselected': function(feature) { 'featureselected': function(feature) {
$('counter').innerHTML = this.selectedFeatures.length; document.getElementById('counter').innerHTML = this.selectedFeatures.length;
}, },
'featureunselected': function(feature) { 'featureunselected': function(feature) {
$('counter').innerHTML = this.selectedFeatures.length; document.getElementById('counter').innerHTML = this.selectedFeatures.length;
} }
}); });

View File

@@ -41,7 +41,6 @@
initUI(); initUI();
} }
var map, draw, modify, snap, split, vectors; var map, draw, modify, snap, split, vectors;
function initMap() { function initMap() {
@@ -185,15 +184,15 @@
*/ */
function initUI() { function initUI() {
// add behavior to snap elements // add behavior to snap elements
var snapCheck = $("snap_toggle"); var snapCheck = document.getElementById("snap_toggle");
snapCheck.checked = true; snapCheck.checked = true;
snapCheck.onclick = function() { snapCheck.onclick = function() {
if(snapCheck.checked) { if(snapCheck.checked) {
snap.activate(); snap.activate();
$("snap_options").style.display = "block"; document.getElementById("snap_options").style.display = "block";
} else { } else {
snap.deactivate(); snap.deactivate();
$("snap_options").style.display = "none"; document.getElementById("snap_options").style.display = "none";
} }
}; };
var target, type, tog, tol; var target, type, tog, tol;
@@ -201,12 +200,12 @@
var target = snap.targets[0]; var target = snap.targets[0];
for(var j=0; j<types.length; ++j) { for(var j=0; j<types.length; ++j) {
type = types[j]; type = types[j];
tog = $("target_" + type); tog = document.getElementById("target_" + type);
tog.checked = target[type]; tog.checked = target[type];
tog.onclick = (function(tog, type, target) { tog.onclick = (function(tog, type, target) {
return function() {target[type] = tog.checked;} return function() {target[type] = tog.checked;}
})(tog, type, target); })(tog, type, target);
tol = $("target_" + type + "Tolerance"); tol = document.getElementById("target_" + type + "Tolerance");
tol.value = target[type + "Tolerance"]; tol.value = target[type + "Tolerance"];
tol.onchange = (function(tol, type, target) { tol.onchange = (function(tol, type, target) {
return function() { return function() {
@@ -216,24 +215,24 @@
} }
// add behavior to split elements // add behavior to split elements
var splitCheck = $("split_toggle"); var splitCheck = document.getElementById("split_toggle");
splitCheck.checked = true; splitCheck.checked = true;
splitCheck.onclick = function() { splitCheck.onclick = function() {
if(splitCheck.checked) { if(splitCheck.checked) {
split.activate(); split.activate();
$("split_options").style.display = "block"; document.getElementById("split_options").style.display = "block";
} else { } else {
split.deactivate(); split.deactivate();
$("split_options").style.display = "none"; document.getElementById("split_options").style.display = "none";
} }
}; };
var edgeCheck = $("edge_toggle"); var edgeCheck = document.getElementById("edge_toggle");
edgeCheck.checked = split.edge; edgeCheck.checked = split.edge;
edgeCheck.onclick = function() { edgeCheck.onclick = function() {
split.edge = edgeCheck.checked; split.edge = edgeCheck.checked;
}; };
$("clear").onclick = function() { document.getElementById("clear").onclick = function() {
modify.deactivate(); modify.deactivate();
vectors.destroyFeatures(); vectors.destroyFeatures();
}; };

View File

@@ -194,7 +194,7 @@
* property values. * property values.
*/ */
function initUI() { function initUI() {
var check = $("snapping"); var check = document.getElementById("snapping");
check.checked = true; check.checked = true;
check.onclick = function() { check.onclick = function() {
if(check.checked) { if(check.checked) {
@@ -204,7 +204,7 @@
} }
}; };
var sel = $("editable"); var sel = document.getElementById("editable");
sel.value = "poly"; sel.value = "poly";
sel.onchange = function() { sel.onchange = function() {
updateEditable(sel.value); updateEditable(sel.value);
@@ -216,12 +216,12 @@
target = snap.targets[i]; target = snap.targets[i];
for(var j=0; j<types.length; ++j) { for(var j=0; j<types.length; ++j) {
type = types[j]; type = types[j];
tog = $(i + "_" + type); tog = document.getElementById(i + "_" + type);
tog.checked = target[type]; tog.checked = target[type];
tog.onclick = (function(tog, type, target) { tog.onclick = (function(tog, type, target) {
return function() {target[type] = tog.checked;} return function() {target[type] = tog.checked;}
})(tog, type, target); })(tog, type, target);
tol = $(i + "_" + type + "Tolerance"); tol = document.getElementById(i + "_" + type + "Tolerance");
tol.value = target[type + "Tolerance"]; tol.value = target[type + "Tolerance"];
tol.onchange = (function(tol, type, target) { tol.onchange = (function(tol, type, target) {
return function() { return function() {

View File

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

View File

@@ -95,14 +95,14 @@ var map, vectorlayer, features, stylemap, select;
} else { } else {
info += '&nbsp;&nbsp;Single feature of clazz = ' + feature.attributes.clazz; info += '&nbsp;&nbsp;Single feature of clazz = ' + feature.attributes.clazz;
} }
$('info').innerHTML = info; document.getElementById('info').innerHTML = info;
}; };
// The function that gets called on feature selection. Shows information // The function that gets called on feature selection. Shows information
// about the number of "points" on the map. // about the number of "points" on the map.
var updateGeneralInformation = function() { var updateGeneralInformation = function() {
var info = 'Currently ' + vectorlayer.features.length + ' points are shown on the map.'; var info = 'Currently ' + vectorlayer.features.length + ' points are shown on the map.';
$('generalinfo').innerHTML = info; document.getElementById('generalinfo').innerHTML = info;
}; };
// instanciate the map // instanciate the map

View File

@@ -18,7 +18,6 @@
</style> </style>
<script src="../lib/OpenLayers.js"></script> <script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"> <script type="text/javascript">
// create a semi-random grid of features to be clustered // create a semi-random grid of features to be clustered
var dx = 3; var dx = 3;
var dy = 3; var dy = 3;
@@ -90,24 +89,24 @@
map.setCenter(new OpenLayers.LonLat(0, 0), 2); map.setCenter(new OpenLayers.LonLat(0, 0), 2);
reset(); reset();
$("reset").onclick = reset; document.getElementById("reset").onclick = reset;
} }
function reset() { function reset() {
var distance = parseInt($("distance").value); var distance = parseInt(document.getElementById("distance").value);
var threshold = parseInt($("threshold").value); var threshold = parseInt(document.getElementById("threshold").value);
strategy.distance = distance || strategy.distance; strategy.distance = distance || strategy.distance;
strategy.threshold = threshold || strategy.threshold; strategy.threshold = threshold || strategy.threshold;
$("distance").value = strategy.distance; document.getElementById("distance").value = strategy.distance;
$("threshold").value = strategy.threshold || "null"; document.getElementById("threshold").value = strategy.threshold || "null";
clusters.removeFeatures(clusters.features); clusters.removeFeatures(clusters.features);
clusters.addFeatures(features); clusters.addFeatures(features);
} }
function display(event) { function display(event) {
var f = event.feature; var f = event.feature;
var el = $("output"); var el = document.getElementById("output");
if(f.cluster) { if(f.cluster) {
el.innerHTML = "cluster of " + f.attributes.count; el.innerHTML = "cluster of " + f.attributes.count;
} else { } else {

View File

@@ -69,6 +69,7 @@
<script src="Jugl.js"></script> <script src="Jugl.js"></script>
<script src="animator.js"></script> <script src="animator.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var map, template; var map, template;
/** /**
@@ -171,21 +172,21 @@
function display(event) { function display(event) {
// clear previous photo list and create new one // clear previous photo list and create new one
$("photos").innerHTML = ""; document.getElementById("photos").innerHTML = "";
var node = template.process({ var node = template.process({
context: {features: event.feature.cluster}, context: {features: event.feature.cluster},
clone: true, clone: true,
parent: $("photos") parent: document.getElementById("photos")
}); });
// set up forward/rewind // set up forward/rewind
var forward = Animator.apply($("list"), ["start", "end"], {duration: 1500}); var forward = Animator.apply(document.getElementById("list"), ["start", "end"], {duration: 1500});
$("scroll-end").onmouseover = function() {forward.seekTo(1)}; document.getElementById("scroll-end").onmouseover = function() {forward.seekTo(1)};
$("scroll-end").onmouseout = function() {forward.seekTo(forward.state)}; document.getElementById("scroll-end").onmouseout = function() {forward.seekTo(forward.state)};
$("scroll-start").onmouseover = function() {forward.seekTo(0)}; document.getElementById("scroll-start").onmouseover = function() {forward.seekTo(0)};
$("scroll-start").onmouseout = function() {forward.seekTo(forward.state)}; document.getElementById("scroll-start").onmouseout = function() {forward.seekTo(forward.state)};
// set up photo zoom // set up photo zoom
for(var i=0; i<event.feature.cluster.length; ++i) { for(var i=0; i<event.feature.cluster.length; ++i) {
listen($("link-" + i), Animator.apply($("photo-" + i), ["thumb", "big"])); listen(document.getElementById("link-" + i), Animator.apply(document.getElementById("photo-" + i), ["thumb", "big"]));
} }
} }

View File

@@ -11,7 +11,7 @@
<script type="text/javascript"> <script type="text/javascript">
var map, layer; var map, layer;
function init(){ function init(){
map = new OpenLayers.Map( $('map'), { map = new OpenLayers.Map( 'map', {
resolutions: [0.087890625, 0.0439453125, 0.02197265625, 0.010986328125] resolutions: [0.087890625, 0.0439453125, 0.02197265625, 0.010986328125]
}); });
layer = new OpenLayers.Layer.TileCache("TileCache Layer", layer = new OpenLayers.Layer.TileCache("TileCache Layer",

View File

@@ -1,4 +1,5 @@
var map, vector; var map, vector;
function init(){ function init(){
map = new OpenLayers.Map('map', { map = new OpenLayers.Map('map', {
projection: 'EPSG:31467', projection: 'EPSG:31467',
@@ -7,16 +8,16 @@ function init(){
numZoomLevels: 1, numZoomLevels: 1,
controls: [ controls: [
new OpenLayers.Control.Attribution({ new OpenLayers.Control.Attribution({
div: $('attribution') div: document.getElementById('attribution')
}), }),
new OpenLayers.Control.MousePosition({ new OpenLayers.Control.MousePosition({
div: $('mouse-position-31467'), div: document.getElementById('mouse-position-31467'),
prefix: 'Coordinates: ', prefix: 'Coordinates: ',
suffix: ' (in <a href="http://spatialreference.org/ref/epsg/' suffix: ' (in <a href="http://spatialreference.org/ref/epsg/'
+ '31467/">EPSG:31467</a>)' + '31467/">EPSG:31467</a>)'
}), }),
new OpenLayers.Control.MousePosition({ new OpenLayers.Control.MousePosition({
div: $('mouse-position-4326'), div: document.getElementById('mouse-position-4326'),
displayProjection: new OpenLayers.Projection('EPSG:4326'), displayProjection: new OpenLayers.Projection('EPSG:4326'),
prefix: 'Coordinates: ', prefix: 'Coordinates: ',
suffix: ' (in <a href="http://spatialreference.org/ref/epsg/' suffix: ' (in <a href="http://spatialreference.org/ref/epsg/'
@@ -59,7 +60,7 @@ function addVector(x, y, btn){
status += '<br /><code class="emph"> ' status += '<br /><code class="emph"> '
+ geometry.toString() + '</code>.'; + geometry.toString() + '</code>.';
$('status').innerHTML = status; document.getElementById('status').innerHTML = status;
var feature = new OpenLayers.Feature.Vector(geometry, {}, { var feature = new OpenLayers.Feature.Vector(geometry, {}, {
strokeColor: '#333333', strokeColor: '#333333',
@@ -110,7 +111,7 @@ function addOutline(btn) {
transformedFeature = new OpenLayers.Feature.Vector(geometry, {}, style); transformedFeature = new OpenLayers.Feature.Vector(geometry, {}, style);
vector.addFeatures([transformedFeature]); vector.addFeatures([transformedFeature]);
$('status').innerHTML = 'Transformed polygon'; document.getElementById('status').innerHTML = 'Transformed polygon';
btn.disabled = true; btn.disabled = true;
} }
@@ -124,8 +125,8 @@ function clearVectors(){
'btnGermany' 'btnGermany'
]; ];
for (var i = 0, len = ids.length; i < len; i++) { for (var i = 0, len = ids.length; i < len; i++) {
var elem = $(ids[i]); var elem = document.getElementById(ids[i]);
elem.disabled = false; elem.disabled = false;
} }
$('status').innerHTML = ''; document.getElementById('status').innerHTML = '';
} }

View File

@@ -414,4 +414,4 @@
/** /**
* Constant: VERSION_NUMBER * Constant: VERSION_NUMBER
*/ */
OpenLayers.VERSION_NUMBER="Release 2.12-rc3"; OpenLayers.VERSION_NUMBER="Release 2.12-rc7";

View File

@@ -261,8 +261,11 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
* deltaZ - {Integer} * deltaZ - {Integer}
*/ */
wheelChange: function(evt, deltaZ) { wheelChange: function(evt, deltaZ) {
if (!this.map.fractionalZoom) {
deltaZ = Math.round(deltaZ);
}
var currentZoom = this.map.getZoom(); var currentZoom = this.map.getZoom();
var newZoom = this.map.getZoom() + Math.round(deltaZ); var newZoom = this.map.getZoom() + deltaZ;
newZoom = Math.max(newZoom, 0); newZoom = Math.max(newZoom, 0);
newZoom = Math.min(newZoom, this.map.getNumZoomLevels()); newZoom = Math.min(newZoom, this.map.getNumZoomLevels());
if (newZoom === currentZoom) { if (newZoom === currentZoom) {

View File

@@ -127,6 +127,20 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
*/ */
maximized: false, maximized: false,
/**
* APIProperty: maximizeTitle
* {String} This property is used for showing a tooltip over the
* maximize div. Defaults to "" (no title).
*/
maximizeTitle: "",
/**
* APIProperty: minimizeTitle
* {String} This property is used for showing a tooltip over the
* minimize div. Defaults to "" (no title).
*/
minimizeTitle: "",
/** /**
* Constructor: OpenLayers.Control.OverviewMap * Constructor: OpenLayers.Control.OverviewMap
* Create a new overview map * Create a new overview map
@@ -247,6 +261,9 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
'absolute'); 'absolute');
this.maximizeDiv.style.display = 'none'; this.maximizeDiv.style.display = 'none';
this.maximizeDiv.className = this.displayClass + 'MaximizeButton olButton'; this.maximizeDiv.className = this.displayClass + 'MaximizeButton olButton';
if (this.maximizeTitle) {
this.maximizeDiv.title = this.maximizeTitle;
}
this.div.appendChild(this.maximizeDiv); this.div.appendChild(this.maximizeDiv);
// minimize button div // minimize button div
@@ -259,6 +276,9 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
'absolute'); 'absolute');
this.minimizeDiv.style.display = 'none'; this.minimizeDiv.style.display = 'none';
this.minimizeDiv.className = this.displayClass + 'MinimizeButton olButton'; this.minimizeDiv.className = this.displayClass + 'MinimizeButton olButton';
if (this.minimizeTitle) {
this.minimizeDiv.title = this.minimizeTitle;
}
this.div.appendChild(this.minimizeDiv); this.div.appendChild(this.minimizeDiv);
this.minimizeControl(); this.minimizeControl();
} else { } else {

View File

@@ -99,6 +99,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
this.map.events.un({ this.map.events.un({
"changebaselayer": this.redraw, "changebaselayer": this.redraw,
"updatesize": this.redraw,
scope: this scope: this
}); });
@@ -116,7 +117,11 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
*/ */
setMap: function(map) { setMap: function(map) {
OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments); OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);
this.map.events.register("changebaselayer", this, this.redraw); this.map.events.on({
"changebaselayer": this.redraw,
"updatesize": this.redraw,
scope: this
});
}, },
/** /**
@@ -189,6 +194,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
_addZoomBar:function(centered) { _addZoomBar:function(centered) {
var imgLocation = OpenLayers.Util.getImageLocation("slider.png"); var imgLocation = OpenLayers.Util.getImageLocation("slider.png");
var id = this.id + "_" + this.map.id; var id = this.id + "_" + this.map.id;
var minZoom = this.map.getMinZoom();
var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom(); var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();
var slider = OpenLayers.Util.createAlphaImageDiv(id, var slider = OpenLayers.Util.createAlphaImageDiv(id,
centered.add(-1, zoomsToEnd * this.zoomStopHeight), centered.add(-1, zoomsToEnd * this.zoomStopHeight),
@@ -211,7 +217,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
var sz = { var sz = {
w: this.zoomStopWidth, w: this.zoomStopWidth,
h: this.zoomStopHeight * this.map.getNumZoomLevels() h: this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom)
}; };
var imgLocation = OpenLayers.Util.getImageLocation("zoombar.png"); var imgLocation = OpenLayers.Util.getImageLocation("zoombar.png");
var div = null; var div = null;
@@ -242,7 +248,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
this.map.events.register("zoomend", this, this.moveZoomBar); this.map.events.register("zoomend", this, this.moveZoomBar);
centered = centered.add(0, centered = centered.add(0,
this.zoomStopHeight * this.map.getNumZoomLevels()); this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom));
return centered; return centered;
}, },

View File

@@ -300,14 +300,17 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
*/ */
unselectAll: function(options) { unselectAll: function(options) {
// we'll want an option to supress notification here // we'll want an option to supress notification here
var layers = this.layers || [this.layer]; var layers = this.layers || [this.layer],
var layer, feature; layer, feature, l, numExcept;
for(var l=0; l<layers.length; ++l) { for(l=0; l<layers.length; ++l) {
layer = layers[l]; layer = layers[l];
for(var i=layer.selectedFeatures.length-1; i>=0; --i) { numExcept = 0;
feature = layer.selectedFeatures[i]; while(layer.selectedFeatures.length > numExcept) {
feature = layer.selectedFeatures[numExcept];
if(!options || options.except != feature) { if(!options || options.except != feature) {
this.unselect(feature); this.unselect(feature);
} else {
++numExcept;
} }
} }
} }

View File

@@ -240,7 +240,7 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
var deactivated = OpenLayers.Control.prototype.deactivate.call(this); var deactivated = OpenLayers.Control.prototype.deactivate.call(this);
if(deactivated) { if(deactivated) {
if(this.source && this.source.events) { if(this.source && this.source.events) {
this.layer.events.un({ this.source.events.un({
sketchcomplete: this.onSketchComplete, sketchcomplete: this.onSketchComplete,
afterfeaturemodified: this.afterFeatureModified, afterfeaturemodified: this.afterFeatureModified,
scope: this scope: this

View File

@@ -41,10 +41,18 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
/** /**
* APIProperty: alwaysZoom * APIProperty: alwaysZoom
* {Boolean} Always zoom in/out, when box drawed * {Boolean} Always zoom in/out when box drawn, even if the zoom level does
* not change.
*/ */
alwaysZoom: false, alwaysZoom: false,
/**
* APIProperty: zoomOnClick
* {Boolean} Should we zoom when no box was dragged, i.e. the user only
* clicked? Default is true.
*/
zoomOnClick: true,
/** /**
* Method: draw * Method: draw
*/ */
@@ -93,7 +101,7 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){ if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){
this.map.zoomTo(lastZoom + (this.out ? -1 : 1)); this.map.zoomTo(lastZoom + (this.out ? -1 : 1));
} }
} else { // it's a pixel } else if (this.zoomOnClick) { // it's a pixel
if (!this.out) { if (!this.out) {
this.map.setCenter(this.map.getLonLatFromPixel(position), this.map.setCenter(this.map.getLonLatFromPixel(position),
this.map.getZoom() + 1); this.map.getZoom() + 1);

View File

@@ -285,11 +285,9 @@ OpenLayers.Event = {
if (elementObservers) { if (elementObservers) {
for(var i = elementObservers.length-1; i >= 0; i--) { for(var i = elementObservers.length-1; i >= 0; i--) {
var entry = elementObservers[i]; var entry = elementObservers[i];
var args = new Array(entry.element, OpenLayers.Event.stopObserving.apply(this, [
entry.name, entry.element, entry.name, entry.observer, entry.useCapture
entry.observer, ]);
entry.useCapture);
var removed = OpenLayers.Event.stopObserving.apply(this, args);
} }
} }
}, },
@@ -824,7 +822,7 @@ OpenLayers.Events = OpenLayers.Class({
* *
* Parameters: * Parameters:
* type - {String} * type - {String}
* evt - {Event} * evt - {Event || Object} will be passed to the listeners.
* *
* Returns: * Returns:
* {Boolean} The last listener return. If a listener returns false, the * {Boolean} The last listener return. If a listener returns false, the

View File

@@ -13,7 +13,7 @@
/** /**
* Class: OpenLayers.Format.ArcXML * Class: OpenLayers.Format.ArcXML
* Read/Wite ArcXML. Create a new instance with the <OpenLayers.Format.ArcXML> * Read/Write ArcXML. Create a new instance with the <OpenLayers.Format.ArcXML>
* constructor. * constructor.
* *
* Inherits from: * Inherits from:

View File

@@ -9,7 +9,7 @@
/** /**
* Class: OpenLayers.Format.ArcXML.Features * Class: OpenLayers.Format.ArcXML.Features
* Read/Wite ArcXML features. Create a new instance with the * Read/Write ArcXML features. Create a new instance with the
* <OpenLayers.Format.ArcXML.Features> constructor. * <OpenLayers.Format.ArcXML.Features> constructor.
* *
* Inherits from: * Inherits from:

View File

@@ -12,7 +12,7 @@
/** /**
* Class: OpenLayers.Format.Filter * Class: OpenLayers.Format.Filter
* Read/Wite ogc:Filter. Create a new instance with the <OpenLayers.Format.Filter> * Read/Write ogc:Filter. Create a new instance with the <OpenLayers.Format.Filter>
* constructor. * constructor.
* *
* Inherits from: * Inherits from:

View File

@@ -16,7 +16,7 @@
/** /**
* Class: OpenLayers.Format.GML * Class: OpenLayers.Format.GML
* Read/Wite GML. Create a new instance with the <OpenLayers.Format.GML> * Read/Write GML. Create a new instance with the <OpenLayers.Format.GML>
* constructor. Supports the GML simple features profile. * constructor. Supports the GML simple features profile.
* *
* Inherits from: * Inherits from:

View File

@@ -241,6 +241,9 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
*/ */
readers: { readers: {
"gml": { "gml": {
"_inherit": function(node, obj, container) {
// To be implemented by version specific parsers
},
"featureMember": function(node, obj) { "featureMember": function(node, obj) {
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
}, },
@@ -309,6 +312,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
}, },
"MultiPoint": function(node, container) { "MultiPoint": function(node, container) {
var obj = {components: []}; var obj = {components: []};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
container.components = [ container.components = [
new OpenLayers.Geometry.MultiPoint(obj.components) new OpenLayers.Geometry.MultiPoint(obj.components)
@@ -319,6 +323,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
}, },
"LineString": function(node, container) { "LineString": function(node, container) {
var obj = {}; var obj = {};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
if(!container.components) { if(!container.components) {
container.components = []; container.components = [];
@@ -329,6 +334,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
}, },
"MultiLineString": function(node, container) { "MultiLineString": function(node, container) {
var obj = {components: []}; var obj = {components: []};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
container.components = [ container.components = [
new OpenLayers.Geometry.MultiLineString(obj.components) new OpenLayers.Geometry.MultiLineString(obj.components)
@@ -339,6 +345,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
}, },
"Polygon": function(node, container) { "Polygon": function(node, container) {
var obj = {outer: null, inner: []}; var obj = {outer: null, inner: []};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
obj.inner.unshift(obj.outer); obj.inner.unshift(obj.outer);
if(!container.components) { if(!container.components) {
@@ -350,6 +357,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
}, },
"LinearRing": function(node, obj) { "LinearRing": function(node, obj) {
var container = {}; var container = {};
this.readers.gml._inherit.apply(this, [node, container]);
this.readChildNodes(node, container); this.readChildNodes(node, container);
obj.components = [new OpenLayers.Geometry.LinearRing( obj.components = [new OpenLayers.Geometry.LinearRing(
container.points container.points
@@ -357,6 +365,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
}, },
"MultiPolygon": function(node, container) { "MultiPolygon": function(node, container) {
var obj = {components: []}; var obj = {components: []};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
container.components = [ container.components = [
new OpenLayers.Geometry.MultiPolygon(obj.components) new OpenLayers.Geometry.MultiPolygon(obj.components)
@@ -367,6 +376,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
}, },
"GeometryCollection": function(node, container) { "GeometryCollection": function(node, container) {
var obj = {components: []}; var obj = {components: []};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
container.components = [ container.components = [
new OpenLayers.Geometry.Collection(obj.components) new OpenLayers.Geometry.Collection(obj.components)

View File

@@ -90,11 +90,20 @@ OpenLayers.Format.GML.v3 = OpenLayers.Class(OpenLayers.Format.GML.Base, {
*/ */
readers: { readers: {
"gml": OpenLayers.Util.applyDefaults({ "gml": OpenLayers.Util.applyDefaults({
"_inherit": function(node, obj, container) {
// SRSReferenceGroup attributes
var dim = parseInt(node.getAttribute("srsDimension"), 10) ||
(container && container.srsDimension);
if (dim) {
obj.srsDimension = dim;
}
},
"featureMembers": function(node, obj) { "featureMembers": function(node, obj) {
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
}, },
"Curve": function(node, container) { "Curve": function(node, container) {
var obj = {points: []}; var obj = {points: []};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
if(!container.components) { if(!container.components) {
container.components = []; container.components = [];
@@ -135,7 +144,9 @@ OpenLayers.Format.GML.v3 = OpenLayers.Class(OpenLayers.Format.GML.Base, {
this.regExes.trimSpace, "" this.regExes.trimSpace, ""
); );
var coords = str.split(this.regExes.splitSpace); var coords = str.split(this.regExes.splitSpace);
var dim = parseInt(node.getAttribute("dimension")) || 2; // The "dimension" attribute is from the GML 3.0.1 spec.
var dim = obj.srsDimension ||
parseInt(node.getAttribute("srsDimension") || node.getAttribute("dimension"), 10) || 2;
var j, x, y, z; var j, x, y, z;
var numPoints = coords.length / dim; var numPoints = coords.length / dim;
var points = new Array(numPoints); var points = new Array(numPoints);
@@ -172,6 +183,7 @@ OpenLayers.Format.GML.v3 = OpenLayers.Class(OpenLayers.Format.GML.Base, {
}, },
"MultiCurve": function(node, container) { "MultiCurve": function(node, container) {
var obj = {components: []}; var obj = {components: []};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
if(obj.components.length > 0) { if(obj.components.length > 0) {
container.components = [ container.components = [
@@ -184,6 +196,7 @@ OpenLayers.Format.GML.v3 = OpenLayers.Class(OpenLayers.Format.GML.Base, {
}, },
"MultiSurface": function(node, container) { "MultiSurface": function(node, container) {
var obj = {components: []}; var obj = {components: []};
this.readers.gml._inherit.apply(this, [node, obj, container]);
this.readChildNodes(node, obj); this.readChildNodes(node, obj);
if(obj.components.length > 0) { if(obj.components.length > 0) {
container.components = [ container.components = [

View File

@@ -311,8 +311,7 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
/** /**
* Method: parseStyles * Method: parseStyles
* Looks for <Style> nodes in the data and parses them * Parses <Style> nodes
* Also parses <StyleMap> nodes, but only uses the 'normal' key
* *
* Parameters: * Parameters:
* nodes - {Array} of {DOMElement} data to read/parse. * nodes - {Array} of {DOMElement} data to read/parse.
@@ -558,8 +557,7 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
/** /**
* Method: parseStyleMaps * Method: parseStyleMaps
* Looks for <Style> nodes in the data and parses them * Parses <StyleMap> nodes, but only uses the 'normal' key
* Also parses <StyleMap> nodes, but only uses the 'normal' key
* *
* Parameters: * Parameters:
* nodes - {Array} of {DOMElement} data to read/parse. * nodes - {Array} of {DOMElement} data to read/parse.
@@ -1212,8 +1210,8 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
createPlacemarkXML: function(feature) { createPlacemarkXML: function(feature) {
// Placemark name // Placemark name
var placemarkName = this.createElementNS(this.kmlns, "name"); var placemarkName = this.createElementNS(this.kmlns, "name");
var name = feature.style && feature.style.label ? feature.style.label : var label = (feature.style && feature.style.label) ? feature.style.label : feature.id;
feature.attributes.name || feature.id; var name = feature.attributes.name || label;
placemarkName.appendChild(this.createTextNode(name)); placemarkName.appendChild(this.createTextNode(name));
// Placemark description // Placemark description

View File

@@ -15,7 +15,7 @@
/** /**
* Class: OpenLayers.Format.SLD * Class: OpenLayers.Format.SLD
* Read/Wite SLD. Create a new instance with the <OpenLayers.Format.SLD> * Read/Write SLD. Create a new instance with the <OpenLayers.Format.SLD>
* constructor. * constructor.
* *
* Inherits from: * Inherits from:

View File

@@ -5,6 +5,7 @@
/** /**
* @requires OpenLayers/Format/XML.js * @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/OGCExceptionReport.js
*/ */
/** /**
@@ -187,8 +188,13 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
data = data.documentElement; data = data.documentElement;
} }
var schema = {}; var schema = {};
if (data.nodeName.split(":").pop() === 'ExceptionReport') {
// an exception must have occurred, so parse it
var parser = new OpenLayers.Format.OGCExceptionReport();
schema.error = parser.read(data);
} else {
this.readNode(data, schema); this.readNode(data, schema);
}
return schema; return schema;
}, },

View File

@@ -6,6 +6,8 @@
/** /**
* @requires OpenLayers/Format/XML.js * @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/WFST.js * @requires OpenLayers/Format/WFST.js
* @requires OpenLayers/Filter/Spatial.js
* @requires OpenLayers/Filter/FeatureId.js
*/ */
/** /**

View File

@@ -127,6 +127,10 @@ OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(
output.complexOutput = {}; output.complexOutput = {};
this.readChildNodes(node, output.complexOutput); this.readChildNodes(node, output.complexOutput);
}, },
"LiteralOutput": function(node, output) {
output.literalOutput = {};
this.readChildNodes(node, output.literalOutput);
},
"Input": function(node, dataInputs) { "Input": function(node, dataInputs) {
var input = { var input = {
maxOccurs: parseInt(node.getAttribute("maxOccurs")), maxOccurs: parseInt(node.getAttribute("maxOccurs")),

View File

@@ -93,6 +93,28 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, {
return OpenLayers.Format.XML.prototype.write.apply(this, [node]); return OpenLayers.Format.XML.prototype.write.apply(this, [node]);
}, },
/**
* APIMethod: read
* Parse a WPS Execute and return an object with its information.
*
* Parameters:
* data - {String} or {DOMElement} data to read/parse.
*
* Returns:
* {Object}
*/
read: function(data) {
if(typeof data == "string") {
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
}
if(data && data.nodeType == 9) {
data = data.documentElement;
}
var info = {};
this.readNode(data, info);
return info;
},
/** /**
* Property: writers * Property: writers
* As a compliment to the readers property, this structure contains public * As a compliment to the readers property, this structure contains public
@@ -131,15 +153,20 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, {
status: responseDocument.status status: responseDocument.status
} }
}); });
if (responseDocument.output) { if (responseDocument.outputs) {
this.writeNode("wps:Output", responseDocument.output, node); for (var i = 0, len = responseDocument.outputs.length; i < len; i++) {
this.writeNode("wps:Output", responseDocument.outputs[i], node);
}
} }
return node; return node;
}, },
"Output": function(output) { "Output": function(output) {
var node = this.createElementNSPlus("wps:Output", { var node = this.createElementNSPlus("wps:Output", {
attributes: { attributes: {
asReference: output.asReference asReference: output.asReference,
mimeType: output.mimeType,
encoding: output.encoding,
schema: output.schema
} }
}); });
this.writeNode("ows:Identifier", output.identifier, node); this.writeNode("ows:Identifier", output.identifier, node);
@@ -150,7 +177,9 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, {
"RawDataOutput": function(rawDataOutput) { "RawDataOutput": function(rawDataOutput) {
var node = this.createElementNSPlus("wps:RawDataOutput", { var node = this.createElementNSPlus("wps:RawDataOutput", {
attributes: { attributes: {
mimeType: rawDataOutput.mimeType mimeType: rawDataOutput.mimeType,
encoding: rawDataOutput.encoding,
schema: rawDataOutput.schema
} }
}); });
this.writeNode("ows:Identifier", rawDataOutput.identifier, node); this.writeNode("ows:Identifier", rawDataOutput.identifier, node);
@@ -186,6 +215,8 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, {
this.writeNode("wps:LiteralData", data.literalData, node); this.writeNode("wps:LiteralData", data.literalData, node);
} else if (data.complexData) { } else if (data.complexData) {
this.writeNode("wps:ComplexData", data.complexData, node); this.writeNode("wps:ComplexData", data.complexData, node);
} else if (data.boundingBoxData) {
this.writeNode("ows:BoundingBox", data.boundingBoxData, node);
} }
return node; return node;
}, },
@@ -257,6 +288,107 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, {
"ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows
}, },
/**
* 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.
*/
readers: {
"wps": {
"ExecuteResponse": function(node, obj) {
obj.executeResponse = {
lang: node.getAttribute("lang"),
statusLocation: node.getAttribute("statusLocation"),
serviceInstance: node.getAttribute("serviceInstance"),
service: node.getAttribute("service")
};
this.readChildNodes(node, obj.executeResponse);
},
"Process":function(node,obj) {
obj.process = {};
this.readChildNodes(node, obj.process);
},
"Status":function(node,obj) {
obj.status = {
creationTime: node.getAttribute("creationTime")
};
this.readChildNodes(node, obj.status);
},
"ProcessSucceeded": function(node,obj) {
obj.processSucceeded = true;
},
"ProcessOutputs": function(node, processDescription) {
processDescription.processOutputs = [];
this.readChildNodes(node, processDescription.processOutputs);
},
"Output": function(node, processOutputs) {
var output = {};
this.readChildNodes(node, output);
processOutputs.push(output);
},
"Reference": function(node, output) {
output.reference = {
href: node.getAttribute("href"),
mimeType: node.getAttribute("mimeType"),
encoding: node.getAttribute("encoding"),
schema: node.getAttribute("schema")
};
},
"Data": function(node, output) {
output.data = {};
this.readChildNodes(node, output);
},
"LiteralData": function(node, output) {
output.literalData = {
dataType: node.getAttribute("dataType"),
uom: node.getAttribute("uom"),
value: this.getChildValue(node)
};
},
"ComplexData": function(node, output) {
output.complexData = {
mimeType: node.getAttribute("mimeType"),
schema: node.getAttribute("schema"),
encoding: node.getAttribute("encoding"),
value: ""
};
// try to get *some* value, ignore the empty text values
if (this.isSimpleContent(node)) {
var child;
for(child=node.firstChild; child; child=child.nextSibling) {
switch(child.nodeType) {
case 3: // text node
case 4: // cdata section
output.complexData.value += child.nodeValue;
}
}
}
else {
for(child=node.firstChild; child; child=child.nextSibling) {
if (child.nodeType == 1) {
output.complexData.value = child;
}
}
}
},
"BoundingBox": function(node, output) {
output.boundingBoxData = {
dimensions: node.getAttribute("dimensions"),
crs: node.getAttribute("crs")
};
this.readChildNodes(node, output.boundingBoxData);
}
},
// TODO: we should add Exception parsing here
"ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"]
},
CLASS_NAME: "OpenLayers.Format.WPSExecute" CLASS_NAME: "OpenLayers.Format.WPSExecute"
}); });

View File

@@ -9,7 +9,7 @@
/** /**
* Class: OpenLayers.Format.XLS * Class: OpenLayers.Format.XLS
* Read/Wite XLS (OpenLS). Create a new instance with the <OpenLayers.Format.XLS> * Read/Write XLS (OpenLS). Create a new instance with the <OpenLayers.Format.XLS>
* constructor. Currently only implemented for Location Utility Services, more * constructor. Currently only implemented for Location Utility Services, more
* specifically only for Geocoding. No support for Reverse Geocoding as yet. * specifically only for Geocoding. No support for Reverse Geocoding as yet.
* *

View File

@@ -139,7 +139,8 @@ OpenLayers.Handler = OpenLayers.Class({
var keyModifiers = var keyModifiers =
(evt.shiftKey ? OpenLayers.Handler.MOD_SHIFT : 0) | (evt.shiftKey ? OpenLayers.Handler.MOD_SHIFT : 0) |
(evt.ctrlKey ? OpenLayers.Handler.MOD_CTRL : 0) | (evt.ctrlKey ? OpenLayers.Handler.MOD_CTRL : 0) |
(evt.altKey ? OpenLayers.Handler.MOD_ALT : 0); (evt.altKey ? OpenLayers.Handler.MOD_ALT : 0) |
(evt.metaKey ? OpenLayers.Handler.MOD_META : 0);
/* if it differs from the handler object's key mask, /* if it differs from the handler object's key mask,
bail out of the event handler */ bail out of the event handler */
@@ -232,12 +233,12 @@ OpenLayers.Handler = OpenLayers.Class({
* to get more information about the event that the handler is * to get more information about the event that the handler is
* processing. * processing.
* *
* This allows modifier keys on the event to be checked (alt, shift, * This allows modifier keys on the event to be checked (alt, shift, ctrl,
* and ctrl cannot be checked with the keyboard handler). For a * and meta cannot be checked with the keyboard handler). For a
* control to determine which modifier keys are associated with the * control to determine which modifier keys are associated with the
* event that a handler is currently processing, it should access * event that a handler is currently processing, it should access
* (code)handler.evt.altKey || handler.evt.shiftKey || * (code)handler.evt.altKey || handler.evt.shiftKey ||
* handler.evt.ctrlKey(end). * handler.evt.ctrlKey || handler.evt.metaKey(end).
* *
* Parameters: * Parameters:
* evt - {Event} The browser event. * evt - {Event} The browser event.
@@ -285,4 +286,10 @@ OpenLayers.Handler.MOD_CTRL = 2;
*/ */
OpenLayers.Handler.MOD_ALT = 4; OpenLayers.Handler.MOD_ALT = 4;
/**
* Constant: OpenLayers.Handler.MOD_META
* If set as the <keyMask>, <checkModifiers> returns false if Cmd is down.
*/
OpenLayers.Handler.MOD_META = 8;

View File

@@ -21,14 +21,6 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
*/ */
wheelListener: null, wheelListener: null,
/**
* Property: mousePosition
* {<OpenLayers.Pixel>} mousePosition is necessary because
* evt.clientX/Y is buggy in Moz on wheel events, so we cache and use the
* value from the last mousemove.
*/
mousePosition: null,
/** /**
* Property: interval * Property: interval
* {Integer} In order to increase server performance, an interval (in * {Integer} In order to increase server performance, an interval (in
@@ -101,12 +93,13 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
// Ride up the element's DOM hierarchy to determine if it or any of // Ride up the element's DOM hierarchy to determine if it or any of
// its ancestors was: // its ancestors was:
// * specifically marked as scrollable // * specifically marked as scrollable (CSS overflow property)
// * one of our layer divs // * one of our layer divs or a div marked as scrollable
// ('olScrollable' CSS class)
// * the map div // * the map div
// //
var overScrollableDiv = false; var overScrollableDiv = false;
var overLayerDiv = false; var allowScroll = false;
var overMapDiv = false; var overMapDiv = false;
var elem = OpenLayers.Event.element(e); var elem = OpenLayers.Event.element(e);
@@ -114,12 +107,13 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
if (!overScrollableDiv) { if (!overScrollableDiv) {
try { try {
var overflow;
if (elem.currentStyle) { if (elem.currentStyle) {
overflow = elem.currentStyle["overflow"]; overflow = elem.currentStyle["overflow"];
} else { } else {
var style = var style =
document.defaultView.getComputedStyle(elem, null); document.defaultView.getComputedStyle(elem, null);
var overflow = style.getPropertyValue("overflow"); overflow = style.getPropertyValue("overflow");
} }
overScrollableDiv = ( overflow && overScrollableDiv = ( overflow &&
(overflow == "auto") || (overflow == "scroll") ); (overflow == "auto") || (overflow == "scroll") );
@@ -129,18 +123,21 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
} }
} }
if (!overLayerDiv) { if (!allowScroll) {
allowScroll = OpenLayers.Element.hasClass(elem, 'olScrollable');
if (!allowScroll) {
for (var i = 0, len = this.map.layers.length; i < len; i++) { for (var i = 0, len = this.map.layers.length; i < len; i++) {
// Are we in the layer div? Note that we have two cases // Are we in the layer div? Note that we have two cases
// here: one is to catch EventPane layers, which have a // here: one is to catch EventPane layers, which have a
// pane above the layer (layer.pane) // pane above the layer (layer.pane)
if (elem == this.map.layers[i].div var layer = this.map.layers[i];
|| elem == this.map.layers[i].pane) { if (elem == layer.div || elem == layer.pane) {
overLayerDiv = true; allowScroll = true;
break; break;
} }
} }
} }
}
overMapDiv = (elem == this.map.div); overMapDiv = (elem == this.map.div);
elem = elem.parentNode; elem = elem.parentNode;
@@ -153,7 +150,7 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
// //
// otherwise // otherwise
// //
// If we are over the layer div: // If we are over the layer div or a 'olScrollable' div:
// * zoom/in out // * zoom/in out
// then // then
// * kill event (so as not to also scroll the page after zooming) // * kill event (so as not to also scroll the page after zooming)
@@ -164,18 +161,23 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
// layerswitcher or the pan/zoom control) // layerswitcher or the pan/zoom control)
// //
if (!overScrollableDiv && overMapDiv) { if (!overScrollableDiv && overMapDiv) {
if (overLayerDiv) { if (allowScroll) {
var delta = 0; var delta = 0;
if (!e) { if (!e) {
e = window.event; e = window.event;
} }
if (e.wheelDelta) { if (e.wheelDelta) {
delta = e.wheelDelta/120; delta = e.wheelDelta;
if (window.opera && window.opera.version() < 9.2) { if (delta % 160 === 0) {
delta = -delta; // opera have steps of 160 instead of 120
delta = delta * 0.75;
} }
delta = delta / 120;
} else if (e.detail) { } else if (e.detail) {
delta = -e.detail / 3; // detail in Firefox on OS X is 1/3 of Windows
// so force delta 1 / -1
delta = - (e.detail / Math.abs(e.detail));
} }
this.delta = this.delta + delta; this.delta = this.delta + delta;
@@ -208,23 +210,7 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
this.delta = 0; this.delta = 0;
if (delta) { if (delta) {
// add the mouse position to the event because mozilla has e.xy = this.map.events.getMousePosition(e);
// a bug with clientX and clientY (see
// https://bugzilla.mozilla.org/show_bug.cgi?id=352179)
// getLonLatFromViewPortPx(e) returns wrong values
if (this.mousePosition) {
e.xy = this.mousePosition;
}
if (!e.xy) {
// If the mouse hasn't moved over the map yet, then
// we don't have a mouse position (in FF), so we just
// act as if the mouse was at the center of the map.
// Note that we can tell we are in the map -- and
// this.map is ensured to be true above.
e.xy = this.map.getPixelFromLonLat(
this.map.getCenter()
);
}
if (delta < 0) { if (delta < 0) {
this.callback("down", [e, this.cumulative ? delta : -1]); this.callback("down", [e, this.cumulative ? delta : -1]);
} else { } else {
@@ -233,20 +219,6 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
} }
}, },
/**
* Method: mousemove
* Update the stored mousePosition on every move.
*
* Parameters:
* evt - {Event} The browser event
*
* Returns:
* {Boolean} Allow event propagation
*/
mousemove: function (evt) {
this.mousePosition = evt.xy;
},
/** /**
* Method: activate * Method: activate
*/ */

View File

@@ -11,7 +11,13 @@
/** /**
* Class: OpenLayers.Layer.EventPane * Class: OpenLayers.Layer.EventPane
* Base class for 3rd party layers. Create a new event pane layer with the * Base class for 3rd party layers, providing a DOM element which isolates
* the 3rd-party layer from mouse events.
* Only used by Google layers.
*
* Automatically instantiated by the Google constructor, and not usually instantiated directly.
*
* Create a new event pane layer with the
* <OpenLayers.Layer.EventPane> constructor. * <OpenLayers.Layer.EventPane> constructor.
* *
* Inherits from: * Inherits from:

View File

@@ -14,6 +14,11 @@
/** /**
* Class: OpenLayers.Layer.Google * Class: OpenLayers.Layer.Google
* *
* Provides a wrapper for Google's Maps API
* Normally the Terms of Use for this API do not allow wrapping, but Google
* have provided written consent to OpenLayers for this - see email in
* http://osgeo-org.1560.n6.nabble.com/Google-Maps-API-Terms-of-Use-changes-tp4910013p4911981.html
*
* Inherits from: * Inherits from:
* - <OpenLayers.Layer.SphericalMercator> * - <OpenLayers.Layer.SphericalMercator>
* - <OpenLayers.Layer.EventPane> * - <OpenLayers.Layer.EventPane>
@@ -462,6 +467,10 @@ OpenLayers.Layer.Google.cache = {};
* Constant: OpenLayers.Layer.Google.v2 * Constant: OpenLayers.Layer.Google.v2
* *
* Mixin providing functionality specific to the Google Maps API v2. * Mixin providing functionality specific to the Google Maps API v2.
*
* This API has been deprecated by Google.
* Developers are encouraged to migrate to v3 of the API; support for this
* is provided by <OpenLayers.Layer.Google.v3>
*/ */
OpenLayers.Layer.Google.v2 = { OpenLayers.Layer.Google.v2 = {

View File

@@ -11,15 +11,42 @@
/** /**
* Constant: OpenLayers.Layer.Google.v3 * Constant: OpenLayers.Layer.Google.v3
* *
* Mixin providing functionality specific to the Google Maps API v3 <= v3.6. * Mixin providing functionality specific to the Google Maps API v3.
* Note that this layer configures the google.maps.map object with the *
* "disableDefaultUI" option set to true. Using UI controls that the Google * To use this layer, you must include the GMaps v3 API in your html.
* Maps API provides is not supported by the OpenLayers API. To use this layer, *
* you must include the GMaps API (<= v3.6) in your html: * Because OpenLayers needs to control mouse events, it isolates the GMaps mapObject
* (the DOM elements provided by Google) using the EventPane.
* However, because the Terms of Use require some of those elements,
* such as the links to Google's terms, to be clickable, these elements have
* to be moved up to OpenLayers' container div. There is however no easy way
* to identify these, and the logic (see the repositionMapElements function
* in the source) may need to be changed if Google changes them.
* These elements are not part of the published API and can be changed at any time,
* so a given OpenLayers release can only guarantee support for the 'frozen'
* Google release at the time of the OpenLayers release. See
* https://developers.google.com/maps/documentation/javascript/basics#Versioning
* for Google's current release cycle.
*
* For this reason, it's recommended that production code specifically loads
* the current frozen version, for example:
* *
* (code) * (code)
* <script src="http://maps.google.com/maps/api/js?v=3.6&amp;sensor=false"></script> * <script src="http://maps.google.com/maps/api/js?v=3.7&amp;sensor=false"></script>
* (end) * (end)
*
* but that development code should use the latest 'nightly' version, so that any
* problems can be dealt with as soon as they arise, and before they affect the production, 'frozen', code.
*
* Note, however, that frozen versions are retired as part of Google's release
* cycle, and once this happens, you will get the next version, in the example above, 3.8 once 3.7 is retired.
*
* This version supports 3.7.
*
*
* Note that this layer configures the google.maps.map object with the
* "disableDefaultUI" option set to true. Using UI controls that the Google
* Maps API provides is not supported by the OpenLayers API.
*/ */
OpenLayers.Layer.Google.v3 = { OpenLayers.Layer.Google.v3 = {
@@ -137,27 +164,31 @@ OpenLayers.Layer.Google.v3 = {
var cache = OpenLayers.Layer.Google.cache[this.map.id]; var cache = OpenLayers.Layer.Google.cache[this.map.id];
var container = this.map.viewPortDiv; var container = this.map.viewPortDiv;
// move the Map Data popup to the container, if any
while (div.lastChild.style.display == "none") {
container.appendChild(div.lastChild);
}
// move the ToS and branding stuff up to the container div // move the ToS and branding stuff up to the container div
var termsOfUse = div.lastChild; // depends on value of zIndex, which is not robust
for (var i=div.children.length-1; i>=0; --i) {
if (div.children[i].style.zIndex == 1000001) {
var termsOfUse = div.children[i];
container.appendChild(termsOfUse); container.appendChild(termsOfUse);
termsOfUse.style.zIndex = "1100"; termsOfUse.style.zIndex = "1100";
termsOfUse.style.bottom = ""; termsOfUse.style.bottom = "";
termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3"; termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
termsOfUse.style.display = ""; termsOfUse.style.display = "";
cache.termsOfUse = termsOfUse; cache.termsOfUse = termsOfUse;
}
var poweredBy = div.lastChild; if (div.children[i].style.zIndex == 1000000) {
var poweredBy = div.children[i];
container.appendChild(poweredBy); container.appendChild(poweredBy);
poweredBy.style.zIndex = "1100"; poweredBy.style.zIndex = "1100";
poweredBy.style.bottom = ""; poweredBy.style.bottom = "";
poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint"; poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
poweredBy.style.display = ""; poweredBy.style.display = "";
cache.poweredBy = poweredBy; cache.poweredBy = poweredBy;
}
if (div.children[i].style.zIndex == 10000002) {
container.appendChild(div.children[i]);
}
}
this.setGMapVisibility(this.visibility); this.setGMapVisibility(this.visibility);

View File

@@ -1302,19 +1302,20 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* columns - {Integer} Maximum number of columns we want our grid to have. * columns - {Integer} Maximum number of columns we want our grid to have.
*/ */
removeExcessTiles: function(rows, columns) { removeExcessTiles: function(rows, columns) {
var i, l;
// remove extra rows // remove extra rows
while (this.grid.length > rows) { while (this.grid.length > rows) {
var row = this.grid.pop(); var row = this.grid.pop();
for (var i=0, l=row.length; i<l; i++) { for (i=0, l=row.length; i<l; i++) {
var tile = row[i]; var tile = row[i];
this.destroyTile(tile); this.destroyTile(tile);
} }
} }
// remove extra columns // remove extra columns
while (this.grid[0].length > columns) { for (i=0, l=this.grid.length; i<l; i++) {
for (var i=0, l=this.grid.length; i<l; i++) { while (this.grid[i].length > columns) {
var row = this.grid[i]; var row = this.grid[i];
var tile = row.pop(); var tile = row.pop();
this.destroyTile(tile); this.destroyTile(tile);

View File

@@ -13,7 +13,7 @@
* This Layer reads from UTFGrid tiled data sources. Since UTFGrids are * This Layer reads from UTFGrid tiled data sources. Since UTFGrids are
* essentially JSON-based ASCII art with attached attributes, they are not * essentially JSON-based ASCII art with attached attributes, they are not
* visibly rendered. In order to use them in the map, you must add a * visibly rendered. In order to use them in the map, you must add a
* <OpenLayers.Control.UTFGrid> ontrol as well. * <OpenLayers.Control.UTFGrid> control as well.
* *
* Example: * Example:
* *

View File

@@ -83,6 +83,7 @@ OpenLayers.Map = OpenLayers.Class({
* mouseout - triggered after mouseout the map * mouseout - triggered after mouseout the map
* mousemove - triggered after mousemove the map * mousemove - triggered after mousemove the map
* changebaselayer - triggered after the base layer changes * changebaselayer - triggered after the base layer changes
* updatesize - triggered after the <updateSize> method was executed
*/ */
/** /**
@@ -662,6 +663,7 @@ OpenLayers.Map = OpenLayers.Class({
* be properly set below. * be properly set below.
*/ */
delete this.center; delete this.center;
delete this.zoom;
this.addLayers(options.layers); this.addLayers(options.layers);
// set center (and optionally zoom) // set center (and optionally zoom)
if (options.center && !this.getCenter()) { if (options.center && !this.getCenter()) {
@@ -1489,6 +1491,7 @@ OpenLayers.Map = OpenLayers.Class({
} }
} }
this.events.triggerEvent("updatesize");
}, },
/** /**
@@ -1783,9 +1786,13 @@ OpenLayers.Map = OpenLayers.Class({
* <baseLayer>'s maxExtent. * <baseLayer>'s maxExtent.
*/ */
adjustZoom: function(zoom) { adjustZoom: function(zoom) {
if (this.baseLayer && this.baseLayer.wrapDateLine) {
var resolution, resolutions = this.baseLayer.resolutions, var resolution, resolutions = this.baseLayer.resolutions,
maxResolution = this.getMaxExtent().getWidth() / this.size.w; maxResolution = this.getMaxExtent().getWidth() / this.size.w;
if (this.getResolutionForZoom(zoom) > maxResolution) { if (this.getResolutionForZoom(zoom) > maxResolution) {
if (this.fractionalZoom) {
zoom = this.getZoomForResolution(maxResolution);
} else {
for (var i=zoom|0, ii=resolutions.length; i<ii; ++i) { for (var i=zoom|0, ii=resolutions.length; i<ii; ++i) {
if (resolutions[i] <= maxResolution) { if (resolutions[i] <= maxResolution) {
zoom = i; zoom = i;
@@ -1793,9 +1800,29 @@ OpenLayers.Map = OpenLayers.Class({
} }
} }
} }
}
}
return zoom; return zoom;
}, },
/**
* APIMethod: getMinZoom
* Returns the minimum zoom level for the current map view. If the base
* layer is configured with <wrapDateLine> set to true, this will be the
* first zoom level that shows no more than one world width in the current
* map viewport. Components that rely on this value (e.g. zoom sliders)
* should also listen to the map's "updatesize" event and call this method
* in the "updatesize" listener.
*
* Returns:
* {Number} Minimum zoom level that shows a map not wider than its
* <baseLayer>'s maxExtent. This is an Integer value, unless the map is
* configured with <fractionalZoom> set to true.
*/
getMinZoom: function() {
return this.adjustZoom(0);
},
/** /**
* Method: moveTo * Method: moveTo
* *
@@ -1817,14 +1844,12 @@ OpenLayers.Map = OpenLayers.Class({
zoom = Math.round(zoom); zoom = Math.round(zoom);
} }
} }
if (this.baseLayer.wrapDateLine) {
var requestedZoom = zoom; var requestedZoom = zoom;
zoom = this.adjustZoom(zoom); zoom = this.adjustZoom(zoom);
if (zoom !== requestedZoom) { if (zoom !== requestedZoom) {
// zoom was adjusted, so keep old lonlat to avoid panning // zoom was adjusted, so keep old lonlat to avoid panning
lonlat = this.getCenter(); lonlat = this.getCenter();
} }
}
// dragging is false by default // dragging is false by default
var dragging = options.dragging || this.dragging; var dragging = options.dragging || this.dragging;
// forceZoomChange is false by default // forceZoomChange is false by default

View File

@@ -108,10 +108,7 @@ OpenLayers.Popup.Anchored =
var oldRelativePosition = this.relativePosition; var oldRelativePosition = this.relativePosition;
this.relativePosition = this.calculateRelativePosition(px); this.relativePosition = this.calculateRelativePosition(px);
var newPx = this.calculateNewPx(px); OpenLayers.Popup.prototype.moveTo.call(this, this.calculateNewPx(px));
var newArguments = new Array(newPx);
OpenLayers.Popup.prototype.moveTo.apply(this, newArguments);
//if this move has caused the popup to change its relative position, //if this move has caused the popup to change its relative position,
// we need to make the appropriate cosmetic changes. // we need to make the appropriate cosmetic changes.

View File

@@ -449,7 +449,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
*/ */
createRenderRoot: function() { createRenderRoot: function() {
var svg = this.nodeFactory(this.container.id + "_svgRoot", "svg"); var svg = this.nodeFactory(this.container.id + "_svgRoot", "svg");
svg.style.position = "absolute"; svg.style.display = "block";
return svg; return svg;
}, },

View File

@@ -7,7 +7,7 @@ var OpenLayers = {
/** /**
* Constant: VERSION_NUMBER * Constant: VERSION_NUMBER
*/ */
VERSION_NUMBER: "Release 2.12-rc3", VERSION_NUMBER: "Release 2.12-rc7",
/** /**
* Constant: singleFile * Constant: singleFile

View File

@@ -339,9 +339,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
*/ */
setImgSrc: function(url) { setImgSrc: function(url) {
var img = this.imgDiv; var img = this.imgDiv;
if (url) {
img.style.visibility = 'hidden'; img.style.visibility = 'hidden';
img.style.opacity = 0; img.style.opacity = 0;
if (url) {
// don't set crossOrigin if the url is a data URL // don't set crossOrigin if the url is a data URL
if (this.crossOriginKeyword) { if (this.crossOriginKeyword) {
if (url.substr(0, 5) !== 'data:') { if (url.substr(0, 5) !== 'data:') {
@@ -351,6 +351,13 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
} }
} }
img.src = url; img.src = url;
} else {
// Remove reference to the image, and leave it to the browser's
// caching and garbage collection.
this.imgDiv = null;
if (img.parentNode) {
img.parentNode.removeChild(img);
}
} }
}, },

View File

@@ -74,13 +74,6 @@ OpenLayers.Util.isArray = function(a) {
return (Object.prototype.toString.call(a) === '[object Array]'); return (Object.prototype.toString.call(a) === '[object Array]');
}; };
/**
* Maintain existing definition of $.
*/
if(typeof window.$ === "undefined") {
window.$ = OpenLayers.Util.getElement;
}
/** /**
* Function: removeItem * Function: removeItem
* Remove an object from an array. Iterates through the array * Remove an object from an array. Iterates through the array
@@ -1635,6 +1628,33 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
var containerElement = (options && options.containerElement) var containerElement = (options && options.containerElement)
? options.containerElement : document.body; ? options.containerElement : document.body;
// Opera and IE7 can't handle a node with position:aboslute if it inherits
// position:absolute from a parent.
var parentHasPositionAbsolute = false;
var superContainer = null;
var parent = containerElement;
while (parent && parent.tagName.toLowerCase()!="body") {
var parentPosition = OpenLayers.Element.getStyle(parent, "position");
if(parentPosition == "absolute") {
parentHasPositionAbsolute = true;
break;
} else if (parentPosition && parentPosition != "static") {
break;
}
parent = parent.parentNode;
}
if(parentHasPositionAbsolute && (containerElement.clientHeight === 0 ||
containerElement.clientWidth === 0) ){
superContainer = document.createElement("div");
superContainer.style.visibility = "hidden";
superContainer.style.position = "absolute";
superContainer.style.overflow = "visible";
superContainer.style.width = document.body.clientWidth + "px";
superContainer.style.height = document.body.clientHeight + "px";
superContainer.appendChild(container);
}
container.style.position = "absolute";
//fix a dimension, if specified. //fix a dimension, if specified.
if (size) { if (size) {
if (size.w) { if (size.w) {
@@ -1668,25 +1688,10 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
container.appendChild(content); container.appendChild(content);
// append container to body for rendering // append container to body for rendering
if (superContainer) {
containerElement.appendChild(superContainer);
} else {
containerElement.appendChild(container); containerElement.appendChild(container);
// Opera and IE7 can't handle a node with position:aboslute if it inherits
// position:absolute from a parent.
var parentHasPositionAbsolute = false;
var parent = container.parentNode;
while (parent && parent.tagName.toLowerCase()!="body") {
var parentPosition = OpenLayers.Element.getStyle(parent, "position");
if(parentPosition == "absolute") {
parentHasPositionAbsolute = true;
break;
} else if (parentPosition && parentPosition != "static") {
break;
}
parent = parent.parentNode;
}
if(!parentHasPositionAbsolute) {
container.style.position = "absolute";
} }
// calculate scroll width of content and add corners and shadow width // calculate scroll width of content and add corners and shadow width
@@ -1703,7 +1708,12 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
// remove elements // remove elements
container.removeChild(content); container.removeChild(content);
if (superContainer) {
superContainer.removeChild(container);
containerElement.removeChild(superContainer);
} else {
containerElement.removeChild(container); containerElement.removeChild(container);
}
return new OpenLayers.Size(w, h); return new OpenLayers.Size(w, h);
}; };

View File

@@ -164,6 +164,17 @@ OpenLayers.Util.getArgs = function(url) {
return OpenLayers.Util.getParameters(url); return OpenLayers.Util.getParameters(url);
}; };
/**
* Maintain existing definition of $.
*
* The use of our $-method is deprecated and the mapping of
* OpenLayers.Util.getElement will eventually be removed. Do not depend on
* window.$ being defined by OpenLayers.
*/
if(typeof window.$ === "undefined") {
window.$ = OpenLayers.Util.getElement;
}
/** /**
* Namespace: OpenLayers.Ajax * Namespace: OpenLayers.Ajax
*/ */

View File

@@ -25,6 +25,16 @@ Corresponding issues/pull requests:
* https://github.com/openlayers/openlayers/pull/254 * https://github.com/openlayers/openlayers/pull/254
* https://github.com/openlayers/openlayers/pull/261 * https://github.com/openlayers/openlayers/pull/261
## style.mobile.css
The theme/default directory now includes a mobile-specific CSS file, namely
style.mobile.css. The OpenLayers mobile examples use this file. To use it
in your mobile pages use tags like this:
<link rel="stylesheet" href="openlayers/theme/default/style.mobile.css" type="text/css">
(This file used to be in the examples/ directory).
## Sensible projection defaults ## Sensible projection defaults
The geographic and web mercator projections define default values for the maxExtent, and units. This simplifies the map and layer configuration. The geographic and web mercator projections define default values for the maxExtent, and units. This simplifies the map and layer configuration.
@@ -219,6 +229,20 @@ Corresponding issues/pull requests:
* https://github.com/openlayers/openlayers/pull/101 * https://github.com/openlayers/openlayers/pull/101
## Google v3 Layer
This release fixes a problem with the clickable elements supplied by Google. `OpenLayers.Layer.Google.v3` is now compatible with the current frozen version of Google's API (3.7) and also with the current release and nightly versions (3.8 and 3.9), but be aware that Google may change these elements in their release and nightly versions at any time, and an interim fix OpenLayers release may be needed.
It's recommended that production servers always load the frozen version of Google's API, but it would help find potential problems if development pages used the latest nightly version.
See the class description in the API docs for `OpenLayers.Layer.Google.v3` for more details.
Good ideas on how to improve this unsatisfactory situation welcome!
Corresponding issues/pull requests:
* https://github.com/openlayers/openlayers/pull/472
## OSM and Bing Layers ## OSM and Bing Layers
`Layer.OSM` is now defined in its own script file, namely `OpenLayers/Layer/OSM.js`. So people using `Layer.OSM` should now include `OpenLayers/Layer/OSM.js`, as opposed to `OpenLayers/Layer/XYZ.js`, in their OpenLayers builds. `Layer.OSM` is now defined in its own script file, namely `OpenLayers/Layer/OSM.js`. So people using `Layer.OSM` should now include `OpenLayers/Layer/OSM.js`, as opposed to `OpenLayers/Layer/XYZ.js`, in their OpenLayers builds.

View File

@@ -7,3 +7,31 @@ Previously, objects generated by the library were given id properties with value
Corresponding issues/pull requests: Corresponding issues/pull requests:
* https://github.com/openlayers/openlayers/pull/416 * https://github.com/openlayers/openlayers/pull/416
## Better support for analog scroll wheel
Removed rounding of zoom level for maps with fractionalZoom == true. So users with an OS and interface device with analog scroll support will now get smooth zooming.
Corresponding issues/pull requests:
* https://github.com/openlayers/openlayers/pull/483
# Behavior Changes from Past Releases
## window.$ is no longer an alias for OpenLayers.Util.getElement
We do no longer create a global variable '$' when such a symbol isn't already
defined. Previous versions of OpenLayers would define '$' to be an alias for
OpenLayers.Util.getElement. If your application requires window.$ to be defined
in such a way you can either
* include deprecated.js in your custom build or as additional ressource in your
HTML-file
* or you do the aliasing in your application code yourself:
window.$ = OpenLayers.Util.getElement;
Corresponding issue/pull requests:
* https://github.com/openlayers/openlayers/pull/423

View File

@@ -14,6 +14,23 @@
"olControlOverviewMap", "displayClass is correct" ); "olControlOverviewMap", "displayClass is correct" );
} }
function test_divs_title(t) {
t.plan(2);
control = new OpenLayers.Control.OverviewMap({
maximizeTitle: "maximize title",
minimizeTitle: "minimize title"
});
map = new OpenLayers.Map('map', {
layers: [new OpenLayers.Layer("layer", {isBaseLayer: true})],
controls: [control]
});
map.zoomToMaxExtent();
t.eq(control.maximizeDiv.title, "maximize title", "maximizeDiv.title is correct");
t.eq(control.minimizeDiv.title, "minimize title", "minimizeDiv.title is correct");
map.destroy();
}
function test_setMap(t) { function test_setMap(t) {
t.plan(4); t.plan(4);

View File

@@ -34,6 +34,31 @@
t.eq( control2.div.style.top, "100px", "2nd control div is located correctly"); t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
} }
function test_draw(t) {
t.plan(3);
map = new OpenLayers.Map('map', {controls:[]});
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.zoomToMaxExtent();
control = new OpenLayers.Control.PanZoomBar();
map.addControl(control);
t.eq(control.zoombarDiv.style.height, '176px', "Bar's height is correct.");
map.baseLayer.wrapDateLine = true;
control.redraw();
t.eq(control.zoombarDiv.style.height, '154px', "Bar's height is correct after minZoom restriction.");
map.div.style.width = "512px";
map.updateSize();
t.eq(control.zoombarDiv.style.height, '165px', "Bar's height is correct after resize and minZoom restriction.");
map.div.style.width = "1024px";
map.destroy();
}
function test_Control_PanZoomBar_clearDiv(t) { function test_Control_PanZoomBar_clearDiv(t) {
t.plan(2); t.plan(2);
map = new OpenLayers.Map('map', {controls:[]}); map = new OpenLayers.Map('map', {controls:[]});

View File

@@ -559,6 +559,46 @@
"Root container moved correctly when control is destroyed and layers was an array parameter"); "Root container moved correctly when control is destroyed and layers was an array parameter");
} }
function test_unselectAll(t) {
t.plan(2);
var layer = new OpenLayers.Layer.Vector();
var control = new OpenLayers.Control.SelectFeature(layer);
var feature1 = new OpenLayers.Feature.Vector();
feature1.id = 1;
var feature2 = new OpenLayers.Feature.Vector();
feature2.id = 2;
var feature3 = new OpenLayers.Feature.Vector();
feature3.id = 3;
var feature4 = new OpenLayers.Feature.Vector();
feature4.id = 4;
layer.addFeatures([feature1, feature2, feature3, feature4]);
control.select(feature1);
control.select(feature2);
control.select(feature3);
control.select(feature4);
layer.events.on({
featureunselected: function(e) {
// we change the selectedFeatures array while
// unselectAll is iterating over that array.
if(feature2.layer) {
layer.removeFeatures([feature2]);
}
}
});
control.unselectAll({except: feature3});
t.eq(layer.selectedFeatures.length, 1,
'unselectAll unselected all but one');
t.eq(layer.selectedFeatures[0].id, 3,
'the remaining selected features is the one expected');
}
</script> </script>
</head> </head>
<body> <body>

View File

@@ -104,13 +104,18 @@
t.plan(7); t.plan(7);
var layer = new OpenLayers.Layer.Vector("foo", { var layer1 = new OpenLayers.Layer.Vector("foo", {
maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10), maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
isBaseLayer: true isBaseLayer: true
}); });
var control = new OpenLayers.Control.Split({layer: layer}); var layer2 = new OpenLayers.Layer.Vector("bar", {
maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
isBaseLayer: false
});
var control = new OpenLayers.Control.Split({layer: layer1});
var map = new OpenLayers.Map("map"); var map = new OpenLayers.Map("map");
map.addLayer(layer); map.addLayer(layer1);
map.addLayer(layer2);
map.zoomToMaxExtent(); map.zoomToMaxExtent();
map.addControl(control); map.addControl(control);
@@ -124,17 +129,17 @@
t.eq(control.handler.active, false, "sketch handler deactivated"); t.eq(control.handler.active, false, "sketch handler deactivated");
// set a source layer // set a source layer
control.setSource(layer); control.setSource(layer2);
// activate and check that listeners are registered // activate and check that listeners are registered
control.activate(); control.activate();
t.ok(layer.events.listeners.sketchcomplete, "sketchcomplete listener registered"); t.ok(layer2.events.listeners.sketchcomplete, "sketchcomplete listener registered");
t.ok(layer.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered"); t.ok(layer2.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered");
// deactivate and confirm no draw related events // deactivate and confirm no draw related events
control.deactivate(); control.deactivate();
t.eq(layer.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners"); t.eq(layer2.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners");
t.eq(layer.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners"); t.eq(layer2.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners");
map.destroy(); map.destroy();
} }

View File

@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_constructor(t) {
t.plan(4);
var control = new OpenLayers.Control.ZoomBox();
t.ok(control instanceof OpenLayers.Control, "instance of Control");
t.ok(control instanceof OpenLayers.Control.ZoomBox, "instance of ZoomBox");
t.eq(control.displayClass, "olControlZoomBox", "displayClass");
control.destroy();
control = new OpenLayers.Control.ZoomBox({
zoomOnClick: false
});
t.eq(control.zoomOnClick, false, "zoomOnClick");
control.destroy();
}
function test_zoomBox(t) {
t.plan(4);
var map = new OpenLayers.Map("map", {
layers: [new OpenLayers.Layer("", {isBaseLayer: true})],
center: [0, 0],
zoom: 1
});
var control = new OpenLayers.Control.ZoomBox();
map.addControl(control);
control.zoomBox(new OpenLayers.Pixel(50, 60));
t.eq(map.getZoom(), 2, "zoomed on click");
control.zoomOnClick = false;
control.zoomBox(new OpenLayers.Pixel(-50, -60));
t.eq(map.getZoom(), 2, "not zoomed with zoomOnClick set to false");
map.zoomToMaxExtent();
control.zoomBox(new OpenLayers.Bounds(128, 64, 256, 128));
t.eq(map.getCenter().toShortString(), "-45, 22.5", "centered to box center");
t.eq(map.getZoom(), 3, "zoomed to box extent");
map.destroy();
}
</script>
</head>
<body>
<div id="map" style="width: 512px; height: 256px;"/>
</body>
</html>

View File

@@ -201,11 +201,16 @@ var cases = {
"v2/box-coord.xml": new OpenLayers.Bounds(1, 2, 3, 4), "v2/box-coord.xml": new OpenLayers.Bounds(1, 2, 3, 4),
"v2/box-coordinates.xml": new OpenLayers.Bounds(1, 2, 3, 4) "v2/box-coordinates.xml": new OpenLayers.Bounds(1, 2, 3, 4),
"v3/linestring3d.xml": new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(1, 2, 3),
new OpenLayers.Geometry.Point(4, 5, 6)
])
}; };
// cases for v3 use the same geometries // some cases for v3 use the same geometries
OpenLayers.Util.extend(cases, { OpenLayers.Util.extend(cases, {
"v3/point.xml": cases["v2/point-coordinates.xml"], "v3/point.xml": cases["v2/point-coordinates.xml"],
"v3/linestring.xml": cases["v2/linestring-coordinates.xml"], "v3/linestring.xml": cases["v2/linestring-coordinates.xml"],

View File

@@ -10,8 +10,8 @@
"v2/linestring-coord.xml", "v2/linestring-coordinates.xml", "v2/linestring-coord.xml", "v2/linestring-coordinates.xml",
"v2/multipoint-coord.xml", "v2/multipoint-coordinates.xml", "v2/multipoint-coord.xml", "v2/multipoint-coordinates.xml",
"v2/multilinestring-coord.xml", "v2/multilinestring-coordinates.xml", "v2/multilinestring-coord.xml", "v2/multilinestring-coordinates.xml",
"v3/point.xml", "v3/linestring.xml", "v3/curve.xml", "v3/point.xml", "v3/linestring.xml", "v3/linestring3d.xml",
"v3/polygon.xml", "v3/surface.xml", "v3/curve.xml", "v3/polygon.xml", "v3/surface.xml",
"v3/multipoint-singular.xml", "v3/multipoint-plural.xml", "v3/multipoint-singular.xml", "v3/multipoint-plural.xml",
"v3/multilinestring-singular.xml", "v3/multilinestring-plural.xml", "v3/multilinestring-singular.xml", "v3/multilinestring-plural.xml",
"v3/multicurve-singular.xml", "v3/multicurve-curve.xml", "v3/multicurve-singular.xml", "v3/multicurve-curve.xml",
@@ -332,6 +332,11 @@
<gml:posList>1 2 3 4</gml:posList> <gml:posList>1 2 3 4</gml:posList>
</gml:LineString> </gml:LineString>
--></div> --></div>
<div id="v3/linestring3d.xml"><!--
<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="foo" srsDimension="3">
<gml:posList>1 2 3 4 5 6</gml:posList>
</gml:LineString>
--></div>
<div id="v3/curve.xml"><!-- <div id="v3/curve.xml"><!--
<gml:Curve xmlns:gml="http://www.opengis.net/gml" srsName="foo"> <gml:Curve xmlns:gml="http://www.opengis.net/gml" srsName="foo">
<gml:segments> <gml:segments>

View File

@@ -236,13 +236,13 @@
var f = new OpenLayers.Format.KML(); var f = new OpenLayers.Format.KML();
t.eq(f.read(f.write(feature))[0].attributes.name, feature.id, "placemark name from feature.id"); t.eq(f.read(f.write(feature))[0].attributes.name, feature.id, "placemark name from feature.id");
feature.attributes.name = "placemark name from attributes.name";
t.eq(f.read(f.write(feature))[0].attributes.name, feature.attributes.name, "placemark name from attributes.name");
feature.style = { feature.style = {
label: "placemark name from style.label" label: "placemark name from style.label"
}; };
t.eq(f.read(f.write(feature))[0].attributes.name, feature.style.label, "placemark name from style.label"); t.eq(f.read(f.write(feature))[0].attributes.name, feature.style.label, "placemark name from style.label");
feature.attributes.name = "placemark name from attributes.name";
t.eq(f.read(f.write(feature))[0].attributes.name, feature.attributes.name, "placemark name from attributes.name");
} }
function test_Format_KML_linestring_projected(t) { function test_Format_KML_linestring_projected(t) {
t.plan(1); t.plan(1);

View File

@@ -374,6 +374,22 @@
// GeoServer example above // GeoServer example above
} }
function test_read_exception(t) {
t.plan(1);
var text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<ows:ExceptionReport version="1.0.0"' +
' xsi:schemaLocation="http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows">' +
' <ows:Exception exceptionCode="NoApplicableCode">' +
' <ows:ExceptionText>Could not find type: {http://geonode.org/}_map_4_annotations</ows:ExceptionText>' +
' </ows:Exception>' +
'</ows:ExceptionReport>';
var format = new OpenLayers.Format.WFSDescribeFeatureType();
var obj = format.read(text);
t.ok(!!obj.error, "Error reported correctly");
}
</script> </script>
</head> </head>
<body> <body>

View File

@@ -4,7 +4,7 @@
<script type="text/javascript"> <script type="text/javascript">
function test_read_WPSDescribeProcess(t) { function test_read_WPSDescribeProcess(t) {
t.plan(16); t.plan(17);
var parser = new OpenLayers.Format.WPSDescribeProcess(); var parser = new OpenLayers.Format.WPSDescribeProcess();
var text = var text =
@@ -109,6 +109,13 @@
' </Supported>' + ' </Supported>' +
' </ComplexOutput>' + ' </ComplexOutput>' +
' </Output>' + ' </Output>' +
' <Output>' +
' <ows:Identifier>literal</ows:Identifier>' +
' <ows:Title>literal output</ows:Title>' +
' <LiteralOutput>' +
' <ows:DataType ows:reference="http://www.w3.org/TR/xmlschema-2/#integer">integer</ows:DataType>'+
' </LiteralOutput>' +
' </Output>' +
' </ProcessOutputs>' + ' </ProcessOutputs>' +
' </ProcessDescription>' + ' </ProcessDescription>' +
'</wps:ProcessDescriptions>'; '</wps:ProcessDescriptions>';
@@ -135,6 +142,9 @@
t.eq(result.complexOutput["supported"].formats["text/xml; subtype=gml/3.1.1"], true, "processOutputs supported format read correctly [1/2]"); t.eq(result.complexOutput["supported"].formats["text/xml; subtype=gml/3.1.1"], true, "processOutputs supported format read correctly [1/2]");
t.eq(result.complexOutput["supported"].formats["application/wkt"], true, "processOutputs supported format read correctly [1/2]"); t.eq(result.complexOutput["supported"].formats["application/wkt"], true, "processOutputs supported format read correctly [1/2]");
var literalresult = buffer.processOutputs[1];
t.eq(literalresult.literalOutput.dataType, "integer", "processOutputs supported data type read corectly");
text = '<?xml version="1.0" encoding="UTF-8"?>' + text = '<?xml version="1.0" encoding="UTF-8"?>' +
'<wps:ProcessDescriptions service="WPS" version="1.0.0" xmlns:wps="http://www.opengis.net/wps/1.0.0"' + '<wps:ProcessDescriptions service="WPS" version="1.0.0" xmlns:wps="http://www.opengis.net/wps/1.0.0"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en"' + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en"' +

View File

@@ -309,12 +309,12 @@
responseForm: { responseForm: {
responseDocument: { responseDocument: {
storeExecuteResponse: true, storeExecuteResponse: true,
output: { outputs: [{
asReference: true, asReference: true,
identifier: 'BufferedPolygon', identifier: 'BufferedPolygon',
title: 'Area serviced by playground.', title: 'Area serviced by playground.',
'abstract': 'Area within which most users of this playground will live.' 'abstract': 'Area within which most users of this playground will live.'
} }]
} }
} }
}); });
@@ -349,6 +349,11 @@
' <ows:Title>Area serviced by playground.</ows:Title>' + ' <ows:Title>Area serviced by playground.</ows:Title>' +
' <ows:Abstract>Area within which most users of this playground will live.</ows:Abstract>' + ' <ows:Abstract>Area within which most users of this playground will live.</ows:Abstract>' +
' </wps:Output>' + ' </wps:Output>' +
' <wps:Output>' +
' <ows:Identifier>literal</ows:Identifier>' +
' <ows:Title/>' +
' <ows:Abstract/>' +
' </wps:Output>' +
' </wps:ResponseDocument>' + ' </wps:ResponseDocument>' +
' </wps:ResponseForm>' + ' </wps:ResponseForm>' +
'</wps:Execute>'; '</wps:Execute>';
@@ -381,12 +386,17 @@
storeExecuteResponse: true, storeExecuteResponse: true,
lineage: true, lineage: true,
status: true, status: true,
output: { outputs: [
{
asReference: true, asReference: true,
identifier: 'BufferedPolygon', identifier: 'BufferedPolygon',
title: 'Area serviced by playground.', title: 'Area serviced by playground.',
'abstract': 'Area within which most users of this playground will live.' 'abstract': 'Area within which most users of this playground will live.'
},
{
identifier: 'literal'
} }
]
} }
} }
}); });
@@ -461,12 +471,12 @@
responseForm: { responseForm: {
responseDocument: { responseDocument: {
storeExecuteResponse: true, storeExecuteResponse: true,
output: { outputs: [{
asReference: true, asReference: true,
identifier: 'BufferedPolygon', identifier: 'BufferedPolygon',
title: 'Area serviced by playground.', title: 'Area serviced by playground.',
'abstract': 'Area within which most users of this playground will live.' 'abstract': 'Area within which most users of this playground will live.'
} }]
} }
} }
}); });

View File

@@ -123,7 +123,7 @@
} }
function test_Handler_setEvent(t) { function test_Handler_setEvent(t) {
t.plan(4); t.plan(5);
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');
var control = new OpenLayers.Control(); var control = new OpenLayers.Control();
map.addControl(control); map.addControl(control);
@@ -135,7 +135,8 @@
xy: new OpenLayers.Pixel(Math.random(), Math.random()), xy: new OpenLayers.Pixel(Math.random(), Math.random()),
altKey: (Math.random() > 0.5), altKey: (Math.random() > 0.5),
shiftKey: (Math.random() > 0.5), shiftKey: (Math.random() > 0.5),
ctrlKey: (Math.random() > 0.5) ctrlKey: (Math.random() > 0.5),
metaKey: (Math.random() > 0.5)
} }
map.events.triggerEvent("click", testEvent); map.events.triggerEvent("click", testEvent);
t.ok(handler.evt.xy.x == testEvent.xy.x && t.ok(handler.evt.xy.x == testEvent.xy.x &&
@@ -147,6 +148,8 @@
"handler.evt.shiftKey correct"); "handler.evt.shiftKey correct");
t.eq(handler.evt.ctrlKey, testEvent.ctrlKey, t.eq(handler.evt.ctrlKey, testEvent.ctrlKey,
"handler.evt.ctrlKey correct"); "handler.evt.ctrlKey correct");
t.eq(handler.evt.metaKey, testEvent.metaKey,
"handler.evt.metaKey correct");
} }
function test_Handler_destroy(t) { function test_Handler_destroy(t) {
@@ -173,7 +176,7 @@
} }
function test_Handler_checkModifiers(t) { function test_Handler_checkModifiers(t) {
t.plan(26); t.plan(62);
var handler = new OpenLayers.Handler({}); var handler = new OpenLayers.Handler({});
handler.keyMask = null; handler.keyMask = null;
var proceed = handler.checkModifiers({}); var proceed = handler.checkModifiers({});
@@ -192,7 +195,8 @@
MOD_NONE: null, MOD_NONE: null,
MOD_SHIFT: "shiftKey", MOD_SHIFT: "shiftKey",
MOD_CTRL: "ctrlKey", MOD_CTRL: "ctrlKey",
MOD_ALT: "altKey" MOD_ALT: "altKey",
MOD_META: "metaKey"
} }
var proceed, evt, value, c, k; var proceed, evt, value, c, k;
for(c in constants) { for(c in constants) {
@@ -220,8 +224,8 @@
* is OpenLayers.Handler.MOD_SHIFT, checkModifiers should return * is OpenLayers.Handler.MOD_SHIFT, checkModifiers should return
* true. * true.
*/ */
var constants = ["MOD_SHIFT", "MOD_CTRL", "MOD_ALT"]; var constants = ["MOD_SHIFT", "MOD_CTRL", "MOD_ALT", "MOD_META"];
var keys = ["shiftKey", "ctrlKey", "altKey"]; var keys = ["shiftKey", "ctrlKey", "altKey", "metaKey"];
var proceed, evt, c1, c2, k1, k2; var proceed, evt, c1, c2, k1, k2;
for(var i=0; i<constants.length-1; ++i) { for(var i=0; i<constants.length-1; ++i) {
c1 = constants[i]; c1 = constants[i];

View File

@@ -56,7 +56,6 @@
handler.setMap(map); handler.setMap(map);
handler.activate(); handler.activate();
var delta = 120; var delta = 120;
if (window.opera && window.opera.version() < 9.2) delta = -delta;
handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta});
t.ok(pass, "evt.xy was set even without a mouse move"); t.ok(pass, "evt.xy was set even without a mouse move");
} }
@@ -108,7 +107,6 @@
var activated = handler.activate(); var activated = handler.activate();
var delta = 120; var delta = 120;
if (window.opera && window.opera.version() < 9.2) delta = -delta;
handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta});
handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta});
t.delay_call(1, function() { t.delay_call(1, function() {
@@ -138,7 +136,6 @@
var delta = 120; var delta = 120;
// generate 20 scroll up in non cumulative mode // generate 20 scroll up in non cumulative mode
if (window.opera && window.opera.version() < 9.2) delta = -delta;
for (var i=0; i < 20; i++) { for (var i=0; i < 20; i++) {
handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta});
} }

View File

@@ -1375,7 +1375,8 @@
map.zoomTo(1); map.zoomTo(1);
t.delay_call(1, function() { // Mark one tile loaded, to see if back buffer removal gets scheduled.
layer.grid[1][1].onImageLoad();
t.ok(layer.backBuffer.parentNode === layer.div, t.ok(layer.backBuffer.parentNode === layer.div,
'[a] back buffer is a child of layer div'); '[a] back buffer is a child of layer div');
@@ -1396,7 +1397,6 @@
// tear down // tear down
map.destroy(); map.destroy();
});
} }
function test_getGridData(t) { function test_getGridData(t) {
@@ -1524,6 +1524,70 @@
} }
function test_removeExcessTiles(t) {
t.plan(15);
/*
* Set up
*/
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.Grid('name', '/url',
{}, {isBaseLayer: true});
map.addLayer(layer);
function newTile(id) {
var t = new OpenLayers.Tile(layer,
new OpenLayers.Pixel(1, 1),
new OpenLayers.Bounds(1, 1, 1, 1));
t._id = id;
return t;
}
layer.grid = [
[newTile(1), newTile(2), newTile(3)],
[newTile(4), newTile(5)],
[newTile(6), newTile(7), newTile(8)]
];
// create a clone to be able to test whether
// tiles have been destroyed or not
var grid = [
layer.grid[0].slice(),
layer.grid[1].slice(),
layer.grid[2].slice()
];
/*
* Test
*/
layer.removeExcessTiles(2, 2);
t.eq(layer.grid.length, 2, 'grid has two rows');
t.eq(layer.grid[0].length, 2, 'row #1 has two columns');
t.eq(layer.grid[0][0]._id, 1, 'row #1 col #1 includes expected tile');
t.eq(layer.grid[0][1]._id, 2, 'row #1 col #2 includes expected tile');
t.eq(layer.grid[1].length, 2, 'row #2 has two columns');
t.eq(layer.grid[1][0]._id, 4, 'row #2 col #1 includes expected tile');
t.eq(layer.grid[1][1]._id, 5, 'row #2 col #2 includes expected tile');
t.ok(grid[0][0].events != null, 'tile 0,0 not destroyed');
t.ok(grid[0][1].events != null, 'tile 0,1 not destroyed');
t.ok(grid[0][2].events == null, 'tile 0,2 destroyed');
t.ok(grid[1][0].events != null, 'tile 1,0 not destroyed');
t.ok(grid[1][1].events != null, 'tile 1,1 not destroyed');
t.ok(grid[2][0].events == null, 'tile 2,0 destroyed');
t.ok(grid[2][1].events == null, 'tile 2,1 destroyed');
t.ok(grid[2][2].events == null, 'tile 2,2 destroyed');
/*
* Tear down
*/
map.destroy();
}
</script> </script>
</head> </head>
<body> <body>

View File

@@ -748,7 +748,7 @@
function test_Map_double_addLayer(t) { function test_Map_double_addLayer(t) {
t.plan(2); t.plan(2);
map = new OpenLayers.Map($('map')); map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.WMS('Test Layer', layer = new OpenLayers.Layer.WMS('Test Layer',
"http://octo.metacarta.com/cgi-bin/mapserv", "http://octo.metacarta.com/cgi-bin/mapserv",
{map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'} {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}
@@ -2047,7 +2047,7 @@
} }
function test_adjustZoom(t) { function test_adjustZoom(t) {
t.plan(4); t.plan(5);
var map = new OpenLayers.Map({ var map = new OpenLayers.Map({
div: 'map', div: 'map',
layers: [ layers: [
@@ -2063,6 +2063,9 @@
t.eq(map.adjustZoom(9), 9, "valid zoom maintained"); t.eq(map.adjustZoom(9), 9, "valid zoom maintained");
t.eq(map.adjustZoom(1), 2, "zoom adjusted to not exceed world width"); t.eq(map.adjustZoom(1), 2, "zoom adjusted to not exceed world width");
map.fractionalZoom = true;
t.eq(map.adjustZoom(1).toPrecision(3), "1.29", "zoom adjusted to match world width");
map.moveTo([16, 48], 0); map.moveTo([16, 48], 0);
t.eq(map.getCenter().toShortString(), "0, 0", "no panning when moveTo is called with invalid zoom"); t.eq(map.getCenter().toShortString(), "0, 0", "no panning when moveTo is called with invalid zoom");
} }

View File

@@ -114,7 +114,7 @@
} }
function test_Tile_Image_draw (t) { function test_Tile_Image_draw (t) {
t.plan(8); t.plan(7);
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');
@@ -139,16 +139,10 @@
//this should trigger a "loadstart" event //this should trigger a "loadstart" event
tile.draw(); tile.draw();
var img = tile.imgDiv;
if (!isMozilla) if (!isMozilla)
t.ok( true, "skipping element test outside of Mozilla"); t.ok( true, "skipping element test outside of Mozilla");
else else
t.ok( tile.imgDiv instanceof HTMLElement, "tile.draw creates an image"); t.ok( tile.imgDiv instanceof HTMLElement, "tile.draw creates an image");
if (!isMozilla)
t.ok( true, "skipping element test outside of Mozilla");
else
t.ok( img instanceof HTMLImageElement, "tile.draw creates an image");
var tParams = { var tParams = {
SERVICE: "WMS", VERSION: "1.1.1", SERVICE: "WMS", VERSION: "1.1.1",
REQUEST: "GetMap", STYLES: "", REQUEST: "GetMap", STYLES: "",
@@ -159,7 +153,7 @@
var expected = new Image(); var expected = new Image();
expected.src = "../../img/blank.gif?" + OpenLayers.Util.getParameterString(tParams) expected.src = "../../img/blank.gif?" + OpenLayers.Util.getParameterString(tParams)
t.delay_call(0.1, function() { t.delay_call(0.1, function() {
t.eq( img.src, expected.src, "tile.draw creates an image"); t.eq( tile.imgDiv.src, expected.src, "tile.draw creates an image");
}); });
t.eq( tile.imgDiv.style.width, "5%", "Image width is correct" ); t.eq( tile.imgDiv.style.width, "5%", "Image width is correct" );
t.eq( tile.imgDiv.style.height, "6%", "Image height is correct" ); t.eq( tile.imgDiv.style.height, "6%", "Image height is correct" );
@@ -178,7 +172,7 @@
var size = new OpenLayers.Size(5,6); var size = new OpenLayers.Size(5,6);
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"../../img/blank.gif", {layers: 'basic'}, {reproject:false, encodeBBOX: true}); "../../img/blank.gif", {layers: 'basic'}, {encodeBBOX: true});
map.addLayer(layer); map.addLayer(layer);
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size); tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size);
tile.draw() tile.draw()
@@ -266,14 +260,14 @@
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size); tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size);
tile.draw(); tile.draw();
tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true); tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true);
t.delay_call( 1, function() { t.eq(tile.imgDiv.style.visibility, "hidden", "Tile image is invisible.") } ); t.delay_call( 1, function() { t.ok(!tile.imgDiv, "Reference to tile image removed.") } );
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"../../img/blank.gif", {layers: 'basic'}, {'alpha':true}); "../../img/blank.gif", {layers: 'basic'}, {'alpha':true});
map.addLayer(layer); map.addLayer(layer);
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size); tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size);
tile.draw(); tile.draw();
tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true) tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true)
t.delay_call( 1, function() { t.eq(tile.imgDiv.style.visibility, "hidden", "Alpha tile image is invisible.") } ); t.delay_call( 1, function() { t.ok(!tile.imgDiv, "Reference to alpha tile image removed.") } );
} }

View File

@@ -1,10 +1,6 @@
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script>
var custom$ = function() {};
window.$ = custom$;
</script>
<script> <script>
var OpenLayers = [ var OpenLayers = [
"OpenLayers/BaseTypes/Class.js", "OpenLayers/BaseTypes/Class.js",
@@ -77,11 +73,6 @@
t.eq(OpenLayers.Util.isArray(testArray), true, "isArray works"); t.eq(OpenLayers.Util.isArray(testArray), true, "isArray works");
} }
function test_$(t) {
t.plan(1);
t.ok($ === custom$, "OpenLayers doesn't clobber existing definition of $.");
}
function test_Util_getImagesLocation (t) { function test_Util_getImagesLocation (t) {
t.plan( 1 ); t.plan( 1 );
t.ok( OpenLayers.Util.getImagesLocation(), "../img/", t.ok( OpenLayers.Util.getImagesLocation(), "../img/",

View File

@@ -0,0 +1,20 @@
<html>
<head>
<script>
var custom$ = function() {};
window.$ = custom$;
</script>
<script src="../OLLoader.js"></script>
<script src="../../lib/deprecated.js"></script>
<script>
function test_$(t) {
t.plan(1);
t.ok($ === custom$, "OpenLayers doesn't clobber existing definition of $.");
}
</script>
</head>
<body>
</body>
</html>

View File

@@ -49,6 +49,7 @@
<li>Control/PanPanel.html</li> <li>Control/PanPanel.html</li>
<li>Control/SLDSelect.html</li> <li>Control/SLDSelect.html</li>
<li>Control/Zoom.html</li> <li>Control/Zoom.html</li>
<li>Control/ZoomBox.html</li>
<li>Events.html</li> <li>Events.html</li>
<li>Events/buttonclick.html</li> <li>Events/buttonclick.html</li>
<li>Extras.html</li> <li>Extras.html</li>
@@ -231,6 +232,7 @@
<li>Kinetic.html</li> <li>Kinetic.html</li>
<li>Util.html</li> <li>Util.html</li>
<li>deprecated/Ajax.html</li> <li>deprecated/Ajax.html</li>
<li>deprecated/Util.html</li>
<li>deprecated/BaseTypes/Class.html</li> <li>deprecated/BaseTypes/Class.html</li>
<li>deprecated/BaseTypes/Element.html</li> <li>deprecated/BaseTypes/Element.html</li>
<li>deprecated/Control/MouseToolbar.html</li> <li>deprecated/Control/MouseToolbar.html</li>

View File

@@ -39,10 +39,64 @@ function run() {
else { else {
out.innerHTML += "<br/>height Fail: " + size + ", " + height; out.innerHTML += "<br/>height Fail: " + size + ", " + height;
} }
// To use the same syntax as in "\tests"
var t = {eq: function(a, b, msg) {
if (a == b) {
out.innerHTML += "<br/>ok " + msg;
}
else {
out.innerHTML += "<br/><span style=\"color:red\">Fail (" + a + " not eq " + b + "): " + msg + "<span>";
}
}
};
var text = (new Array(10)).join("foo foo foo <br>"),
content = "<div>" + text + "</div>";
var testName,
finalSize,
initialSize = OpenLayers.Util.getRenderedDimensions(content, null);
// containerElement option on absolute position with width and height
testName = "Absolute with w&h: ";
var optionAbsDiv ={
containerElement: document.getElementById("absoluteDiv")
};
finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv);
t.eq(finalSize.w, initialSize.w,
testName + "initial width " + initialSize.w + "px is maintained");
t.eq(finalSize.h, initialSize.h,
testName + "initial height " + initialSize.h + "px is maintained");
testName = "Absolute with w&h (set height): ";
finalSize = OpenLayers.Util.getRenderedDimensions(content, {h: 15}, optionAbsDiv);
t.eq(finalSize.h, 15, testName + "got the fixed height to 15px");
t.eq(finalSize.w, initialSize.w,
testName + "initial width " + initialSize.w + "px is maintained");
testName = "Absolute with w&h (set width): ";
finalSize = OpenLayers.Util.getRenderedDimensions(content, {w: 20}, optionAbsDiv);
t.eq(finalSize.w, 20, testName + "got the fixed width to 20px");
// containerElement option on absolute position without width and height
testName = "Absolute without w&h: ";
var optionAbsDiv00 ={
containerElement: document.getElementById("absoluteDiv00")
};
finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv00);
t.eq(finalSize.w, initialSize.w,
testName + "initial width " + initialSize.w + "px is maintained");
t.eq(finalSize.h, initialSize.h,
testName + "initial height " + initialSize.h + "px is maintained");
testName = "Absolute without w&h (set height): ";
finalSize = OpenLayers.Util.getRenderedDimensions(content, {h: 15}, optionAbsDiv00);
t.eq(finalSize.h, 15, testName + "got the fixed height to 15px");
t.eq(finalSize.w, initialSize.w,
testName + "initial width " + initialSize.w + "px is maintained");
testName = "Absolute without w&h (set width): ";
finalSize = OpenLayers.Util.getRenderedDimensions(content, {w: 20}, optionAbsDiv00);
t.eq(finalSize.w, 20, testName + "got the fixed width to 20px");
} }
</script> </script>
</head> </head>
<body onload="run()"> <body onload="run()">
<div id="out"></div> <div id="out"></div>
<div id="absoluteDiv" style="position:absolute; left:10px; width:500px; height: 500px"></div>
<div id="absoluteDiv00" style="position:absolute; left:10px;"></div>
</body> </body>
</html> </html>

View File

@@ -49,3 +49,15 @@ div.olControlZoom a:hover {
-o-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear; transition: opacity 0.2s linear;
} }
/* Enable 3d acceleration when operating on tiles, this is
known to yield better performance on IOS Safari.
http://osgeo-org.1803224.n2.nabble.com/Harware-accelerated-CSS3-animations-for-iOS-td6255560.html
It also prevents tile blinking effects in iOS 5.
See https://github.com/openlayers/openlayers/issues/511
*/
@media (-webkit-transform-3d) {
img.olTileImage {
-webkit-transform: translate3d(0, 0, 0);
}
}

View File

@@ -1,5 +1,28 @@
#!/bin/sh #!/bin/sh
#
#
# Usage:
# $ ./release.sh <release_number>
#
# Example:
# $ ./release.sh 2.12-rc7
#
# This script should be run on the www.openlayers.org server.
#
# What the script does:
#
# 1. Download release tarball from from GitHub.
# 2. Create builds using the Closure Compiler.
# 3. Run the exampleparser.py script to create the examples index.
# 4. Run csstidy for each CSS file in theme/default.
# 5. Publish builds and resources on api.openlayers.org.
# 6. Build the API docs.
# 7. Create release archives
# 8. Make the release archives available on openlayers.org/downloads.
#
#
VERSION=$1 VERSION=$1
wget -c http://closure-compiler.googlecode.com/files/compiler-latest.zip wget -c http://closure-compiler.googlecode.com/files/compiler-latest.zip
@@ -17,20 +40,21 @@ mv ../../compiler.jar ../tools/closure-compiler.jar
./build.py -c none full OpenLayers.debug.js ./build.py -c none full OpenLayers.debug.js
./build.py -c none mobile OpenLayers.mobile.debug.js ./build.py -c none mobile OpenLayers.mobile.debug.js
./build.py -c none light OpenLayers.light.debug.js ./build.py -c none light OpenLayers.light.debug.js
cp OpenLayers.js .. mv OpenLayers*.js ../
cp OpenLayers.*.js .. rm -rf closure-compiler
rm closure*.py
rm ../tools/closure-compiler.jar rm ../tools/closure-compiler.jar
cd .. cd ..
cd tools cd tools
python exampleparser.py python exampleparser.py
cd .. cd ..
for i in google ie6-style style; do for i in google ie6-style style style.mobile; do
csstidy theme/default/$i.css --template=highest theme/default/$i.tidy.css csstidy theme/default/$i.css --template=highest theme/default/$i.tidy.css
done done
mkdir doc/devdocs mkdir -p doc/devdocs
mkdir doc/apidocs mkdir -p doc/apidocs
rm tools/*.pyc rm tools/*.pyc
mkdir -p /osgeo/openlayers/sites/openlayers.org/api/$VERSION mkdir -p /osgeo/openlayers/sites/openlayers.org/api/$VERSION

View File

@@ -3,10 +3,10 @@
# check to see if the hosted examples or API docs need an update # check to see if the hosted examples or API docs need an update
cd /osgeo/openlayers/repos/openlayers cd /osgeo/openlayers/repos/openlayers
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/openlayers/ | grep HEAD | awk '{print $1}'` REMOTE_HEAD=`git ls-remote https://github.com/openlayers/openlayers/ | grep HEAD | awk '{print $1}'`
OLD_REMOTE_HEAD=`git rev-parse HEAD` LOCAL_HEAD=`git rev-parse HEAD`
# if there's something different in the remote, update and build # if there's something different in the remote, update and build
if [ ! o$REMOTE_HEAD = o$OLD_REMOTE_HEAD ]; then if [ ! o$REMOTE_HEAD = o$LOCAL_HEAD ]; then
git checkout master git checkout master
git clean -f git clean -f
@@ -54,10 +54,10 @@ fi
# check to see if the website needs an update # check to see if the website needs an update
cd /osgeo/openlayers/repos/website cd /osgeo/openlayers/repos/website
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/website/ | grep HEAD | awk '{print $1}'` REMOTE_HEAD=`git ls-remote https://github.com/openlayers/website/ | grep HEAD | awk '{print $1}'`
OLD_REMOTE_HEAD=`git rev-parse HEAD` LOCAL_HEAD=`git rev-parse HEAD`
# if there's something different in the remote, update the clone # if there's something different in the remote, update the clone
if [ ! o$REMOTE_HEAD = o$OLD_REMOTE_HEAD ]; then if [ ! o$REMOTE_HEAD = o$LOCAL_HEAD ]; then
git checkout master git checkout master
git clean -f git clean -f
@@ -72,19 +72,17 @@ fi
# check to see if prose docs need an update # check to see if prose docs need an update
cd /osgeo/openlayers/repos/docs cd /osgeo/openlayers/repos/docs
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/docs/ | grep HEAD | awk '{print $1}'` REMOTE_HEAD=`git ls-remote https://github.com/openlayers/docs/ | grep HEAD | awk '{print $1}'`
OLD_REMOTE_HEAD=`git rev-parse HEAD` LOCAL_HEAD=`git rev-parse HEAD`
# if there's something different in the remote, update the clone # if there's something different in the remote, update the clone
if [ ! o$REMOTE_HEAD = o$OLD_REMOTE_HEAD ]; then if [ ! o$REMOTE_HEAD = o$LOCAL_HEAD ]; then
git checkout master git checkout master
git clean -f git clean -f
git pull origin master git pull origin master
mkdir -p /tmp/ol/docs/build/html /tmp/ol/docs/build/doctrees mkdir -p /osgeo/openlayers/sites/docs.openlayers.org /tmp/ol/docs/build/doctrees
sphinx-build -b html -d /tmp/ol/docs/build/doctrees . /tmp/ol/docs/build/html sphinx-build -b html -d /tmp/ol/docs/build/doctrees . /osgeo/openlayers/sites/docs.openlayers.org
rsync -r --delete /tmp/ol/docs/build/html/ /osgeo/openlayers/sites/docs.openlayers.org
fi fi
@@ -102,11 +100,4 @@ if [ ! o$SVNREV = $OLD_SVNREV ]; then
svn up /osgeo/openlayers/repos/old_svn_repo/ svn up /osgeo/openlayers/repos/old_svn_repo/
# Record the revision # Record the revision
echo -n $SVNREV > /tmp/ol_svn_rev echo -n $SVNREV > /tmp/ol_svn_rev
# update the hosted sandboxes
rsync -r --delete --exclude=.svn --delete-excluded /osgeo/openlayers/repos/old_svn_repo/sandbox /osgeo/openlayers/sites/dev.openlayers.org/
# update the hosted addins
rsync -r --delete --exclude=.svn --delete-excluded /osgeo/openlayers/repos/old_svn_repo/addins /osgeo/openlayers/sites/dev.openlayers.org/
fi fi