diff --git a/src/ol/Map.js b/src/ol/Map.js index 02bda8f5fa..7f2a3d4a29 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -9,6 +9,8 @@ goog.require('ol.control.Control'); goog.require('ol.renderer.MapRenderer'); goog.require('goog.dom'); +goog.require('goog.math'); + /** * @export @@ -259,6 +261,23 @@ ol.Map.prototype.getResolutionForZoom = function(zoom) { }; +/** + * @param {goog.math.Coordinate|{x: number, y: number}} pixel + * @return {ol.Loc} + */ +ol.Map.prototype.getLocForPixel = function(pixel) { + return this.renderer_.getLocForPixel(pixel); +}; + + +/** + * @return {goog.math.Size} The currently rendered map size in pixels. + */ +ol.Map.prototype.getSize = function() { + return this.renderer_.getSize(); +}; + + /** * @param {ol.Loc} center Center in map projection. */ @@ -268,6 +287,17 @@ ol.Map.prototype.setCenter = function(center) { }; +/** + * @param {number} zoom + * @param {ol.Loc} center + */ +ol.Map.prototype.zoomTo = function(zoom, center) { + this.zoom_ = this.limitZoom(zoom); + this.center_ = center; + this.conditionallyRender(); +}; + + /** * @param {ol.Projection} projection Projection. */ @@ -288,13 +318,23 @@ ol.Map.prototype.setUserProjection = function(userProjection) { * @param {number} zoom Zoom. */ ol.Map.prototype.setZoom = function(zoom) { - if (zoom !== this.zoom_ && zoom >= 0 && zoom < this.getNumZoomLevels()) { + zoom = this.limitZoom(zoom); + if (zoom !== this.zoom_) { this.zoom_ = zoom; this.conditionallyRender(); } }; +/** + * @param {number} zoom + * @return {number} zoom clamped to the range of available zoom levels. + */ +ol.Map.prototype.limitZoom = function(zoom) { + return goog.math.clamp(zoom, 0, this.getNumZoomLevels()-1); +}; + + /** * @param {number} nZoom Zoom. */ diff --git a/src/ol/renderer/Composite.js b/src/ol/renderer/Composite.js index 1a7b53d43d..7f2ffa86e5 100644 --- a/src/ol/renderer/Composite.js +++ b/src/ol/renderer/Composite.js @@ -49,6 +49,8 @@ ol.renderer.Composite.prototype.draw = function(layers, center, resolution, anim for (var i=0, ii=layers.length; i