Compare commits

...

14 Commits

Author SHA1 Message Date
crschmidt
38813af5e3 Tagging the 2.11 release.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.11@12355 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-09-11 15:16:28 +00:00
crschmidt
685a756843 Updating version numbers for 2.11.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12354 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-09-11 15:16:26 +00:00
crschmidt
e6b65519bc Merge a fix for tests (Closes #3449)
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12353 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-09-11 15:14:28 +00:00
crschmidt
6dd8ee7400 Accidentally set build script to python2.6, revervt.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12322 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-09-03 15:46:01 +00:00
crschmidt
c36c896601 Updating version numbers for 2.11-rc4.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12320 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-09-03 15:40:52 +00:00
crschmidt
d29b14d3e5 Pullup changes to Google Layers for OL 2.11 RC4:
Google base layer not showing when switching base layers (Closes #3475)
  remove GoogleNG layer (Closes #3481)


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12319 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-09-03 15:37:48 +00:00
crschmidt
e89633fd52 Updating version numbers for 2.11-rc3.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12275 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-24 23:36:06 +00:00
crschmidt
c867627c78 Pulling in patches for OL 2.11 RC3:
* ArcGISCache resolutions get compromised by some JS frameworks. (Closes #3474)
 * OpenLayers.Layer.HTTPRequest initialize simplification (Closes #3470)
 * missing requires (Closes #3467)
 * deleting a vertex does not update feature.modified (Closes #3463)
 * fixing test failure in some browsers (Closes #3461)
 * a grid layer may be moved while its grid hasn't been initialized yet (Closes #3458) -- this one is the actual release blocker
 * Change the callback function of Protocol.Script (JSONP) (Closes #3417)
 * "build.py -c closure" does not work on Windows systems. (Closes #3158)


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12274 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-24 23:32:34 +00:00
ahocevar
061eeacf92 reverting r12185 from #3431
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12232 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-10 08:41:37 +00:00
crschmidt
78c2e7767b Updating version numbers for 2.11-rc2.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12223 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-08 14:14:11 +00:00
crschmidt
911393123e Branching for the 2.11 release
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12222 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-08 14:13:46 +00:00
crschmidt
fcd2a62fa3 Branching for the 2.11 release
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12220 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-08 14:05:07 +00:00
crschmidt
9a3db8c5b7 Updating version numbers for 2.11-rc1.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@11996 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-05-23 14:33:54 +00:00
crschmidt
e846551c2c Branching for the 2.11 release
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@11995 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-05-23 14:25:10 +00:00
34 changed files with 309 additions and 830 deletions

View File

@@ -352,7 +352,6 @@ Group: OpenLayers {
File: GML (no auto-title, OpenLayers/Layer/GML.js) File: GML (no auto-title, OpenLayers/Layer/GML.js)
File: Google (no auto-title, OpenLayers/Layer/Google.js) File: Google (no auto-title, OpenLayers/Layer/Google.js)
File: Google.v3 (no auto-title, OpenLayers/Layer/Google/v3.js) File: Google.v3 (no auto-title, OpenLayers/Layer/Google/v3.js)
File: GoogleNG (no auto-title, OpenLayers/Layer/GoogleNG.js)
File: Grid (no auto-title, OpenLayers/Layer/Grid.js) File: Grid (no auto-title, OpenLayers/Layer/Grid.js)
File: HTTPRequest (no auto-title, OpenLayers/Layer/HTTPRequest.js) File: HTTPRequest (no auto-title, OpenLayers/Layer/HTTPRequest.js)
File: Image (no auto-title, OpenLayers/Layer/Image.js) File: Image (no auto-title, OpenLayers/Layer/Image.js)
@@ -475,7 +474,6 @@ Group: OpenLayers {
Group: Tile { Group: Tile {
File: Tile (no auto-title, OpenLayers/Tile.js) File: Tile (no auto-title, OpenLayers/Tile.js)
File: Google (no auto-title, OpenLayers/Tile/Google.js)
File: Image (no auto-title, OpenLayers/Tile/Image.js) File: Image (no auto-title, OpenLayers/Tile/Image.js)
File: Image.IFrame (no auto-title, OpenLayers/Tile/Image/IFrame.js) File: Image.IFrame (no auto-title, OpenLayers/Tile/Image/IFrame.js)
File: WFS (no auto-title, OpenLayers/Tile/WFS.js) File: WFS (no auto-title, OpenLayers/Tile/WFS.js)

View File

@@ -352,7 +352,6 @@ Group: OpenLayers {
File: GML (no auto-title, OpenLayers/Layer/GML.js) File: GML (no auto-title, OpenLayers/Layer/GML.js)
File: Google (no auto-title, OpenLayers/Layer/Google.js) File: Google (no auto-title, OpenLayers/Layer/Google.js)
File: Google.v3 (no auto-title, OpenLayers/Layer/Google/v3.js) File: Google.v3 (no auto-title, OpenLayers/Layer/Google/v3.js)
File: GoogleNG (no auto-title, OpenLayers/Layer/GoogleNG.js)
File: Grid (no auto-title, OpenLayers/Layer/Grid.js) File: Grid (no auto-title, OpenLayers/Layer/Grid.js)
File: HTTPRequest (no auto-title, OpenLayers/Layer/HTTPRequest.js) File: HTTPRequest (no auto-title, OpenLayers/Layer/HTTPRequest.js)
File: Image (no auto-title, OpenLayers/Layer/Image.js) File: Image (no auto-title, OpenLayers/Layer/Image.js)
@@ -475,7 +474,6 @@ Group: OpenLayers {
Group: Tile { Group: Tile {
File: Tile (no auto-title, OpenLayers/Tile.js) File: Tile (no auto-title, OpenLayers/Tile.js)
File: Google (no auto-title, OpenLayers/Tile/Google.js)
File: Image (no auto-title, OpenLayers/Tile/Image.js) File: Image (no auto-title, OpenLayers/Tile/Image.js)
File: Image.IFrame (no auto-title, OpenLayers/Tile/Image/IFrame.js) File: Image.IFrame (no auto-title, OpenLayers/Tile/Image/IFrame.js)
File: WFS (no auto-title, OpenLayers/Tile/WFS.js) File: WFS (no auto-title, OpenLayers/Tile/WFS.js)

View File

@@ -1,45 +0,0 @@
<!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 Google NG Layer Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
.olControlAttribution {
left: 2px;
right: inherit;
bottom: 3px;
line-height: 11px;
font-family: Arial, sans-serif;
}
</style>
<script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
<script src="../lib/OpenLayers.js"></script>
<script src="google-ng.js"></script>
</head>
<body onload="init()">
<h1 id="title">Google NG Layer Example</h1>
<div id="tags">
Google, api key, apikey
</div>
<p id="shortdesc">
Demonstrate use of tiles from the Google Maps v3 API.
</p>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>
If you use OpenLayers.Layer.GoogleNG, the getTile method of the
GMaps v3 API's MapType is used to load tiles. This allows for
better integration than interacting with a whole map generated
by a google.maps.Map instance, as done with
OpenLayers.Layer.Google. See the
<a href="google-ng.js" target="_blank">google-ng.js source</a>
to see how this is done.
</p>
</div>
</body>
</html>

View File

@@ -1,28 +0,0 @@
var map;
function init() {
map = new OpenLayers.Map('map');
map.addControl(new OpenLayers.Control.LayerSwitcher());
var gphy = new OpenLayers.Layer.GoogleNG(
{type: google.maps.MapTypeId.TERRAIN}
);
var gmap = new OpenLayers.Layer.GoogleNG(
// ROADMAP, the default
);
var ghyb = new OpenLayers.Layer.GoogleNG(
{type: google.maps.MapTypeId.HYBRID}
);
var gsat = new OpenLayers.Layer.GoogleNG(
{type: google.maps.MapTypeId.SATELLITE}
);
map.addLayers([gphy, gmap, ghyb, gsat]);
// GoogleNG uses EPSG:900913 as projection, so we have to
// transform our coordinates
map.setCenter(new OpenLayers.LonLat(10.2, 48.9).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 5);
}

View File

@@ -121,7 +121,6 @@
"OpenLayers/Marker/Box.js", "OpenLayers/Marker/Box.js",
"OpenLayers/Popup.js", "OpenLayers/Popup.js",
"OpenLayers/Tile.js", "OpenLayers/Tile.js",
"OpenLayers/Tile/Google.js",
"OpenLayers/Tile/Image.js", "OpenLayers/Tile/Image.js",
"OpenLayers/Tile/Image/IFrame.js", "OpenLayers/Tile/Image/IFrame.js",
"OpenLayers/Tile/WFS.js", "OpenLayers/Tile/WFS.js",
@@ -154,7 +153,6 @@
"OpenLayers/Layer/Boxes.js", "OpenLayers/Layer/Boxes.js",
"OpenLayers/Layer/XYZ.js", "OpenLayers/Layer/XYZ.js",
"OpenLayers/Layer/Bing.js", "OpenLayers/Layer/Bing.js",
"OpenLayers/Layer/GoogleNG.js",
"OpenLayers/Layer/TMS.js", "OpenLayers/Layer/TMS.js",
"OpenLayers/Layer/TileCache.js", "OpenLayers/Layer/TileCache.js",
"OpenLayers/Layer/Zoomify.js", "OpenLayers/Layer/Zoomify.js",
@@ -383,4 +381,4 @@
/** /**
* Constant: VERSION_NUMBER * Constant: VERSION_NUMBER
*/ */
OpenLayers.VERSION_NUMBER="$Revision$"; OpenLayers.VERSION_NUMBER="Release 2.11";

View File

@@ -633,6 +633,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
this.layer.drawFeature(this.feature, this.standalone ? this.layer.drawFeature(this.feature, this.standalone ?
undefined : undefined :
this.selectControl.renderIntent); this.selectControl.renderIntent);
this.modified = true;
this.resetVertices(); this.resetVertices();
this.setFeatureState(); this.setFeatureState();
this.onModification(this.feature); this.onModification(this.feature);

View File

@@ -5,6 +5,7 @@
/** /**
* @requires OpenLayers/Format/XML.js * @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/OWSCommon/v1_1_0.js
*/ */
/** /**

View File

@@ -349,11 +349,6 @@ OpenLayers.Layer = OpenLayers.Class({
this.div.style.width = "100%"; this.div.style.width = "100%";
this.div.style.height = "100%"; this.div.style.height = "100%";
this.div.dir = "ltr"; this.div.dir = "ltr";
if (this.opacity != null) {
OpenLayers.Util.modifyDOMElement(
this.div, null, null, null, null, null, null, this.opacity
);
}
this.events = new OpenLayers.Events(this, this.div, this.events = new OpenLayers.Events(this, this.div,
this.EVENT_TYPES); this.EVENT_TYPES);
@@ -1274,8 +1269,11 @@ OpenLayers.Layer = OpenLayers.Class({
setOpacity: function(opacity) { setOpacity: function(opacity) {
if (opacity != this.opacity) { if (opacity != this.opacity) {
this.opacity = opacity; this.opacity = opacity;
OpenLayers.Util.modifyDOMElement(this.div, null, null, null, for(var i=0, len=this.div.childNodes.length; i<len; ++i) {
null, null, null, opacity); var element = this.div.childNodes[i].firstChild;
OpenLayers.Util.modifyDOMElement(element, null, null, null,
null, null, null, opacity);
}
if (this.map != null) { if (this.map != null) {
this.map.events.triggerEvent("changelayer", { this.map.events.triggerEvent("changelayer", {
layer: this, layer: this,

View File

@@ -172,21 +172,23 @@ OpenLayers.Layer.ArcGISCache = OpenLayers.Class(OpenLayers.Layer.XYZ, {
this.lods = []; this.lods = [];
for(var key in info.tileInfo.lods) { for(var key in info.tileInfo.lods) {
var lod = info.tileInfo.lods[key]; if (info.tileInfo.lods.hasOwnProperty(key)) {
if (this.useScales) { var lod = info.tileInfo.lods[key];
this.scales.push(lod.scale); if (this.useScales) {
} else { this.scales.push(lod.scale);
this.resolutions.push(lod.resolution); } else {
this.resolutions.push(lod.resolution);
}
var start = this.getContainingTileCoords(upperLeft, lod.resolution);
lod.startTileCol = start.x;
lod.startTileRow = start.y;
var end = this.getContainingTileCoords(bottomRight, lod.resolution);
lod.endTileCol = end.x;
lod.endTileRow = end.y;
this.lods.push(lod);
} }
var start = this.getContainingTileCoords(upperLeft, lod.resolution);
lod.startTileCol = start.x;
lod.startTileRow = start.y;
var end = this.getContainingTileCoords(bottomRight, lod.resolution);
lod.endTileCol = end.x;
lod.endTileRow = end.y;
this.lods.push(lod);
} }
this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]); this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]);

View File

@@ -203,7 +203,7 @@ OpenLayers.Layer.Google.v3 = {
*/ */
setGMapVisibility: function(visible) { setGMapVisibility: function(visible) {
var cache = OpenLayers.Layer.Google.cache[this.map.id]; var cache = OpenLayers.Layer.Google.cache[this.map.id];
if (cache && !cache.resized) { if (cache) {
var type = this.type; var type = this.type;
var layers = this.map.layers; var layers = this.map.layers;
var layer; var layer;

View File

@@ -1,336 +0,0 @@
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Layer/XYZ.js
* @requires OpenLayers/Tile/Google.js
* @requires OpenLayers/Layer/SphericalMercator.js
*/
/**
* Class: OpenLayers.Layer.GoogleNG
* Google layer using <OpenLayers.Tile.Google> tiles.
*
* Inherits from:
* - <OpenLayers.Layer.XYZ>
*/
OpenLayers.Layer.GoogleNG = OpenLayers.Class(OpenLayers.Layer.XYZ, {
/**
* Property: SUPPORTED_TRANSITIONS
* {Array} An immutable (that means don't change it!) list of supported
* transitionEffect values. This layer type supports none.
*/
SUPPORTED_TRANSITIONS: [],
/**
* Property: serverResolutions
* {Array} the resolutions provided by the Google API.
*/
serverResolutions: [
156543.03390625, 78271.516953125, 39135.7584765625,
19567.87923828125, 9783.939619140625, 4891.9698095703125,
2445.9849047851562, 1222.9924523925781, 611.4962261962891,
305.74811309814453, 152.87405654907226, 76.43702827453613,
38.218514137268066, 19.109257068634033, 9.554628534317017,
4.777314267158508, 2.388657133579254, 1.194328566789627,
0.5971642833948135, 0.29858214169740677, 0.14929107084870338,
0.07464553542435169, 0.037322767712175846
],
/**
* Property: attributionTemplate
* {String}
*/
attributionTemplate: '<span class="olGoogleAttribution ${mapType}">' +
'<div><a title="Click to see this area on Google Maps" ' +
'target="_blank" href="http://maps.google.com/maps?' +
'll=${center}&z=${zoom}&t=${t}"><img width="62" height="24" ' +
'src="http://maps.gstatic.com/mapfiles/google_white.png"/></a>' +
'</div>${mapData}<a style="white-space: nowrap" target="_blank" ' +
'href="http://www.google.com/help/terms_maps.html">' +
'Terms of Use</a></span>',
/**
* Property: mapTypes
* {Object} mapping of {google.maps.MapTypeId} to the t param of
* http://maps.google.com/maps? permalinks
*/
mapTypes: {
"roadmap": "m",
"satellite": "k",
"hybrid": "h",
"terrain": "p"
},
/**
* APIProperty: type
* {google.maps.MapTypeId} See
* http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeId
*/
type: null,
/**
* Constructor: OpenLayers.Layer.GoogleNG
* Create a new GoogleNG layer. Requires the GMaps v3 JavaScript API script
* (http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false) loaded in
* the html document. Note: Terms of Service compliant use requires the map
* to be configured with an <OpenLayers.Control.Attribution> control and
* the attribution placed on the map.
*
* Example:
* (code)
* var terrain = new OpenLayers.Layer.GoogleNG({
* name: "Google Terrain",
* type: google.maps.MapTypeId.TERRAIN
* });
* (end)
*
* Parameters:
* options - {Object} Configuration properties for the layer.
*
* Required configuration properties:
* type - {google.maps.MapTypeId} The layer identifier. See
* http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeId
* for valid types.
*
* Any other documented layer properties can be provided in the config object.
*/
initialize: function(options) {
options = OpenLayers.Util.applyDefaults({
sphericalMercator: true
}, options);
if (!options.type) {
options.type = google.maps.MapTypeId.ROADMAP;
}
var newArgs = [options.name, null, options];
OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArgs);
if (!OpenLayers.Layer.GoogleNG.mapObject) {
OpenLayers.Layer.GoogleNG.mapObject =
new google.maps.Map(document.createElement("div"));
}
if (OpenLayers.Layer.GoogleNG.mapObject.mapTypes[this.type]) {
this.initLayer();
} else {
google.maps.event.addListenerOnce(
OpenLayers.Layer.GoogleNG.mapObject,
"idle",
OpenLayers.Function.bind(this.initLayer, this)
);
}
},
/**
* Method: initLayer
*
* Sets layer properties according to the metadata provided by the API
*/
initLayer: function() {
var mapType = OpenLayers.Layer.GoogleNG.mapObject.mapTypes[this.type];
if (!this.name) {
this.setName("Google " + mapType.name);
}
var minZoom = mapType.minZoom || 0;
this.addOptions({
maxResolution: Math.min(
this.serverResolutions[minZoom], this.maxResolution
),
zoomOffset: minZoom,
numZoomLevels: Math.min(
mapType.maxZoom + 1 - minZoom, this.numZoomLevels
)
}, true);
},
/**
* Method: addTile
* Create a tile, initialize it, and add it to the layer div.
*
* Parameters
* bounds - {<OpenLayers.Bounds>}
* position - {<OpenLayers.Pixel>}
*
* Returns:
* {<OpenLayers.Tile.Google>} The added OpenLayers.Tile.Google
*/
addTile:function(bounds, position) {
return new OpenLayers.Tile.Google(
this, position, bounds, this.tileOptions
);
},
/**
* Method: updateAttribution
* Updates the attribution using the <attributionTemplate>
*
* Parameters:
* copyrights - {Object} Object with "m", "k", "h" and "p" properties (see
* <mapTypes>), each holding an array of copyrights.
*/
updateAttribution: function(copyrights) {
var myCopyrights;
if (this.type == google.maps.MapTypeId.HYBRID) {
// the Copyright Service returns "k" and "m" copyrights for the
// HYBRID layer type.
var candidates = [].concat(
copyrights["h"], copyrights["k"], copyrights["m"]
);
myCopyrights = [];
for (var i=candidates.length-1; i>=0; --i) {
if (OpenLayers.Util.indexOf(candidates, myCopyrights) == -1) {
myCopyrights.push(candidates[i]);
}
}
} else {
myCopyrights = copyrights[this.mapTypes[this.type]];
}
var mapData = myCopyrights.length == 0 ? "" :
"Map Data &copy;" + new Date().getFullYear() + " " +
myCopyrights.join(", ") + " - ";
var center = this.map.getCenter();
center && center.transform(
this.map.getProjectionObject(),
new OpenLayers.Projection("EPSG:4326")
);
var size = this.map.getSize();
this.attribution = OpenLayers.String.format(this.attributionTemplate, {
t: this.mapTypes[this.type],
zoom: this.map.getZoom(),
center: center.lat + "," + center.lon,
mapType: this.type,
mapData: mapData
});
this.map && this.map.events.triggerEvent("changelayer", {
layer: this,
property: "attribution"
});
},
/**
* Method: setMap
*/
setMap: function() {
OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments);
this.events.register("moveend", this,
OpenLayers.Layer.GoogleNG.loadCopyrights
);
},
/**
* Method: removeMap
*/
removeMap: function() {
OpenLayers.Layer.XYZ.prototype.removeMap.apply(this, arguments);
this.events.unregister("moveend", this,
OpenLayers.Layer.GoogleNG.loadCopyrights
);
},
/**
* APIMethod: clone
*
* Parameters:
* obj - {Object}
*
* Returns:
* {<OpenLayers.Layer.GoogleNG>} An exact clone of this
* <OpenLayers.Layer.GoogleNG>
*/
clone: function(obj) {
if (obj == null) {
obj = new OpenLayers.Layer.GoogleNG(this.options);
}
//get all additions from superclasses
obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);
// copy/set any non-init, non-simple values here
return obj;
},
CLASS_NAME: "OpenLayers.Layer.GoogleNG"
});
/**
* Property: mapObject
* {google.maps.Map} Shared GMaps instance - will be set upon instantiation of
* the 1st GoogleNG layer
*/
OpenLayers.Layer.GoogleNG.mapObject = null;
/**
* Function: loadCopyrights
* Using the Google Maps Copyright Service mode (see
* http://mapki.com/wiki/Google_Map_Parameters#Misc) to get the attribution for
* the current map extent. Will be called by each GoogleNG layer instance on
* moveend.
*/
OpenLayers.Layer.GoogleNG.loadCopyrights = function() {
var me = OpenLayers.Layer.GoogleNG.loadCopyrights;
if (me.numLoadingScripts == undefined) {
me.loadingScripts = [];
me.numLoadingScripts = 0;
me.copyrights = {"m": [], "k": [], "h": [], "p": []};
// store window scope functions before overwriting them
me.origGAddCopyright = window.GAddCopyright;
me.origGVerify = window.GVerify;
me.origGAppFeatures = window.GAppFeatures;
// defining window scope functions called by the script that the
// Copyright Service returns
window.GAddCopyright = function() {
var copyright = arguments[7];
var category = me.copyrights[arguments[0]];
if (OpenLayers.Util.indexOf(category, copyright) == -1) {
copyright && category.push(copyright);
}
};
window.GVerify = OpenLayers.Function.True;
window.GAppFeatures = OpenLayers.Function.bind(function() {
me.numLoadingScripts--;
if (me.numLoadingScripts == 0) {
var script;
for (var i=me.loadingScripts.length-1; i>=0; --i) {
script = me.loadingScripts[i][0];
me.loadingScripts[i][1].updateAttribution(me.copyrights);
script.parentNode.removeChild(script);
}
// restore original functions
window.GAddCopyright = me.origGAddCopyright;
delete me.origGAddCopyright;
window.GVerify = me.origGVerify;
delete me.origGVerify;
window.GAppFeatures = me.origGAppFeatures;
delete me.origGAppFeatures;
delete me.loadingScripts;
delete me.numLoadingScripts;
delete me.copyrights;
}
}, this);
}
var mapProj = this.map.getProjectionObject();
var llProj = new OpenLayers.Projection("EPSG:4326");
var center = this.map.getCenter().transform(mapProj, llProj);
var extent = this.map.getExtent().transform(mapProj, llProj);
var params = {
spn: extent.getHeight() + "," + extent.getWidth(),
z: this.map.getZoom(),
t: this.mapTypes[this.type],
vp: center.lat + "," + center.lon
};
var url = "http://maps.google.com/maps?" +
OpenLayers.Util.getParameterString(params);
var script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
me.numLoadingScripts++;
me.loadingScripts.push([script, this]);
document.getElementsByTagName("head")[0].appendChild(script);
};

View File

@@ -58,9 +58,7 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
* options - {Object} Hashtable of extra options to tag onto the layer * options - {Object} Hashtable of extra options to tag onto the layer
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = arguments; OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
newArguments = [name, options];
OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
this.url = url; this.url = url;
this.params = OpenLayers.Util.extend( {}, params); this.params = OpenLayers.Util.extend( {}, params);
}, },

View File

@@ -60,6 +60,22 @@ OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer, {
OpenLayers.Layer.prototype.destroy.apply(this, arguments); OpenLayers.Layer.prototype.destroy.apply(this, arguments);
}, },
/**
* APIMethod: setOpacity
* Sets the opacity for all the markers.
*
* Parameter:
* opacity - {Float}
*/
setOpacity: function(opacity) {
if (opacity != this.opacity) {
this.opacity = opacity;
for (var i=0, len=this.markers.length; i<len; i++) {
this.markers[i].setOpacity(this.opacity);
}
}
},
/** /**
* Method: moveTo * Method: moveTo
* *

View File

@@ -590,5 +590,21 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
return extent; return extent;
}, },
/**
* APIMethod: setOpacity
* Call the setOpacity method of the appropriate parent class to set the
* opacity.
*
* Parameter:
* opacity - {Float}
*/
setOpacity: function (opacity) {
if (this.vectorMode) {
OpenLayers.Layer.Vector.prototype.setOpacity.apply(this, [opacity]);
} else {
OpenLayers.Layer.Markers.prototype.setOpacity.apply(this, [opacity]);
}
},
CLASS_NAME: "OpenLayers.Layer.WFS" CLASS_NAME: "OpenLayers.Layer.WFS"
}); });

View File

@@ -1722,7 +1722,8 @@ OpenLayers.Map = OpenLayers.Class({
var layer, i, len; var layer, i, len;
for (i=0, len=this.layers.length; i<len; ++i) { for (i=0, len=this.layers.length; i<len; ++i) {
layer = this.layers[i]; layer = this.layers[i];
if (layer.visibility) { if (layer.visibility &&
(layer === this.baseLayer || layer.inRange)) {
layer.moveByPx(dx, dy); layer.moveByPx(dx, dy);
layer.events.triggerEvent("move"); layer.events.triggerEvent("move");
} }

View File

@@ -207,7 +207,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
*/ */
createRequest: function(url, params, callback) { createRequest: function(url, params, callback) {
var id = OpenLayers.Protocol.Script.register(callback); var id = OpenLayers.Protocol.Script.register(callback);
var name = "OpenLayers.Protocol.Script.getCallback(" + id + ")"; var name = "OpenLayers.Protocol.Script.registry[" + id + "]";
params = OpenLayers.Util.extend({}, params); params = OpenLayers.Util.extend({}, params);
params[this.callbackKey] = this.callbackPrefix + name; params[this.callbackKey] = this.callbackPrefix + name;
url = OpenLayers.Util.urlAppend( url = OpenLayers.Util.urlAppend(
@@ -328,7 +328,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
(function() { (function() {
var o = OpenLayers.Protocol.Script; var o = OpenLayers.Protocol.Script;
var counter = 0; var counter = 0;
var registry = {}; o.registry = [];
/** /**
* Function: OpenLayers.Protocol.Script.register * Function: OpenLayers.Protocol.Script.register
@@ -344,7 +344,10 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
*/ */
o.register = function(callback) { o.register = function(callback) {
var id = ++counter; var id = ++counter;
registry[id] = callback; o.registry[id] = function() {
o.unregister(id);
callback.apply(this, arguments);
};
return id; return id;
}; };
@@ -356,22 +359,6 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
* id: {Number} The identifer returned by the register function. * id: {Number} The identifer returned by the register function.
*/ */
o.unregister = function(id) { o.unregister = function(id) {
delete registry[id]; delete o.registry[id];
};
/**
* Function: OpenLayers.Protocol.Script.getCallback
* Retreive and unregister a callback. A call to this function is the "P"
* in JSONP. For example, a script may be added with a src attribute
* http://example.com/features.json?callback=OpenLayers.Protocol.Script.getCallback(1)
*
* Parameters:
* id: {Number} The identifer returned by the register function.
*/
o.getCallback = function(id) {
var callback = registry[id];
o.unregister(id);
return callback;
}; };
})(); })();

View File

@@ -7,7 +7,7 @@ var OpenLayers = {
/** /**
* Constant: VERSION_NUMBER * Constant: VERSION_NUMBER
*/ */
VERSION_NUMBER: "$Revision$", VERSION_NUMBER: "Release 2.11",
/** /**
* Constant: singleFile * Constant: singleFile

View File

@@ -1,154 +0,0 @@
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/BaseTypes/Class.js
* @requires OpenLayers/Util.js
* @requires OpenLayers/Tile.js
*/
/*
* Class: OpenLayers.Tile.Google
* Instances of OpenLayers.Tile.Google are used to manage the tiles created
* by google.maps.MapType (see
* http://code.google.com/apis/maps/documentation/javascript/reference.html#MapType).
*
* Inherits from:
* - <OpenLayers.Tile>
*/
OpenLayers.Tile.Google = OpenLayers.Class(OpenLayers.Tile, {
/**
* Property: node
* {DOMElement} The tile node from the MapType's getTile method
*/
node: null,
/**
* Constructor: OpenLayers.Tile.Google
* Constructor for a new <OpenLayers.Tile.Google> instance.
*
* Parameters:
* layer - {<OpenLayers.Layer>} layer that the tile will go in.
* position - {<OpenLayers.Pixel>}
* bounds - {<OpenLayers.Bounds>}
* options - {Object}
*/
initialize: function(layer, position, bounds, options) {
OpenLayers.Tile.prototype.initialize.apply(this, [
layer, position, bounds, null, null, options
]);
},
/**
* APIMethod: destroy
* Nullify references to prevent circular references and memory leaks.
*/
destroy:function() {
this.node && this.clear();
this.node = null;
OpenLayers.Tile.prototype.destroy.apply(this, arguments);
},
/**
* Method: clone
*
* Parameters:
* obj - {<OpenLayers.Tile>} The tile to be cloned
*
* Returns:
* {<OpenLayers.Tile>} An exact clone of this <OpenLayers.Tile.Google>
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Tile.Google(this.layer,
this.position,
this.bounds);
}
// catch any randomly tagged-on properties
OpenLayers.Util.applyDefaults(obj, this);
obj.node = null;
return obj;
},
/**
* Method: draw
* Check that a tile should be drawn, and draw it.
*
* Returns:
* {Boolean} Always returns true.
*/
draw: function() {
var layerType = OpenLayers.Layer.GoogleNG.mapObject.mapTypes[
this.layer.type
];
if (layerType && OpenLayers.Tile.prototype.draw.apply(this, arguments)) {
var xyz = this.layer.getXYZ(this.bounds);
var point = new google.maps.Point(xyz.x, xyz.y);
// The hybrid tile consists of two images. For some reason, we have
// to make sure that the satellite image loads first, otherwise we
// occasionally get blank tiles for one of the two images. This is
// done by requesting the tile for just the satellite mapType
// first, before requesting the hybrid one.
//TODO revisit this - it may be a temporary issue with GMaps
var tempTile;
if (this.layer.type === google.maps.MapTypeId.HYBRID) {
tempTile = layerType.getTile(point, xyz.z, document);
}
this.node = layerType.getTile(point, xyz.z, document);
this.isLoading = true;
this.events.triggerEvent("loadstart");
this.layer.div.appendChild(this.node);
// We only modify what we need to - we expect the size to be set
// by getTile, and we have a test that will fail if this changes.
OpenLayers.Util.modifyDOMElement(
this.node, null, this.position, null, "absolute"
);
// The images inside the node returned from getTile seem to be
// preloaded already, so registering onload events on these images
// won't work. Instead, we trigger the loadend event immediately
// in the next cycle.
window.setTimeout(OpenLayers.Function.bind(function() {
this.isLoading = false;
// check for this.events - we may be destroyed already
this.events && this.events.triggerEvent("loadend");
// see hybrid tile issue above
//TODO revisit this - it may be a temporary issue with GMaps
if (tempTile) {
layerType.releaseTile(tempTile);
}
}, this), 0);
}
return true;
},
/**
* Method: clear
* Clear the tile of any bounds/position-related data so that it can
* be reused in a new location. To be implemented by subclasses.
*/
clear: function() {
if (this.node) {
this.node.parentNode &&
this.node.parentNode.removeChild(this.node);
OpenLayers.Layer.GoogleNG.mapObject.mapTypes[
this.layer.type
].releaseTile(this.node);
}
},
CLASS_NAME: "OpenLayers.Tile.Google"
});

View File

@@ -20,7 +20,15 @@
// check invalid date // check invalid date
date = new Date("foo"); date = new Date("foo");
str = OpenLayers.Date.toISOString(date); try {
str = OpenLayers.Date.toISOString(date);
} catch (err) {
// some implementations throw RangeError
// see https://bugzilla.mozilla.org/show_bug.cgi?id=649575
if (err instanceof RangeError) {
str = "Invalid Date";
}
}
t.eq(str, "Invalid Date", "invalid date"); t.eq(str, "Invalid Date", "invalid date");
} }

View File

@@ -74,7 +74,7 @@
} }
function test_handleKeypress(t) { function test_handleKeypress(t) {
t.plan(14); t.plan(16);
/** /**
* There are two things that we want to test here * There are two things that we want to test here
@@ -101,6 +101,8 @@
// mock up vertex deletion // mock up vertex deletion
control.dragControl.feature = point; control.dragControl.feature = point;
control.feature = poly; control.feature = poly;
// we cannot use selectFeature since the control is not part of a map
control._originalGeometry = poly.geometry.clone();
control.vertices = [point]; control.vertices = [point];
point.geometry.parent = { point.geometry.parent = {
removeComponent: function(geometry) { removeComponent: function(geometry) {
@@ -110,6 +112,7 @@
}; };
layer.events.on({ layer.events.on({
"featuremodified": function(event) { "featuremodified": function(event) {
t.ok(event.feature.modified !== null, "modified property of feature should have been set");
t.eq(event.feature.id, poly.id, "vertex deletion: featuremodifed triggered"); t.eq(event.feature.id, poly.id, "vertex deletion: featuremodifed triggered");
}, },
"vertexremoved": function(evt) { "vertexremoved": function(evt) {

View File

@@ -535,13 +535,12 @@ Changes:
<Layer> <Layer>
<Title>Acme Corp. Map Server</Title> <Title>Acme Corp. Map Server</Title>
<SRS>EPSG:4326</SRS> <SRS>EPSG:4326</SRS>
<BoundingBox SRS="EPSG:4326"
minx="-1" miny="-1" maxx="1" maxy="1" resx="0.0" resy="0.0"/>
<AuthorityURL name="DIF_ID"> <AuthorityURL name="DIF_ID">
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
xlink:href="http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html" /> xlink:href="http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html" />
</AuthorityURL> </AuthorityURL>
<BoundingBox SRS="EPSG:4326"
minx="-1" miny="-1" maxx="1" maxy="1" resx="0.0" resy="0.0"/>
<Layer> <Layer>
<Name>ROADS_RIVERS</Name> <Name>ROADS_RIVERS</Name>
<Title>Roads and Rivers</Title> <Title>Roads and Rivers</Title>

View File

@@ -786,15 +786,14 @@
} }
function test_setOpacity(t) { function test_setOpacity(t) {
t.plan(8); t.plan(5);
var map, layer, log; var map, layer, log;
map = new OpenLayers.Map("map"); map = new OpenLayers.Map("map");
layer = new OpenLayers.Layer("", {opacity: 0.56}); layer = new OpenLayers.Layer("");
map.addLayer(layer); map.addLayer(layer);
t.eq(layer.div.style.opacity, "0.56", "initial opacity correctly applied as layer.div style");
log = []; log = [];
map.events.register('changelayer', t, function(event) { map.events.register('changelayer', t, function(event) {
log.push({layer: event.layer, property: event.property}); log.push({layer: event.layer, property: event.property});
@@ -802,7 +801,6 @@
layer.setOpacity(0.42); layer.setOpacity(0.42);
t.eq(layer.opacity, 0.42, t.eq(layer.opacity, 0.42,
"setOpacity() set layer.opacity to correct value"); "setOpacity() set layer.opacity to correct value");
t.eq(layer.div.style.opacity, "0.42", "opacity correctly applied as layer.div style");
t.eq(log.length, 1, t.eq(log.length, 1,
"setOpacity() triggers changelayer once"); "setOpacity() triggers changelayer once");
t.ok(log[0].layer == layer, t.ok(log[0].layer == layer,
@@ -815,12 +813,6 @@
layer.setOpacity(0.42); layer.setOpacity(0.42);
t.eq(log.length, 0, t.eq(log.length, 0,
"setOpacity() does not trigger changelayer if the opacity value is the same"); "setOpacity() does not trigger changelayer if the opacity value is the same");
// 0 as initial opacity
layer.destroy();
layer = new OpenLayers.Layer("", {opacity: 0});
map.addLayer(layer);
t.eq(layer.div.style.opacity, "0", "initial opacity correctly applied as layer.div style");
} }

View File

@@ -195,6 +195,31 @@
} }
function test_Layer_AGS93_setOpacity (t) {
var params = {layers: "show:0,2"};
t.plan( 5 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tParams = { layers: 'show:0,2',
format: 'png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.ArcGIS93Rest(name, url, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
var pixel = new OpenLayers.Pixel(5,6);
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
tile.draw();
t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly");
map.destroy();
}
function test_Layer_AGS93_noGutters (t) { function test_Layer_AGS93_noGutters (t) {
t.plan(2); t.plan(2);
var map = new OpenLayers.Map('map'); var map = new OpenLayers.Map('map');

View File

@@ -219,6 +219,32 @@
t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail'); t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail');
} }
/*
* Test that messing up the Array.prototype does not mess up the lods of the layer.
* This messes up zooming when resolutions are very small/scales are very large/zoomed way in.
*/
function test_Layer_ARCGISCACHE_lods (t) {
t.plan( 2 );
var layerInfo = capabilitiesObject;
lods = layerInfo.tileInfo.lods.length;
// mess up the Array prototype
Array.prototype.foo = function() { };
t.ok( lods == layerInfo.tileInfo.lods.length, 'proper number of "Levels of Detail" before initialization' );
// initialize the layer using the JSON object from an arcgis server
// see: ArcGISCache.json
var layer = new OpenLayers.Layer.ArcGISCache(name, url, {
layerInfo: layerInfo
});
t.ok( lods == layer.lods.length, 'proper number of "Levels of Detail" after initialization.' );
// restore the Array prototype
delete Array.prototype.foo;
}
</script> </script>
</head> </head>
<body> <body>

View File

@@ -1,104 +0,0 @@
<html>
<head>
<script src="http://maps.google.com/maps/api/js?sensor=false&v=3.5"></script>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
var map, layer;
function test_constructor(t) {
t.plan(2);
layer = new OpenLayers.Layer.GoogleNG({type: google.maps.MapTypeId.HYBRID});
t.ok(layer instanceof OpenLayers.Layer.GoogleNG, "returns OpenLayers.Layer.GoogleNG object" );
t.eq(layer.type, google.maps.MapTypeId.HYBRID, "Layer type set");
}
function test_initLayer(t) {
t.plan(6);
map = new OpenLayers.Map("map");
var log = {};
layer = new OpenLayers.Layer.GoogleNG({
numZoomLevels: 10,
maxResolution: 39135.7584765625,
initLayer: function() {
log[layer.id] = true;
OpenLayers.Layer.GoogleNG.prototype.initLayer.apply(this, arguments);
}
});
map.addLayer(layer);
map.zoomToMaxExtent();
var map2 = new OpenLayers.Map("map2");
var minZoom = 1;
var layer2 = new OpenLayers.Layer.GoogleNG({
numZoomLevels: 24,
initLayer: function() {
log[layer2.id] = true;
var origMinZoom = OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].minZoom;
// pretend the API reports a different minZoom
OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].minZoom = minZoom;
OpenLayers.Layer.GoogleNG.prototype.initLayer.apply(this, arguments);
OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].minZoom = origMinZoom;
}
});
map2.addLayer(layer2);
map2.zoomToMaxExtent();
t.delay_call(1, function() {
t.eq(log[layer.id], true, "initLayer called for 1st layer");
t.eq(log[layer2.id], true, "initLayer called for 2nd layer");
t.eq(layer.numZoomLevels, 10, "numZoomLevels from configuration takes precedence if lower");
t.eq(layer2.numZoomLevels, OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].maxZoom + 1 - minZoom, "numZoomLevels from API takes precedence if lower");
t.eq(layer.maxResolution, 39135.7584765625, "maxResolution from configuration takes precedence if higher");
t.eq(layer2.maxResolution, 78271.516953125, "maxResolution from API takes precedence if higher");
map.destroy();
map2.destroy();
});
}
function test_attribution(t) {
t.plan(4);
var log = [];
map = new OpenLayers.Map("map");
layer = new OpenLayers.Layer.GoogleNG({
type: google.maps.MapTypeId.HYBRID,
updateAttribution: function(copyrights) {
log.push(copyrights);
OpenLayers.Layer.GoogleNG.prototype.updateAttribution.apply(this, arguments);
}
});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(16, 48).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), 5);
t.delay_call(3, function() {
t.eq(log.length, 1, "updateAttribution was called once");
t.ok(log[0]["m"].length && log[0]["k"].length, "'m' and 'k' copyrights populated for hybrid layer");
t.ok(layer.attribution.indexOf('olGoogleAttribution hybrid') != -1, "Attribution has the correct css class");
t.ok(layer.attribution.indexOf('?ll=48,16&z=5&t=h"') != -1, "maps.google.com link has correct parameters");
map.destroy();
});
}
function test_clone(t) {
t.plan(2);
var clone;
layer = new OpenLayers.Layer.GoogleNG({type: google.maps.MapTypeId.HYBRID});
clone = layer.clone();
t.ok(clone instanceof OpenLayers.Layer.GoogleNG, "clone is a Layer.GoogleNG instance");
t.eq(clone.type, google.maps.MapTypeId.HYBRID, "with the correct map type");
}
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
<div id="map2" style="width:500px;height:550px"></div>
</body>
</html>

View File

@@ -196,6 +196,31 @@
} }
function test_Layer_MapServer_setOpacity (t) {
t.plan( 5 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tUrl = "http://labs.metacarta.com/cgi-bin/mapserv";
tParams = { layers: 'basic',
format: 'image/png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.MapServer(name, tUrl, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
var pixel = new OpenLayers.Pixel(5,6);
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
tile.draw();
t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly");
map.destroy();
}
function test_Layer_MapServer_Reproject (t) { function test_Layer_MapServer_Reproject (t) {
var validkey = (window.location.protocol == "file:") || var validkey = (window.location.protocol == "file:") ||
(window.location.host == "localhost") || (window.location.host == "localhost") ||
@@ -386,6 +411,27 @@
} }
function test_Layer_MapServer_Untiled_setOpacity (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tUrl = "http://labs.metacarta.com/cgi-bin/mapserv";
tParams = { layers: 'basic',
format: 'image/png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.MapServer.Untiled(name, tUrl, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
map.destroy();
}
// DEPRECATED -- REMOVE IN 3.0 // DEPRECATED -- REMOVE IN 3.0
function test_Layer_Untiled_MapServer(t) { function test_Layer_Untiled_MapServer(t) {
t.plan(1); t.plan(1);

View File

@@ -121,6 +121,33 @@
} }
function test_setOpacity(t) {
t.plan(1);
layer = new OpenLayers.Layer.Markers('Test Layer');
var opacity = 0.1234;
for (var i = 0; i < 12; i++) {
layer.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0), new OpenLayers.Icon()));
}
layer.setOpacity(opacity);
for (var i = 0; i < 4; i++) {
layer.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0), new OpenLayers.Icon()));
}
var itWorks = false;
for (var i = 0; i < layer.markers.length; i++) {
itWorks = parseFloat(layer.markers[i].icon.imageDiv.style.opacity) == opacity;
if (!itWorks) {
break;
}
}
t.ok(itWorks, "setOpacity change markers opacity");
}
</script> </script>
</head> </head>
<body> <body>

View File

@@ -25,6 +25,22 @@
} }
function test_Layer_WFS_setOpacity(t) {
t.plan(3);
var layer = new OpenLayers.Layer.WFS(name, "url", {});
layer.setOpacity(.5);
t.eq(layer.opacity, 0.5, "vector setOpacity didn't fail");
var layer = new OpenLayers.Layer.WFS(name, "url", {}, {'featureClass': OpenLayers.Feature.WFS});
var marker = new OpenLayers.Marker(new OpenLayers.LonLat(0,0));
marker.setOpacity = function() {
t.ok(true, "Marker setOpacity was called");
}
layer.addMarker(marker);
layer.setOpacity(.6);
t.eq(layer.opacity, 0.6, "setOpacity didn't fail on markers");
}
function test_Layer_WFS_destroy(t) { function test_Layer_WFS_destroy(t) {
t.plan(13); t.plan(13);

View File

@@ -281,6 +281,31 @@
} }
function test_Layer_WMS_setOpacity (t) {
t.plan( 5 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
tParams = { layers: 'basic',
format: 'image/png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
var pixel = new OpenLayers.Pixel(5,6);
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
tile.draw();
t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly");
map.destroy();
}
function test_Layer_WMS_Reproject (t) { function test_Layer_WMS_Reproject (t) {
var validkey = (window.location.protocol == "file:") || var validkey = (window.location.protocol == "file:") ||
(window.location.host == "localhost") || (window.location.host == "localhost") ||

View File

@@ -1790,36 +1790,76 @@
} }
function test_moveByPx(t) { function test_moveByPx(t) {
t.plan(8); t.plan(16);
var moved;
var Layer = OpenLayers.Class(OpenLayers.Layer, {
moveByPx: function(dx, dy) {
moved[this.name] = true;
}
});
var map = new OpenLayers.Map({ var map = new OpenLayers.Map({
div: 'map', div: 'map',
maxExtent: new OpenLayers.Bounds(-50, -50, 50, 50), maxExtent: new OpenLayers.Bounds(-50, -50, 50, 50),
restrictedExtent: new OpenLayers.Bounds(-10, -10, 10, 10), restrictedExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
layers: [ layers: [
new OpenLayers.Layer('name', {isBaseLayer: true}) new Layer('base',
{isBaseLayer: true}),
new Layer('outofrange',
{isBaseLayer: false, minResolution:2})
] ]
}); });
moved = {};
map.zoomToExtent(new OpenLayers.Bounds(-1, -1, 1, 1)); map.zoomToExtent(new OpenLayers.Bounds(-1, -1, 1, 1));
// check initial state // check initial state
t.eq(map.layerContainerDiv.style.left, '0px', 'layer container left correct'); t.eq(map.layerContainerDiv.style.left, '0px',
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct'); '[initial state] layer container left correct');
t.eq(map.layerContainerDiv.style.top, '0px',
'[initial state] layer container top correct');
t.eq(moved['base'], undefined,
'[initial state] base layer not moved');
t.eq(moved['outofrange'], undefined,
'[initial state] out-of-range layer not moved');
// move to a valid position // move to a valid position
moved = {};
map.moveByPx(-455, 455); map.moveByPx(-455, 455);
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct'); t.eq(map.layerContainerDiv.style.left, '455px',
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct'); '[valid position] layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px',
'[valid position] layer container top correct');
t.eq(moved['base'], true,
'[valid position] base layer moved');
t.eq(moved['outofrange'], undefined,
'[valid position] out-of-range layer not moved');
// move outside the max extent // move outside the max extent
moved = {};
map.moveByPx(-4500, 4500); map.moveByPx(-4500, 4500);
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct'); t.eq(map.layerContainerDiv.style.left, '455px',
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct'); '[outside max extent] layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px',
'[outside max extent] layer container top correct');
t.eq(moved['base'], undefined,
'[outside max extent] base layer not moved');
t.eq(moved['outofrange'], undefined,
'[outside max extent] out-of-range layer not moved');
// move outside the restricted extent // move outside the restricted extent
moved = {};
map.moveByPx(-500, 500); map.moveByPx(-500, 500);
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct'); t.eq(map.layerContainerDiv.style.left, '455px',
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct'); '[outside restricted extent] layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px',
'[outside restricted extent] layer container top correct');
t.eq(moved['base'], undefined,
'[outside restricted extent] base layer not moved');
t.eq(moved['outofrange'], undefined,
'[outside restricted extent] out-of-range layer not moved');
map.destroy(); map.destroy();
} }

View File

@@ -150,7 +150,7 @@
t.eq(script.type, 'text/javascript', t.eq(script.type, 'text/javascript',
'created script has a correct type'); 'created script has a correct type');
t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.getCallback(bar)', t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.registry%5Bbar%5D',
'created script has a correct url'); 'created script has a correct url');
t.eq(script.id, 'OpenLayers_Protocol_Script_bar', t.eq(script.id, 'OpenLayers_Protocol_Script_bar',
'created script has a correct id'); 'created script has a correct id');

View File

@@ -1,74 +0,0 @@
<html>
<head>
<script src="http://maps.google.com/maps/api/js?sensor=false&v=3.5"></script>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
var tile;
var layer = new OpenLayers.Layer.GoogleNG();
var position = new OpenLayers.Pixel(20,30);
var bounds = new OpenLayers.Bounds(1,2,3,4);
function test_constructor (t) {
t.plan( 4 );
tile = new OpenLayers.Tile.Google(layer, position, bounds);
t.ok( tile instanceof OpenLayers.Tile.Google, "new OpenLayers.Tile.Google returns Tile object" );
t.ok( tile.layer == layer, "tile.layer is set correctly");
t.ok( tile.position.equals(position), "tile.position is set correctly");
t.ok( tile.bounds.equals(bounds), "tile.bounds is set correctly");
}
function test_clone (t) {
t.plan( 5 );
tile = new OpenLayers.Tile.Google(layer, position, bounds);
tile.node = document.createElement("div");
var clone = tile.clone();
t.ok( clone instanceof OpenLayers.Tile.Google, "OpenLayers.Tile.Google.clone returns Tile.Google object" );
t.ok( clone.layer == layer, "clone.layer is set correctly");
t.ok( clone.position.equals(position), "clone.position is set correctly");
t.ok( clone.bounds.equals(bounds), "clone.bounds is set correctly");
t.ok( !clone.node, "node not cloned");
}
function test_draw (t) {
t.plan( 5 );
var map = new OpenLayers.Map('map');
map.addLayer(layer);
tile = new OpenLayers.Tile.Google(layer, position, bounds);
tile.events.register("loadstart", this, function() {
t.ok(true, "loadstart triggered");
});
tile.events.register("loadend", this, function() {
t.ok(true, "loadend triggered");
});
t.delay_call(1, function() {
//this should trigger a "loadstart" event
tile.draw();
t.ok( tile.node, "tile.draw creates a node");
// The two tests below will fail when getTile doesn't set the tile size
t.eq( tile.node.style.width, layer.tileSize.w+"px", "Image width is correct" );
t.eq( tile.node.style.height, layer.tileSize.h+"px", "Image height is correct" );
});
t.delay_call(2, function() {
map.removeLayer(layer);
map.destroy();
/* wait until "loadend" fires */
});
}
</script>
</head>
<body>
<div id="map" style="height:550px;width:500px"></div>
</body>
</html>

View File

@@ -153,7 +153,6 @@
<li>Layer/GML.html</li> <li>Layer/GML.html</li>
<li>Layer/Google.html</li> <li>Layer/Google.html</li>
<li>Layer/Google/v3.html</li> <li>Layer/Google/v3.html</li>
<li>Layer/GoogleNG.html</li>
<li>Layer/Grid.html</li> <li>Layer/Grid.html</li>
<li>Layer/HTTPRequest.html</li> <li>Layer/HTTPRequest.html</li>
<li>Layer/Image.html</li> <li>Layer/Image.html</li>
@@ -224,7 +223,6 @@
<li>Symbolizer/Raster.html</li> <li>Symbolizer/Raster.html</li>
<li>Symbolizer/Text.html</li> <li>Symbolizer/Text.html</li>
<li>Tile.html</li> <li>Tile.html</li>
<li>Tile/Google.html</li>
<li>Tile/Image.html</li> <li>Tile/Image.html</li>
<li>Tile/Image/IFrame.html</li> <li>Tile/Image/IFrame.html</li>
<li>Tile/WFS.html</li> <li>Tile/WFS.html</li>

View File

@@ -2,20 +2,21 @@ import sys
import os import os
import tempfile import tempfile
path = os.path.abspath(os.path.join(os.path.dirname(__file__), "closure-compiler.jar")) path = "../tools/closure-compiler.jar"
if not os.path.exists(path): if not os.path.exists(path):
raise Exception("No closure-compiler.jar at %s; read README.txt!" % path) raise Exception("No closure-compiler.jar at %s; read README.txt!" % path)
def minimize(code): def minimize(code):
ntf = tempfile.NamedTemporaryFile() ntf = tempfile.NamedTemporaryFile(delete=False)
ntf.write(code) ntf.write(code)
ntf.flush() ntf.flush()
ntf2 = tempfile.NamedTemporaryFile() ntf2 = tempfile.NamedTemporaryFile(delete=False)
os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
ntf2.seek(0)
data = ntf2.read()
ntf.close() ntf.close()
ntf2.close() ntf2.close()
os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
data = open(ntf2.name).read()
os.unlink(ntf.name)
os.unlink(ntf2.name)
return data return data