Merge pull request #272 from twpayne/projection-get
allow people to specify projection as a string
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
@exportObjectLiteralProperty ol.View2DOptions.center ol.Coordinate|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.maxResolution number|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.numZoomLevels number|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.projection ol.Projection|string|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.View2DOptions.resolution number|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.resolutions Array.<number>|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.rotation number|undefined
|
||||
@@ -61,7 +61,7 @@
|
||||
@exportObjectLiteral ol.control.MousePositionOptions
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.coordinateFormat ol.CoordinateFormatType|undefined
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.map ol.Map|undefined
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.target Element|undefined
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.undefinedHTML string|undefined
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
@exportObjectLiteral ol.source.DebugTileSourceOptions
|
||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.extent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.tileGrid ol.tilegrid.TileGrid|undefined
|
||||
|
||||
@exportObjectLiteral ol.source.SingleImageWMSOptions
|
||||
@@ -111,7 +111,7 @@
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.crossOrigin null|string|undefined
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.extent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.params Object.<string,*>
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.resolutions Array.<number>|undefined
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.url string|undefined
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.extent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.imageExtent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.imageSize ol.Size|undefined
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.url string|undefined
|
||||
|
||||
@exportObjectLiteral ol.source.TiledWMSOptions
|
||||
@@ -138,7 +138,7 @@
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.extent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.tileGrid ol.tilegrid.TileGrid|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.maxZoom number|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.url string|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.urls Array.<string>|undefined
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ ol.control.MousePosition = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Projection|undefined}
|
||||
* @type {ol.Projection}
|
||||
*/
|
||||
this.projection_ = options.projection;
|
||||
this.projection_ = ol.projection.get(options.projection);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -168,8 +168,8 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
|
||||
var html = this.undefinedHTML_;
|
||||
if (!goog.isNull(pixel)) {
|
||||
if (this.renderedProjection_ != this.mapProjection_) {
|
||||
if (goog.isDef(this.projection_)) {
|
||||
this.transform_ = ol.projection.getTransform(
|
||||
if (!goog.isNull(this.projection_)) {
|
||||
this.transform_ = ol.projection.getTransformFromProjections(
|
||||
this.mapProjection_, this.projection_);
|
||||
} else {
|
||||
this.transform_ = ol.projection.identityTransform;
|
||||
|
||||
@@ -176,8 +176,8 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
|
||||
|
||||
// Convert pointResolution from meters or feet to degrees
|
||||
if (goog.isNull(this.toEPSG4326_)) {
|
||||
this.toEPSG4326_ = ol.projection.getTransform(
|
||||
projection, ol.projection.getFromCode('EPSG:4326'));
|
||||
this.toEPSG4326_ = ol.projection.getTransformFromProjections(
|
||||
projection, ol.projection.get('EPSG:4326'));
|
||||
}
|
||||
var vertex = [center.x, center.y];
|
||||
vertex = this.toEPSG4326_(vertex, vertex, 2);
|
||||
|
||||
@@ -76,8 +76,8 @@ ol.Geolocation.prototype.disposeInternal = function() {
|
||||
ol.Geolocation.prototype.handleProjectionChanged_ = function() {
|
||||
var projection = this.getProjection();
|
||||
if (goog.isDefAndNotNull(projection)) {
|
||||
this.transformFn_ = ol.projection.getTransform(
|
||||
ol.projection.getFromCode('EPSG:4326'), projection);
|
||||
this.transformFn_ = ol.projection.getTransformFromProjections(
|
||||
ol.projection.get('EPSG:4326'), projection);
|
||||
if (!goog.isNull(this.position_)) {
|
||||
var vertex = [this.position_.x, this.position_.y];
|
||||
vertex = this.transformFn_(vertex, vertex, 2);
|
||||
|
||||
@@ -79,7 +79,7 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
|
||||
var topLeftCorner = this.getChildValue(node);
|
||||
var coords = topLeftCorner.split(' ');
|
||||
var axisOrientation =
|
||||
ol.projection.getFromCode(obj['supportedCRS']).getAxisOrientation();
|
||||
ol.projection.get(obj['supportedCRS']).getAxisOrientation();
|
||||
obj['topLeftCorner'] = ol.Coordinate.fromProjectedArray(
|
||||
[parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation);
|
||||
},
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
@exportProperty ol.ProjectionUnits.METERS
|
||||
|
||||
@exportSymbol ol.projection.addProjection
|
||||
@exportSymbol ol.projection.getFromCode
|
||||
@exportSymbol ol.projection.get
|
||||
@exportSymbol ol.projection.getTransform
|
||||
@exportSymbol ol.projection.getTransformFromCodes
|
||||
@exportSymbol ol.projection.getTransformFromProjections
|
||||
@exportSymbol ol.projection.transform
|
||||
@exportSymbol ol.projection.transformWithCodes
|
||||
@exportSymbol ol.projection.transformWithProjections
|
||||
@exportSymbol ol.projection.configureProj4jsProjection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
goog.provide('ol.Projection');
|
||||
goog.provide('ol.ProjectionLike');
|
||||
goog.provide('ol.ProjectionUnits');
|
||||
goog.provide('ol.projection');
|
||||
|
||||
@@ -23,6 +24,12 @@ ol.ENABLE_PROJ4JS = true;
|
||||
ol.HAVE_PROJ4JS = ol.ENABLE_PROJ4JS && typeof Proj4js == 'object';
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {ol.Projection|string|undefined}
|
||||
*/
|
||||
ol.ProjectionLike;
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
@@ -211,7 +218,7 @@ ol.Proj4jsProjection_.prototype.getPointResolution =
|
||||
// measuring its width and height on the normal sphere, and taking the
|
||||
// average of the width and height.
|
||||
if (goog.isNull(this.toEPSG4326_)) {
|
||||
this.toEPSG4326_ = ol.projection.getTransform(
|
||||
this.toEPSG4326_ = ol.projection.getTransformFromProjections(
|
||||
this, ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: 'EPSG:4326',
|
||||
extent: null
|
||||
@@ -365,9 +372,9 @@ ol.projection.clearAllProjections = function() {
|
||||
*/
|
||||
ol.projection.createProjection = function(projection, defaultCode) {
|
||||
if (!goog.isDefAndNotNull(projection)) {
|
||||
return ol.projection.getFromCode(defaultCode);
|
||||
return ol.projection.get(defaultCode);
|
||||
} else if (goog.isString(projection)) {
|
||||
return ol.projection.getFromCode(projection);
|
||||
return ol.projection.get(projection);
|
||||
} else {
|
||||
goog.asserts.assert(projection instanceof ol.Projection);
|
||||
return projection;
|
||||
@@ -422,20 +429,29 @@ ol.projection.removeTransform = function(source, destination) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} code Code which is a combination of authority and identifier
|
||||
* such as “EPSG:4326”.
|
||||
* @param {ol.ProjectionLike} projectionLike Either a code string which is a
|
||||
* combination of authority and identifier such as "EPSG:4326", or an
|
||||
* existing projection object, or undefined.
|
||||
* @return {ol.Projection} Projection.
|
||||
*/
|
||||
ol.projection.getFromCode = function(code) {
|
||||
var projection = ol.projection.projections_[code];
|
||||
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
|
||||
projection = ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: code,
|
||||
extent: null
|
||||
});
|
||||
}
|
||||
if (!goog.isDef(projection)) {
|
||||
goog.asserts.assert(goog.isDef(projection));
|
||||
ol.projection.get = function(projectionLike) {
|
||||
var projection;
|
||||
if (projectionLike instanceof ol.Projection) {
|
||||
projection = projectionLike;
|
||||
} else if (goog.isString(projectionLike)) {
|
||||
var code = projectionLike;
|
||||
projection = ol.projection.projections_[code];
|
||||
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
|
||||
projection = ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: code,
|
||||
extent: null
|
||||
});
|
||||
}
|
||||
if (!goog.isDef(projection)) {
|
||||
goog.asserts.assert(goog.isDef(projection));
|
||||
projection = null;
|
||||
}
|
||||
} else {
|
||||
projection = null;
|
||||
}
|
||||
return projection;
|
||||
@@ -483,24 +499,43 @@ ol.projection.equivalent = function(projection1, projection2) {
|
||||
} else if (projection1.getUnits() != projection2.getUnits()) {
|
||||
return false;
|
||||
} else {
|
||||
var transformFn = ol.projection.getTransform(projection1, projection2);
|
||||
var transformFn = ol.projection.getTransformFromProjections(
|
||||
projection1, projection2);
|
||||
return transformFn === ol.projection.cloneTransform;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Given the projection-like objects this method searches for a transformation
|
||||
* function to convert a coordinates array from the source projection to the
|
||||
* destination projection.
|
||||
*
|
||||
* @param {ol.ProjectionLike} source Source.
|
||||
* @param {ol.ProjectionLike} destination Destination.
|
||||
* @return {ol.TransformFunction} Transform.
|
||||
*/
|
||||
ol.projection.getTransform = function(source, destination) {
|
||||
var sourceProjection = ol.projection.get(source);
|
||||
var destinationProjection = ol.projection.get(destination);
|
||||
return ol.projection.getTransformFromProjections(
|
||||
sourceProjection, destinationProjection);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Searches a function that can be used to convert coordinates from the source
|
||||
* projection to the destination projection.
|
||||
*
|
||||
* @param {ol.Projection} source Source.
|
||||
* @param {ol.Projection} destination Destination.
|
||||
* @param {ol.Projection} sourceProjection Source projection.
|
||||
* @param {ol.Projection} destinationProjection Destination projection.
|
||||
* @return {ol.TransformFunction} Transform.
|
||||
*/
|
||||
ol.projection.getTransform = function(source, destination) {
|
||||
ol.projection.getTransformFromProjections =
|
||||
function(sourceProjection, destinationProjection) {
|
||||
var transforms = ol.projection.transforms_;
|
||||
var sourceCode = source.getCode();
|
||||
var destinationCode = destination.getCode();
|
||||
var sourceCode = sourceProjection.getCode();
|
||||
var destinationCode = destinationProjection.getCode();
|
||||
var transform;
|
||||
if (goog.object.containsKey(transforms, sourceCode) &&
|
||||
goog.object.containsKey(transforms[sourceCode], destinationCode)) {
|
||||
@@ -508,23 +543,23 @@ ol.projection.getTransform = function(source, destination) {
|
||||
}
|
||||
if (ol.HAVE_PROJ4JS && !goog.isDef(transform)) {
|
||||
var proj4jsSource;
|
||||
if (source instanceof ol.Proj4jsProjection_) {
|
||||
proj4jsSource = source;
|
||||
if (sourceProjection instanceof ol.Proj4jsProjection_) {
|
||||
proj4jsSource = sourceProjection;
|
||||
} else {
|
||||
proj4jsSource =
|
||||
ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: source.getCode(),
|
||||
code: sourceCode,
|
||||
extent: null
|
||||
});
|
||||
}
|
||||
var sourceProj4jsProj = proj4jsSource.getProj4jsProj();
|
||||
var proj4jsDestination;
|
||||
if (destination instanceof ol.Proj4jsProjection_) {
|
||||
proj4jsDestination = destination;
|
||||
if (destinationProjection instanceof ol.Proj4jsProjection_) {
|
||||
proj4jsDestination = destinationProjection;
|
||||
} else {
|
||||
proj4jsDestination =
|
||||
ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: destination.getCode(),
|
||||
code: destinationCode,
|
||||
extent: null
|
||||
});
|
||||
}
|
||||
@@ -559,7 +594,8 @@ ol.projection.getTransform = function(source, destination) {
|
||||
}
|
||||
return output;
|
||||
};
|
||||
ol.projection.addTransform(source, destination, transform);
|
||||
ol.projection.addTransform(
|
||||
sourceProjection, destinationProjection, transform);
|
||||
}
|
||||
if (!goog.isDef(transform)) {
|
||||
goog.asserts.assert(goog.isDef(transform));
|
||||
@@ -569,22 +605,6 @@ ol.projection.getTransform = function(source, destination) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Given the projection codes this method searches for a transformation function
|
||||
* to convert a coordinates array from the source projection to the destination
|
||||
* projection.
|
||||
*
|
||||
* @param {string} sourceCode Source code.
|
||||
* @param {string} destinationCode Destination code.
|
||||
* @return {ol.TransformFunction} Transform.
|
||||
*/
|
||||
ol.projection.getTransformFromCodes = function(sourceCode, destinationCode) {
|
||||
var source = ol.projection.getFromCode(sourceCode);
|
||||
var destination = ol.projection.getFromCode(destinationCode);
|
||||
return ol.projection.getTransform(source, destination);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<number>} input Input coordinate array.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinate values.
|
||||
@@ -626,11 +646,9 @@ ol.projection.cloneTransform = function(input, opt_output, opt_dimension) {
|
||||
|
||||
|
||||
/**
|
||||
* Transforms the given point to the destination projection.
|
||||
*
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @param {ol.Projection} source Source.
|
||||
* @param {ol.Projection} destination Destination.
|
||||
* @param {ol.ProjectionLike} source Source.
|
||||
* @param {ol.ProjectionLike} destination Destination.
|
||||
* @return {ol.Coordinate} Point.
|
||||
*/
|
||||
ol.projection.transform = function(point, source, destination) {
|
||||
@@ -642,15 +660,17 @@ ol.projection.transform = function(point, source, destination) {
|
||||
|
||||
|
||||
/**
|
||||
* Transforms the given point to the destination projection.
|
||||
*
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @param {string} sourceCode Source code.
|
||||
* @param {string} destinationCode Destination code.
|
||||
* @param {ol.Projection} sourceProjection Source projection.
|
||||
* @param {ol.Projection} destinationProjection Destination projection.
|
||||
* @return {ol.Coordinate} Point.
|
||||
*/
|
||||
ol.projection.transformWithCodes =
|
||||
function(point, sourceCode, destinationCode) {
|
||||
var transformFn = ol.projection.getTransformFromCodes(
|
||||
sourceCode, destinationCode);
|
||||
ol.projection.transformWithProjections =
|
||||
function(point, sourceProjection, destinationProjection) {
|
||||
var transformFn = ol.projection.getTransformFromProjections(
|
||||
sourceProjection, destinationProjection);
|
||||
var vertex = [point.x, point.y];
|
||||
vertex = transformFn(vertex, vertex, 2);
|
||||
return new ol.Coordinate(vertex[0], vertex[1]);
|
||||
|
||||
@@ -24,7 +24,7 @@ ol.source.BingMaps = function(bingMapsOptions) {
|
||||
|
||||
goog.base(this, {
|
||||
opaque: true,
|
||||
projection: ol.projection.getFromCode('EPSG:3857')
|
||||
projection: ol.projection.get('EPSG:3857')
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -111,8 +111,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
};
|
||||
})));
|
||||
|
||||
var transform = ol.projection.getTransform(
|
||||
ol.projection.getFromCode('EPSG:4326'), this.getProjection());
|
||||
var transform = ol.projection.getTransformFromProjections(
|
||||
ol.projection.get('EPSG:4326'), this.getProjection());
|
||||
var attributions = goog.array.map(
|
||||
resource.imageryProviders,
|
||||
function(imageryProvider) {
|
||||
|
||||
@@ -16,7 +16,7 @@ goog.require('ol.source.Source');
|
||||
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
||||
* crossOrigin: (null|string|undefined),
|
||||
* extent: (null|ol.Extent|undefined),
|
||||
* projection: (ol.Projection|undefined),
|
||||
* projection: ol.ProjectionLike,
|
||||
* resolutions: (Array.<number>|undefined),
|
||||
* imageUrlFunction: (ol.ImageUrlFunctionType|
|
||||
* undefined)}}
|
||||
|
||||
@@ -18,7 +18,7 @@ goog.require('ol.tilegrid.TileGrid');
|
||||
* crossOrigin: (null|string|undefined),
|
||||
* extent: (ol.Extent|undefined),
|
||||
* opaque: (boolean|undefined),
|
||||
* projection: (ol.Projection|undefined),
|
||||
* projection: ol.ProjectionLike,
|
||||
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
||||
* tileUrlFunction: (ol.TileUrlFunctionType|undefined)}}
|
||||
*/
|
||||
|
||||
@@ -5,13 +5,13 @@ goog.require('goog.events.EventType');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.projection');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
||||
* extent: (ol.Extent|undefined),
|
||||
* projection: (ol.Projection|undefined)}}
|
||||
* projection: ol.ProjectionLike}}
|
||||
*/
|
||||
ol.source.SourceOptions;
|
||||
|
||||
@@ -30,8 +30,7 @@ ol.source.Source = function(sourceOptions) {
|
||||
* @private
|
||||
* @type {ol.Projection}
|
||||
*/
|
||||
this.projection_ = goog.isDef(sourceOptions.projection) ?
|
||||
sourceOptions.projection : null;
|
||||
this.projection_ = ol.projection.get(sourceOptions.projection);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -39,7 +38,7 @@ ol.source.Source = function(sourceOptions) {
|
||||
*/
|
||||
this.extent_ = goog.isDef(sourceOptions.extent) ?
|
||||
sourceOptions.extent : goog.isDef(sourceOptions.projection) ?
|
||||
sourceOptions.projection.getExtent() : null;
|
||||
this.projection_.getExtent() : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.source.StaticImage');
|
||||
|
||||
goog.require('ol.Image');
|
||||
goog.require('ol.ImageUrlFunctionType');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.ImageSource');
|
||||
|
||||
|
||||
@@ -19,7 +20,7 @@ ol.source.StaticImage = function(options) {
|
||||
var imageExtent = options.imageExtent;
|
||||
var imageSize = options.imageSize;
|
||||
var imageResolution = imageExtent.getHeight() / imageSize.height;
|
||||
var projection = goog.isDef(options.projection) ? options.projection : null;
|
||||
var projection = ol.projection.get(options.projection);
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportSymbol ol.source.TiledWMS
|
||||
@exportSymbol ol.source.TiledWMS
|
||||
|
||||
@@ -52,7 +52,7 @@ goog.exportSymbol('grid', grid);
|
||||
ol.source.TileJSON = function(tileJsonOptions) {
|
||||
|
||||
goog.base(this, {
|
||||
projection: ol.projection.getFromCode('EPSG:3857')
|
||||
projection: ol.projection.get('EPSG:3857')
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -80,15 +80,15 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
|
||||
|
||||
var tileJSON = ol.tilejson.grids_.pop();
|
||||
|
||||
var epsg4326Projection = ol.projection.getFromCode('EPSG:4326');
|
||||
var epsg4326Projection = ol.projection.get('EPSG:4326');
|
||||
|
||||
var epsg4326Extent, extent;
|
||||
if (goog.isDef(tileJSON.bounds)) {
|
||||
var bounds = tileJSON.bounds;
|
||||
epsg4326Extent = new ol.Extent(
|
||||
bounds[0], bounds[1], bounds[2], bounds[3]);
|
||||
extent = epsg4326Extent.transform(
|
||||
ol.projection.getTransform(epsg4326Projection, this.getProjection()));
|
||||
extent = epsg4326Extent.transform(ol.projection.getTransformFromProjections(
|
||||
epsg4326Projection, this.getProjection()));
|
||||
this.setExtent(extent);
|
||||
} else {
|
||||
epsg4326Extent = null;
|
||||
|
||||
@@ -4,7 +4,6 @@ goog.provide('ol.source.TileSourceOptions');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileRange');
|
||||
@@ -16,7 +15,7 @@ goog.require('ol.tilegrid.TileGrid');
|
||||
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
||||
* extent: (ol.Extent|undefined),
|
||||
* opaque: (boolean|undefined),
|
||||
* projection: (ol.Projection|undefined),
|
||||
* projection: ol.ProjectionLike,
|
||||
* tileGrid: (ol.tilegrid.TileGrid|undefined)}}
|
||||
*/
|
||||
ol.source.TileSourceOptions;
|
||||
|
||||
@@ -37,7 +37,7 @@ ol.source.XYZOptions;
|
||||
ol.source.XYZ = function(xyzOptions) {
|
||||
|
||||
var projection = xyzOptions.projection ||
|
||||
ol.projection.getFromCode('EPSG:3857');
|
||||
ol.projection.get('EPSG:3857');
|
||||
|
||||
/**
|
||||
* @type {ol.TileUrlFunctionType}
|
||||
|
||||
Reference in New Issue
Block a user