map get/set methods

This commit is contained in:
Mike Adair
2012-06-19 08:06:08 -04:00
3 changed files with 100 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ goog.require('ol.Loc');
goog.require('ol.Map');
goog.require('ol.Projection');
goog.require('ol.loc');
goog.require('ol.projection');
/**
@@ -24,6 +25,8 @@ ol.map = function(opt_arg){
var zoom;
/** @type {number|undefined} */
var numZoomLevels;
/** @type {ol.Projection|undefined} */
var projection;
var target;
var map = new ol.Map();
@@ -47,6 +50,10 @@ ol.map = function(opt_arg){
numZoomLevels = config.numZoomLevels;
map.setNumZoomLevels(numZoomLevels);
}
if (goog.isDef(config.projection)) {
projection = config.projection;
map.setProjection(projection);
}
if (goog.isDef(config.target)) {
target = config.target;
}
@@ -72,23 +79,35 @@ ol.Map.prototype.center = function(opt_arg) {
}
};
/**
* @param {number|undefined} opt_arg Get or set the current zoom level.
* @returns {ol.Map|number|undefined} current zoom level on get or the map.
*/
ol.Map.prototype.zoom = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setZoom(opt_arg);
} else {
return this.getZoom();
}
};
/**
* @param {ol.Projection|string|undefined} opt_arg Get or set the map projection.
* @returns {ol.Map|number|undefined} the current zoom level, or the map on set.
*/
ol.Map.prototype.projection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setProjection(ol.projection(opt_arg));
} else {
return this.getProjection();
}
};
/**
* @param {ol.ProjectionLike=} opt_arg
* @returns {ol.Map|ol.Loc|undefined}
*/
ol.Map.prototype.userProjection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setUserProjection(ol.projection(opt_arg));
} else {
return this.getUserProjection();
}
};
/**
* @param {number|undefined} opt_arg Get or set the current zoom level.
* @returns {ol.Map|number|undefined} current zoom level on get or the map.
*/
ol.Map.prototype.zoom = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setZoom(opt_arg);
} else {