the API user does not know about UnreferencedBounds, and remove getResForZoom and getMaxRes from the map API
This commit is contained in:
@@ -221,7 +221,7 @@ ol.Map.prototype.controls = function(opt_arg) {
|
||||
/**
|
||||
* @export
|
||||
* @param {Array=} opt_arg
|
||||
* @returns {ol.Map|ol.UnreferencedBounds|undefined} Map max extent.
|
||||
* @returns {ol.Map|ol.Bounds|undefined} Map max extent.
|
||||
*/
|
||||
ol.Map.prototype.maxExtent = function(opt_arg) {
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
@@ -232,28 +232,6 @@ ol.Map.prototype.maxExtent = function(opt_arg) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @param {number=} opt_arg
|
||||
* @returns {ol.Map|number|undefined} Map maximum resolution
|
||||
*/
|
||||
ol.Map.prototype.maxRes = function(opt_arg) {
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
this.setMaxRes(opt_arg);
|
||||
return this;
|
||||
} else {
|
||||
return this.getMaxRes();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} arg
|
||||
* @returns {number} resolution for a given zoom level
|
||||
*/
|
||||
ol.Map.prototype.getResForZoom = function(arg) {
|
||||
return this.getResolutionForZoom(arg);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string|Element} arg Render the map to a container
|
||||
* @returns {ol.Map}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.provide('ol.Map');
|
||||
|
||||
goog.require('ol.Loc');
|
||||
goog.require('ol.Bounds');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.event');
|
||||
goog.require('ol.event.Events');
|
||||
@@ -65,7 +66,7 @@ ol.Map = function() {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.UnreferencedBounds}
|
||||
* @type {ol.Bounds}
|
||||
*/
|
||||
this.maxExtent_ = null;
|
||||
|
||||
@@ -209,14 +210,19 @@ ol.Map.prototype.getControls = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.UnreferencedBounds} the maxExtent for the map
|
||||
* @return {ol.Bounds} the maxExtent for the map
|
||||
*/
|
||||
ol.Map.prototype.getMaxExtent = function() {
|
||||
if (goog.isDefAndNotNull(this.maxExtent_)) {
|
||||
return this.maxExtent_;
|
||||
} else {
|
||||
var extent = this.getProjection().getExtent();
|
||||
var projection = this.getProjection();
|
||||
var extent = projection.getExtent();
|
||||
if (goog.isDefAndNotNull(extent)) {
|
||||
extent = new ol.Bounds(
|
||||
extent.getMinX(), extent.getMinY(),
|
||||
extent.getMaxX(), extent.getMaxY());
|
||||
extent.setProjection(projection);
|
||||
return extent;
|
||||
} else {
|
||||
throw('maxExtent must be defined either in the map or the projection');
|
||||
@@ -332,7 +338,7 @@ ol.Map.prototype.setControls = function(opt_controls) {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ol.UnreferencedBounds} extent the maxExtent for the map
|
||||
* @param {ol.Bounds} extent the maxExtent for the map
|
||||
*/
|
||||
ol.Map.prototype.setMaxExtent = function(extent) {
|
||||
this.maxExtent_ = extent;
|
||||
|
||||
@@ -193,11 +193,11 @@ describe("ol.map", function() {
|
||||
var map = ol.map();
|
||||
|
||||
var extent = map.maxExtent();
|
||||
expect(extent).toBeA(ol.UnreferencedBounds);
|
||||
expect(extent.getMinX()).toBe(-20037508.34);
|
||||
expect(extent.getMaxX()).toBe(20037508.34);
|
||||
expect(extent.getMinY()).toBe(-20037508.34);
|
||||
expect(extent.getMaxY()).toBe(20037508.34);
|
||||
expect(extent).toBeA(ol.Bounds);
|
||||
expect(extent.minX()).toBe(-20037508.34);
|
||||
expect(extent.maxX()).toBe(20037508.34);
|
||||
expect(extent.minY()).toBe(-20037508.34);
|
||||
expect(extent.maxY()).toBe(20037508.34);
|
||||
|
||||
});
|
||||
|
||||
@@ -206,11 +206,11 @@ describe("ol.map", function() {
|
||||
map.maxExtent([-5,-4,7,9]);
|
||||
|
||||
var extent = map.maxExtent();
|
||||
expect(extent).toBeA(ol.UnreferencedBounds);
|
||||
expect(extent.getMinX()).toBe(-5);
|
||||
expect(extent.getMaxX()).toBe(7);
|
||||
expect(extent.getMinY()).toBe(-4);
|
||||
expect(extent.getMaxY()).toBe(9);
|
||||
expect(extent).toBeA(ol.Bounds);
|
||||
expect(extent.minX()).toBe(-5);
|
||||
expect(extent.maxX()).toBe(7);
|
||||
expect(extent.minY()).toBe(-4);
|
||||
expect(extent.maxY()).toBe(9);
|
||||
|
||||
});
|
||||
|
||||
@@ -219,11 +219,11 @@ describe("ol.map", function() {
|
||||
map.projection("CRS:84");
|
||||
|
||||
var extent = map.maxExtent();
|
||||
expect(extent).toBeA(ol.UnreferencedBounds);
|
||||
expect(extent.getMinX()).toBe(-180);
|
||||
expect(extent.getMaxX()).toBe(180);
|
||||
expect(extent.getMinY()).toBe(-90);
|
||||
expect(extent.getMaxY()).toBe(90);
|
||||
expect(extent).toBeA(ol.Bounds);
|
||||
expect(extent.minX()).toBe(-180);
|
||||
expect(extent.maxX()).toBe(180);
|
||||
expect(extent.minY()).toBe(-90);
|
||||
expect(extent.maxY()).toBe(90);
|
||||
|
||||
});
|
||||
|
||||
@@ -234,59 +234,6 @@ describe("ol.map", function() {
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
it("getMaxRes returns correct defaults", function() {
|
||||
var map = ol.map();
|
||||
|
||||
var res = map.maxRes();
|
||||
expect(res.toFixed(5)).toBe("156543.03391");
|
||||
|
||||
});
|
||||
|
||||
it("allows setting of maxRes", function() {
|
||||
var map = ol.map({
|
||||
maxRes: 67
|
||||
});
|
||||
|
||||
var res = map.maxRes();
|
||||
expect(res).toBe(67);
|
||||
|
||||
});
|
||||
|
||||
it("getMaxRes returns correct for custom maxExtent", function() {
|
||||
var map = ol.map({
|
||||
projection: ol.projection({
|
||||
code: 'foo',
|
||||
maxExtent: [0,0,90,90]
|
||||
})
|
||||
});
|
||||
|
||||
var res = map.maxRes();
|
||||
expect(res.toFixed(7)).toBe("0.3515625");
|
||||
|
||||
});
|
||||
|
||||
it("returns correct getResForZoom for default map", function() {
|
||||
var map = ol.map();
|
||||
|
||||
var res = map.getResForZoom(0);
|
||||
expect(res.toFixed(5)).toBe("156543.03391");
|
||||
res = map.getResForZoom(5);
|
||||
expect(res.toFixed(5)).toBe("4891.96981");
|
||||
|
||||
});
|
||||
|
||||
it("returns correct getResForZoom when resolution array is set",function() {
|
||||
var map = ol.map({
|
||||
resolutions: [1,4,7,9,12]
|
||||
});
|
||||
|
||||
var res = map.getResForZoom(0);
|
||||
expect(res).toBe(1);
|
||||
res = map.getResForZoom(3);
|
||||
expect(res).toBe(9);
|
||||
|
||||
});
|
||||
|
||||
it("has no layers by default", function() {
|
||||
var map = ol.map();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user