Skip to content

Commit

Permalink
Merge branch '2.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
elemoine committed May 25, 2012
2 parents 5879a71 + f5c43d6 commit 2141cb9
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/all-overlays-google.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion examples/google-v3-alloverlays.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
13 changes: 12 additions & 1 deletion examples/google-v3.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -35,6 +35,17 @@ <h1 id="title">Google (v3) Layer Example</h1>
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>
2 changes: 1 addition & 1 deletion examples/osm-google.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion examples/spherical-mercator.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,4 @@
/**
* Constant: VERSION_NUMBER
*/
OpenLayers.VERSION_NUMBER="Release 2.12-rc4";
OpenLayers.VERSION_NUMBER="Release 2.12-rc5";
8 changes: 7 additions & 1 deletion lib/OpenLayers/Layer/EventPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions lib/OpenLayers/Layer/Google.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 = {

Expand Down
39 changes: 33 additions & 6 deletions lib/OpenLayers/Layer/Google/v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {

Expand Down
7 changes: 4 additions & 3 deletions lib/OpenLayers/Layer/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1302,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);
Expand Down
2 changes: 1 addition & 1 deletion lib/OpenLayers/SingleFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var OpenLayers = {
/**
* Constant: VERSION_NUMBER
*/
VERSION_NUMBER: "Release 2.12-rc4",
VERSION_NUMBER: "Release 2.12-rc5",

/**
* Constant: singleFile
Expand Down
14 changes: 14 additions & 0 deletions notes/2.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,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.
Expand Down
64 changes: 64 additions & 0 deletions tests/Layer/Grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 2141cb9

Please sign in to comment.