Compare commits

..

36 Commits

Author SHA1 Message Date
Éric Lemoine
f5c43d6506 set VERSION_NUMBER to Release 2.12-rc5 2012-05-25 14:55:14 +02:00
Éric Lemoine
ba4a68d0e3 Merge pull request #481 from elemoine/481
2.12-rc4 Tile.js script error (Firefox)
2012-05-25 05:49:16 -07:00
Éric Lemoine
d289aa327e Grid.removeExcessTiles removes more tiles than it should, refs #481 2012-05-24 22:55:43 +02:00
Éric Lemoine
65cd2bcb88 Merge pull request #480 from elemoine/googleexamples
Use nightly version of Google Maps API in examples
2012-05-24 06:14:07 -07:00
Éric Lemoine
2cd979d34c use the nightly version of Google Maps API in the examples, and provide some information about Google Maps API versioning in the google-v3 example 2012-05-22 10:07:18 +02:00
Éric Lemoine
c34b111b38 Merge pull request #476 from probins/googledoc
Document issues with Google v3 layers
2012-05-21 04:20:54 -07:00
Peter Robins
1193e17266 Google v3 docs amendment 2012-05-21 10:06:27 +01:00
Peter Robins
95164d8cc0 Document issues with Google v3 layers 2012-05-20 14:01:12 +01:00
Tim Schaub
ae89452936 Merge pull request #473 from ahocevar/svg-block
Using display:block instead of position:absolute.
2012-05-18 12:29:26 -07:00
ahocevar
120cc0680d Using display:block instead of position:absolute.
This fixes a regression that can be seen e.g. when using the FeatureRenderer in GeoExt, causing an incorrect alignment of the renderer.
2012-05-18 12:38:34 +02:00
ahocevar
92f04a7a42 Merge pull request #472 from probins/goopop
Fix Google terms/poweredby/popup. Thanks @probins for the quick fix.
2012-05-17 11:31:51 -07:00
Peter Robins
f435a98a2a Fix Google terms/poweredby/popup 2012-05-17 16:48:43 +01:00
Éric Lemoine
2624ea089e set VERSION_NUMBER to 2.12-rc4 2012-05-16 21:10:08 +02:00
Éric Lemoine
24b1fa1b08 Merge pull request #467 from jorix/392
Add style = "position: absolute;" on the SVG to skip the bug of Chrome 18
2012-05-16 12:04:41 -07:00
Éric Lemoine
af3615f1ee Merge pull request #469 from elemoine/indexof
Use Util.indexOf in Layer.Bing
2012-05-16 00:19:42 -07:00
Éric Lemoine
62bd06f465 use Util.indexOf in Layer.Bing, for compatibility with IE < 9 2012-05-16 08:24:55 +02:00
Bart van den Eijnden
adcf5bb20a Merge pull request #468 from bartvde/bboxstrategy
Fix visibility and inRange issues with the BBOX strategy (r=@elemoine)
2012-05-15 08:13:55 -07:00
Bart van den Eijnden
44f9b81085 also check for visibility of the layer in the central place: the update function 2012-05-15 12:26:21 +02:00
Bart van den Eijnden
bca3e45940 BBOX strategy should not request data if its layer is out of range when changing layer visibility 2012-05-15 12:18:42 +02:00
Éric Lemoine
4e42dec4ab Merge pull request #465 from probins/gpxwrite
Fix GPX write Point transform
2012-05-15 01:03:35 -07:00
Peter Robins
359bd3d598 Merge pull request #16 from elemoine/gpxwrite
use t.geom_eq in GPX read test
2012-05-15 00:45:20 -07:00
Éric Lemoine
114541d0b7 use t.geom_eq in GPX tests 2012-05-15 08:58:23 +02:00
Xavier Mamano
05672deefa Add style = "position: absolute;" on the SVG to skip the bug of Chrome 18 2012-05-14 23:02:53 +02:00
Peter Robins
9ea3c2f121 Fix GPX write Point transform 2012-05-14 14:21:23 +01:00
Tim Schaub
44e526a0e8 Merge pull request #439 from tschaub/439
Changing/fixing the meaning of getServerZoom
2012-05-11 00:16:09 -07:00
ahocevar
72d1b54956 Also taking into account zoomOffset.
Now the meaning of getServerZoom is fully clarified, and we can get rid of some code again as well.
2012-05-11 00:26:09 -06:00
ahocevar
40b4cc49e0 Using OpenLayers.Util.indexOf.
Thanks @jorix for catching this.
2012-05-11 00:26:09 -06:00
ahocevar
9585341d9c Changing/fixing the meaning of getServerZoom.
If a layer is configured with serverResolutions, then getServerZoom should return the zoom level as index of the current resolution in the serverResolutions array.
2012-05-11 00:26:08 -06:00
Éric Lemoine
293ad9b32a Merge pull request #460 from elemoine/460
Fixing issue of calculating maxResolution of layer again
2012-05-10 06:44:14 -07:00
Éric Lemoine
4ad6bacc5d when calculating maxResolution from maxExtent and tileSize we dont want to the actual tile size for single layers 2012-05-10 15:42:59 +02:00
Éric Lemoine
98fb795f97 set VERSION_NUMBER to 2.12-rc3 2012-05-05 14:27:12 +02:00
Éric Lemoine
23d8057222 Merge pull request #449 from elemoine/449
Issues with window resize in IE9 for OL 2.12RC2
2012-05-05 04:49:55 -07:00
Éric Lemoine
2608a0ebe7 fix resize handling in IE 9 and better (refs #449) 2012-05-04 14:28:12 +02:00
Éric Lemoine
ac3d361778 Merge pull request #441 from elemoine/gutter
Tiles with gutters are shifted
2012-05-02 02:35:32 -07:00
Éric Lemoine
612401a644 fix bug where tiles with gutters are shifted (refs #441) 2012-04-28 21:23:55 +02:00
Frederic Junod
5f1651a30f Add missing hover option to the SelectFeature control.
Thanks Arnie Shore.
2012-04-25 10:34:40 +02:00
27 changed files with 372 additions and 90 deletions

View File

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

View File

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

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="http://maps.google.com/maps/api/js?v=3.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="google-v3.js"></script>
</head>
@@ -35,6 +35,17 @@
location, you must include the extra theme/default/google.css
stylesheet.
</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>
</body>
</html>

View File

@@ -57,6 +57,7 @@ function init() {
// create the select feature control
var selector = new OpenLayers.Control.SelectFeature(vector,{
hover:true,
autoActivate:true
});

View File

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

View File

@@ -22,7 +22,7 @@
}
</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>
</head>

View File

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

View File

@@ -280,7 +280,8 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, {
this.externalProjection);
}
if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
var wpt = this.buildWptNode(feature);
var wpt = this.buildWptNode(geometry);
this.appendAttributesNode(wpt, feature);
return wpt;
} else {
var trkNode = this.createElementNSPlus("gpx:trk");
@@ -348,16 +349,15 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, {
* Builds a wpt node given a point
*
* Parameters:
* feature - {<OpenLayers.Feature.Vector>}
* geometry - {<OpenLayers.Geometry.Point>}
*
* Returns:
* {DOMElement} A wpt node
*/
buildWptNode: function(feature) {
buildWptNode: function(geometry) {
var node = this.createElementNSPlus("gpx:wpt");
node.setAttribute("lon", feature.geometry.x);
node.setAttribute("lat", feature.geometry.y);
this.appendAttributesNode(node, feature);
node.setAttribute("lon", geometry.x);
node.setAttribute("lat", geometry.y);
return node;
},

View File

@@ -1010,7 +1010,7 @@ OpenLayers.Layer = OpenLayers.Class({
this.maxExtent != null) {
// maxResolution for default grid sets assumes that at zoom
// level zero, the whole world fits on one tile.
var tileSize = this.tileSize || this.map.getTileSize();
var tileSize = this.map.getTileSize();
maxResolution = Math.max(
this.maxExtent.getWidth() / tileSize.w,
this.maxExtent.getHeight() / tileSize.h

View File

@@ -224,7 +224,8 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
new OpenLayers.Projection("EPSG:4326")
);
var providers = res.imageryProviders,
zoom = this.serverResolutions.indexOf(this.getServerResolution()),
zoom = OpenLayers.Util.indexOf(this.serverResolutions,
this.getServerResolution()),
copyrights = "", provider, i, ii, j, jj, bbox, coverage;
for (i=0,ii=providers.length; i<ii; ++i) {
provider = providers[i];

View File

@@ -11,7 +11,13 @@
/**
* 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.
*
* Inherits from:

View File

@@ -14,6 +14,11 @@
/**
* 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:
* - <OpenLayers.Layer.SphericalMercator>
* - <OpenLayers.Layer.EventPane>
@@ -462,6 +467,10 @@ OpenLayers.Layer.Google.cache = {};
* Constant: OpenLayers.Layer.Google.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 = {

View File

@@ -11,15 +11,42 @@
/**
* Constant: OpenLayers.Layer.Google.v3
*
* Mixin providing functionality specific to the Google Maps API v3 <= v3.6.
* 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. To use this layer,
* you must include the GMaps API (<= v3.6) in your html:
* Mixin providing functionality specific to the Google Maps API v3.
*
* To use this layer, you must include the GMaps v3 API 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)
* <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)
*
* 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 = {
@@ -137,27 +164,31 @@ OpenLayers.Layer.Google.v3 = {
var cache = OpenLayers.Layer.Google.cache[this.map.id];
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
var termsOfUse = div.lastChild;
container.appendChild(termsOfUse);
termsOfUse.style.zIndex = "1100";
termsOfUse.style.bottom = "";
termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
termsOfUse.style.display = "";
cache.termsOfUse = termsOfUse;
var poweredBy = div.lastChild;
container.appendChild(poweredBy);
poweredBy.style.zIndex = "1100";
poweredBy.style.bottom = "";
poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
poweredBy.style.display = "";
cache.poweredBy = poweredBy;
// 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);
termsOfUse.style.zIndex = "1100";
termsOfUse.style.bottom = "";
termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
termsOfUse.style.display = "";
cache.termsOfUse = termsOfUse;
}
if (div.children[i].style.zIndex == 1000000) {
var poweredBy = div.children[i];
container.appendChild(poweredBy);
poweredBy.style.zIndex = "1100";
poweredBy.style.bottom = "";
poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
poweredBy.style.display = "";
cache.poweredBy = poweredBy;
}
if (div.children[i].style.zIndex == 10000002) {
container.appendChild(div.children[i]);
}
}
this.setGMapVisibility(this.visibility);

View File

@@ -651,14 +651,18 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
/**
* Method: getServerZoom
* Return the zoom value corresponding to the best zoom supported by the server
* resolution.
* Return the zoom value corresponding to the best matching server
* resolution, taking into account <serverResolutions> and <zoomOffset>.
*
* Returns:
* {Number} The closest server supported zoom.
* {Number} The closest server supported zoom. This is not the map zoom
* level, but an index of the server's resolutions array.
*/
getServerZoom: function() {
return this.map.getZoomForResolution(this.getServerResolution());
var resolution = this.getServerResolution();
return this.serverResolutions ?
OpenLayers.Util.indexOf(this.serverResolutions, resolution) :
this.map.getZoomForResolution(resolution) + (this.zoomOffset || 0);
},
/**
@@ -1298,19 +1302,20 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* columns - {Integer} Maximum number of columns we want our grid to have.
*/
removeExcessTiles: function(rows, columns) {
var i, l;
// remove extra rows
while (this.grid.length > rows) {
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];
this.destroyTile(tile);
}
}
// remove extra columns
while (this.grid[0].length > columns) {
for (var i=0, l=this.grid.length; i<l; i++) {
for (i=0, l=this.grid.length; i<l; i++) {
while (this.grid[i].length > columns) {
var row = this.grid[i];
var tile = row.pop();
this.destroyTile(tile);

View File

@@ -173,9 +173,7 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
var res = this.getServerResolution();
var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
var z = this.serverResolutions != null ?
OpenLayers.Util.indexOf(this.serverResolutions, res) :
this.getServerZoom() + this.zoomOffset;
var z = this.getServerZoom();
var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
var url = this.url;
if (OpenLayers.Util.isArray(url)) {

View File

@@ -332,10 +332,7 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
* Get the current index in the matrixIds array.
*/
getIdentifier: function() {
return this.serverResolutions != null ?
OpenLayers.Util.indexOf(this.serverResolutions,
this.getServerResolution()) :
this.getServerZoom() + this.zoomOffset;
return this.getServerZoom();
},
/**

View File

@@ -143,10 +143,7 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
(res * this.tileSize.w));
var y = Math.round((this.maxExtent.top - bounds.top) /
(res * this.tileSize.h));
var resolutions = this.serverResolutions || this.resolutions;
var z = this.zoomOffset == 0 ?
OpenLayers.Util.indexOf(resolutions, res) :
this.getServerZoom() + this.zoomOffset;
var z = this.getServerZoom();
if (this.wrapDateLine) {
var limit = Math.pow(2, z);

View File

@@ -580,8 +580,8 @@ OpenLayers.Map = OpenLayers.Class({
// Because Mozilla does not support the "resize" event for elements
// other than "window", we need to put a hack here.
if (OpenLayers.String.contains(navigator.appName, "Microsoft")) {
// If IE, register the resize on the div
if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) {
// If IE < 9, register the resize on the div
this.events.register("resize", this, this.updateSize);
} else {
// Else updateSize on catching the window's resize

View File

@@ -446,7 +446,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
* {DOMElement} The specific render engine's root element
*/
createRenderRoot: function() {
return this.nodeFactory(this.container.id + "_svgRoot", "svg");
var svg = this.nodeFactory(this.container.id + "_svgRoot", "svg");
svg.style.display = "block";
return svg;
},
/**

View File

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

View File

@@ -81,20 +81,11 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
if(activated) {
this.layer.events.on({
"moveend": this.update,
scope: this
});
this.layer.events.on({
"refresh": this.update,
"visibilitychanged": this.update,
scope: this
});
if(this.layer.visibility === true && this.layer.inRange === true) {
this.update();
} else {
this.layer.events.on({
"visibilitychanged": this.update,
scope: this
});
}
this.update();
}
return activated;
},
@@ -134,7 +125,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
update: function(options) {
var mapBounds = this.getMapBounds();
if (mapBounds !== null && ((options && options.force) ||
this.invalidBounds(mapBounds))) {
(this.layer.visibility && this.layer.calculateInRange() && this.invalidBounds(mapBounds)))) {
this.calculateBounds(mapBounds);
this.resolution = this.layer.map.getResolution();
this.triggerRead(options);

View File

@@ -211,7 +211,8 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
*/
positionTile: function() {
var style = this.getTile().style,
size = this.layer.getImageSize(this.bounds);
size = this.frame ? this.size :
this.layer.getImageSize(this.bounds);
style.left = this.position.x + "%";
style.top = this.position.y + "%";
style.width = size.w + "%";
@@ -254,11 +255,16 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
this.imgDiv.galleryImg = "no";
var style = this.imgDiv.style;
if (this.layer.gutter) {
var left = this.layer.gutter / this.layer.tileSize.w * 100;
var top = this.layer.gutter / this.layer.tileSize.h * 100;
if (this.frame) {
var left = 0, top = 0;
if (this.layer.gutter) {
left = this.layer.gutter / this.layer.tileSize.w * 100;
top = this.layer.gutter / this.layer.tileSize.h * 100;
}
style.left = -left + "%";
style.top = -top + "%";
style.width = (2 * left + 100) + "%";
style.height = (2 * top + 100) + "%";
}
style.visibility = "hidden";
style.opacity = 0;
@@ -275,8 +281,6 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
style.width = "100%";
}
if (this.frame) {
style.width = "100%";
style.height = "100%";
this.frame.appendChild(this.imgDiv);
}
}

View File

@@ -152,6 +152,8 @@ Corresponding issues/pull requests:
The `gpxns` API property has been removed. The GPX namespace is now defined in the `namespaces` property but is not intended to be overriden.
GPX also now has a basic write function.
Corresponding issues/pull requests:
* https://github.com/openlayers/openlayers/pull/221
@@ -217,6 +219,20 @@ Corresponding issues/pull requests:
* 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
`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

@@ -19,13 +19,48 @@
"default external projection is EPSG:4326");
}
function test_Format_GPX_read(t) {
t.plan(4);
t.plan(7);
var expected,
P = OpenLayers.Geometry.Point,
LS = OpenLayers.Geometry.LineString;
var f = new OpenLayers.Format.GPX();
var features = f.read(gpx_data);
t.eq(features.length, 3, "Number of features read is correct");
t.eq(features[2].geometry.toString(), "POINT(-0.1853562259 51.3697845627)", "waypoint feature correctly created");
t.eq(features[0].geometry.toString(), "LINESTRING(-0.1721292044 51.3768216433,-0.1649230916 51.370833767,-0.1736741378 51.3644368725,-0.166259525 51.3576354272)", "track feature correctly created");
t.eq(features[1].geometry.toString(), "LINESTRING(-0.1829991904 51.3761803674,-0.1758887005 51.3697894659,-0.1833202965 51.3639790884,-0.1751119509 51.3567607069)", "route feature correctly created");
expected = new P(-0.1853562259, 51.3697845627);
t.geom_eq(features[2].geometry, expected, "waypoint feature correctly created");
expected = new LS([
new P(-0.1721292044, 51.3768216433),
new P(-0.1649230916, 51.370833767),
new P(-0.1736741378, 51.3644368725),
new P(-0.166259525, 51.3576354272)
]);
t.geom_eq(features[0].geometry, expected, "track feature correctly created");
expected = new LS([
new P(-0.1829991904, 51.3761803674),
new P(-0.1758887005, 51.3697894659),
new P(-0.1833202965, 51.3639790884),
new P(-0.1751119509, 51.3567607069)
]);
t.geom_eq(features[1].geometry, expected, "route feature correctly created");
f.internalProjection = new OpenLayers.Projection("EPSG:3857");
features = f.read(gpx_data);
expected = new P(-20633.760679678744, 6686966.841929403);
t.geom_eq(features[2].geometry, expected, "transformed waypoint feature correctly created");
expected = new LS([
new P(-19161.33538179203, 6688221.743275255),
new P(-18359.1545744088, 6687153.931130851),
new P(-19333.316581165607, 6686013.33343931),
new P(-18507.925659955214, 6684800.777090962)
]);
t.geom_eq(features[0].geometry, expected, "transformed track feature correctly created");
expected = new LS([
new P(-20371.3766880736, 6688107.378491073),
new P(-19579.84057322507, 6686967.716235109),
new P(-20407.12205561124, 6685931.714395953),
new P(-19493.373203291227, 6684644.845706556)
]);
t.geom_eq(features[1].geometry, expected, "transformed route feature correctly created");
}
function test_format_GPX_read_attributes(t) {
t.plan(2);
@@ -35,7 +70,7 @@
t.eq(features[2].attributes['sym'], "Flag", "CDATA attribute node read correctly.");
}
function test_Format_GPX_serialize_points(t) {
t.plan(1);
t.plan(2);
var parser = new OpenLayers.Format.GPX();
@@ -47,9 +82,19 @@
];
var data = parser.write(features);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wpt lon="-111.04" lat="45.68"><name>foo</name><desc>bar</desc></wpt><wpt lon="-112.04" lat="45.68"><name>foo</name><desc>bar</desc></wpt></gpx>', 'GPX serializes points correctly');
parser.internalProjection = new OpenLayers.Projection("EPSG:3857");
point = new OpenLayers.Geometry.Point(-12367595.42541111, 5621521.485409545);
point2 = new OpenLayers.Geometry.Point(-12472235.746742222, 5621521.485409545);
features = [
new OpenLayers.Feature.Vector(point, {name: 'foo', description: 'bar'}),
new OpenLayers.Feature.Vector(point2, {name: 'foo', description: 'bar'})
];
data = parser.write(features);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wpt lon="-111.1" lat="45"><name>foo</name><desc>bar</desc></wpt><wpt lon="-112.04" lat="45"><name>foo</name><desc>bar</desc></wpt></gpx>', 'GPX serializes transformed points correctly');
}
function test_Format_GPX_serialize_line(t) {
t.plan(1);
t.plan(2);
var parser = new OpenLayers.Format.GPX();
@@ -59,6 +104,14 @@
var f = new OpenLayers.Feature.Vector(line, {name: 'foo', description: 'bar'});
var data = parser.write(f);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/></trkseg></trk></gpx>', 'GPX serializes line correctly');
parser.internalProjection = new OpenLayers.Projection("EPSG:3857");
point = new OpenLayers.Geometry.Point(-12367595.42541111, 5621521.485409545);
point2 = new OpenLayers.Geometry.Point(-12472235.746742222, 5621521.485409545);
line = new OpenLayers.Geometry.LineString([point, point2]);
f = new OpenLayers.Feature.Vector(line, {name: 'foo', description: 'bar'});
data = parser.write(f);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.1" lat="45"/><trkpt lon="-112.04" lat="45"/></trkseg></trk></gpx>', 'GPX serializes transformed line correctly');
}
function test_Format_GPX_serialize_lines(t) {
t.plan(1);

View File

@@ -837,12 +837,12 @@
layer.serverResolutions = [2, 1];
resolution = 1;
zoom = layer.getServerZoom();
t.eq(zoom, 3, '[3] getServerZoom return value is correct');
t.eq(zoom, 1, '[3] getServerZoom return value is correct');
layer.serverResolutions = [2];
resolution = 0.5;
zoom = layer.getServerZoom();
t.eq(zoom, 2, '[4] getServerZoom return value is correct');
t.eq(zoom, 0, '[4] getServerZoom return value is correct');
var exc;
layer.serverResolutions = [0.5];
@@ -1523,6 +1523,70 @@
map.destroy();
}
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>
</head>

View File

@@ -305,7 +305,7 @@
// Test fix for Ticket #3142
function test_layerLoadedAfterBeingAdded(t) {
t.plan(2);
t.plan(3);
var dummy = new OpenLayers.Layer(null, {isBaseLayer: true});
@@ -341,6 +341,11 @@
// test that the strategy bounds were set
t.ok(map.getExtent().equals(strategy.bounds), "[set center] bounds set to map extent");
t.eq(layerOutOfRange.strategies[0].bounds, null, "Data not requested if layer is out of range");
layerOutOfRange.setVisibility(false);
layerOutOfRange.setVisibility(true);
t.eq(layerOutOfRange.strategies[0].bounds, null, "Data not requested if layer is out of range when switching visibility");
map.destroy();
}

View File

@@ -399,6 +399,97 @@
}
}
/*
* A series of tests to verify the dimensions and positions
* of the tile frame and img after draw.
* Written for https://github.com/openlayers/openlayers/issues/441
*/
function test_draw_without_gutter_without_frame(t) {
t.plan(5);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS('blank',
'../../img/blank.gif',
{layers: 'fake'},
{isBaseLayer: true});
map.addLayer(layer);
var tile = new OpenLayers.Tile.Image(
layer,
new OpenLayers.Pixel(6, 6),
new OpenLayers.Bounds(5, 45, 6, 46),
null,
new OpenLayers.Size(256, 256));
tile.draw();
t.eq(tile.frame, null, 'no frame');
t.eq(parseInt(tile.imgDiv.style.left, 10), 6, 'correct tile img left');
t.eq(parseInt(tile.imgDiv.style.top, 10), 6, 'correct tile img top');
t.eq(parseInt(tile.imgDiv.style.width, 10), 256, 'correct tile img width');
t.eq(parseInt(tile.imgDiv.style.height, 10), 256, 'correct tile img height');
map.destroy();
}
function test_draw_without_gutter_with_frame(t) {
t.plan(8);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS('blank',
'../../img/blank.gif',
{layers: 'fake'},
{isBaseLayer: true});
map.addLayer(layer);
layer.gutter = 1; // this is just for a frame to be created for
// the tile
var tile = new OpenLayers.Tile.Image(
layer,
new OpenLayers.Pixel(6, 6),
new OpenLayers.Bounds(5, 45, 6, 46),
null,
new OpenLayers.Size(256, 256));
layer.gutter = null;
tile.draw();
t.eq(parseInt(tile.frame.style.left, 10), 6, 'correct tile frame left');
t.eq(parseInt(tile.frame.style.top, 10), 6, 'correct tile frame top');
t.eq(parseInt(tile.frame.style.width, 10), 256, 'correct tile frame width');
t.eq(parseInt(tile.frame.style.height, 10), 256, 'correct tile frame height');
t.eq(parseInt(tile.imgDiv.style.left, 10), 0, 'correct tile img left');
t.eq(parseInt(tile.imgDiv.style.top, 10), 0, 'correct tile img top');
t.eq(parseInt(tile.imgDiv.style.width, 10), 100, 'correct tile img width');
t.eq(parseInt(tile.imgDiv.style.height, 10), 100, 'correct tile img height');
map.destroy();
}
function test_draw_with_gutter(t) {
t.plan(8);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS('blank',
'../../img/blank.gif',
{layers: 'fake'},
{isBaseLayer: true, gutter: 15});
map.addLayer(layer);
var tile = new OpenLayers.Tile.Image(
layer,
new OpenLayers.Pixel(6, 6),
new OpenLayers.Bounds(5, 45, 6, 46),
null,
new OpenLayers.Size(256, 256));
tile.draw();
t.eq(parseInt(tile.frame.style.left, 10), 6, 'correct tile frame left');
t.eq(parseInt(tile.frame.style.top, 10), 6, 'correct tile frame top');
t.eq(parseInt(tile.frame.style.width, 10), 256, 'correct tile frame width');
t.eq(parseInt(tile.frame.style.height, 10), 256, 'correct tile frame height');
t.eq(parseInt(tile.imgDiv.style.left, 10), -5, 'correct tile img left');
t.eq(parseInt(tile.imgDiv.style.top, 10), -5, 'correct tile img top');
t.eq(parseInt(tile.imgDiv.style.width, 10), 111, 'correct tile img width');
t.eq(parseInt(tile.imgDiv.style.height, 10), 111, 'correct tile img height');
map.destroy();
}
</script>
</head>
<body>