interim map test updates

This commit is contained in:
Mike Adair
2012-06-19 06:53:59 -04:00
parent 95fe8762da
commit 818ca7016a
2 changed files with 78 additions and 5 deletions

View File

@@ -20,8 +20,14 @@ ol.map = function(opt_arg){
/** @type {ol.Loc|undefined} */
var center;
/** @type {number|undefined} */
var zoom;
/** @type {number|undefined} */
var numZoomLevels;
var target;
var map = new ol.Map();
if (arguments.length == 1) {
if (opt_arg instanceof ol.Map) {
return opt_arg;
@@ -31,6 +37,15 @@ ol.map = function(opt_arg){
var config = opt_arg;
if (goog.isDef(config.center)) {
center = ol.loc(config.center);
map.setCenter(center);
}
if (goog.isDef(config.zoom)) {
zoom = config.zoom;
map.setZoom(zoom);
}
if (goog.isDef(config.numZoomLevels)) {
numZoomLevels = config.numZoomLevels;
map.setNumZoomLevels(numZoomLevels);
}
if (goog.isDef(config.target)) {
target = config.target;
@@ -41,15 +56,13 @@ ol.map = function(opt_arg){
}
}
var map = new ol.Map();
return map;
};
/**
* @param {ol.LocLike=} opt_arg
* @returns {ol.Map|ol.Loc|undefined} Map center.
* @param {ol.LocLike=} opt_arg Get or set the map center.
* @returns {ol.Map|ol.Loc|undefined} The map center, or the map on set.
*/
ol.Map.prototype.center = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
@@ -58,3 +71,39 @@ ol.Map.prototype.center = function(opt_arg) {
return this.getCenter();
}
};
/**
* @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.setZoom(opt_arg);
} else {
return this.getZoom();
}
};
/**
* @param {number|undefined} opt_arg Get or set the number of zoom levels.
* @returns {ol.Map|number|undefined} the number of zoom levels, or the map on set.
*/
ol.Map.prototype.numZoomLevels = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setNumZoomLevels(opt_arg);
} else {
return this.getNumZoomLevels();
}
};