Merge pull request #1124 from tschaub/xyz

Allow tilegrid creation from projection or extent.
This commit is contained in:
Tim Schaub
2014-08-19 11:59:52 -06:00
9 changed files with 255 additions and 39 deletions

View File

@@ -89,7 +89,9 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
var resource = response.resourceSets[0].resources[0];
goog.asserts.assert(resource.imageWidth == resource.imageHeight);
var sourceProjection = this.getProjection();
var tileGrid = new ol.tilegrid.XYZ({
extent: ol.tilegrid.extentFromProjection(sourceProjection),
minZoom: resource.zoomMin,
maxZoom: resource.zoomMax,
tileSize: resource.imageWidth
@@ -97,7 +99,6 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
this.tileGrid = tileGrid;
var culture = this.culture_;
var sourceProjection = this.getProjection();
this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
tileGrid.createTileCoordTransform(),
ol.TileUrlFunction.createFromTileUrlFunctions(

View File

@@ -54,10 +54,11 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
var epsg4326Projection = ol.proj.get('EPSG:4326');
var sourceProjection = this.getProjection();
var extent;
if (goog.isDef(tileJSON.bounds)) {
var transform = ol.proj.getTransformFromProjections(
epsg4326Projection, this.getProjection());
epsg4326Projection, sourceProjection);
extent = ol.extent.applyTransform(tileJSON.bounds, transform);
}
@@ -67,6 +68,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
var minZoom = tileJSON.minzoom || 0;
var maxZoom = tileJSON.maxzoom || 22;
var tileGrid = new ol.tilegrid.XYZ({
extent: ol.tilegrid.extentFromProjection(sourceProjection),
maxZoom: maxZoom,
minZoom: minZoom
});

View File

@@ -17,14 +17,12 @@ goog.require('ol.tilegrid.XYZ');
* @api
*/
ol.source.XYZ = function(options) {
var projection = goog.isDef(options.projection) ?
options.projection : 'EPSG:3857';
var maxZoom = goog.isDef(options.maxZoom) ? options.maxZoom : 18;
var tileGrid = new ol.tilegrid.XYZ({
maxZoom: maxZoom
extent: ol.tilegrid.extentFromProjection(projection),
maxZoom: options.maxZoom
});
goog.base(this, {