map initialization

This commit is contained in:
Mike Adair
2012-06-19 09:23:58 -04:00
4 changed files with 32 additions and 16 deletions

View File

@@ -17,15 +17,15 @@
"checks": {
// "accessControls": "ERROR",
// "visibility": "ERROR"
"checkTypes": "ERROR",
"checkRegExp": "ERROR",
"checkVars": "ERROR",
"deprecated": "ERROR",
"fileoverviewTags": "ERROR",
"invalidCasts": "ERROR",
"missingProperties": "ERROR",
"nonStandardJsDocs": "ERROR",
"undefinedVars": "ERROR"
// "checkTypes": "ERROR",
// "checkRegExp": "ERROR",
// "checkVars": "ERROR",
// "deprecated": "ERROR",
// "fileoverviewTags": "ERROR",
// "invalidCasts": "ERROR",
// "missingProperties": "ERROR",
// "nonStandardJsDocs": "ERROR",
// "undefinedVars": "ERROR"
},
"jsdoc-html-output-path": "."

View File

@@ -113,3 +113,15 @@ ol.Map.prototype.zoom = function(opt_arg) {
return this.getZoom();
}
};
/**
* @param {number=} opt_arg
* @returns {ol.Map|number|undefined} Map center.
*/
ol.Map.prototype.numZoomLevels = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setNumZoomLevels(opt_arg);
} else {
return this.getNumZoomLevels();
}
};

View File

@@ -42,12 +42,16 @@ ol.Map = function() {
};
ol.Map.prototype.defaults = {};
/**
@const
@type {string}
*/
ol.Map.prototype.defaults.projection = "EPSG:3857";
ol.Map.prototype.defaults.userProjection = "EPSG:4326";
ol.Map.prototype.DEFAULT_PROJECTION = "EPSG:3857";
/**
@const
@type {string}
*/
ol.Map.prototype.DEFAULT_USER_PROJECTION = "EPSG:4326";
/**
@@ -63,7 +67,7 @@ ol.Map.prototype.getCenter = function() {
*/
ol.Map.prototype.getProjection = function() {
if (!goog.isDef(this.projection_)) {
this.projection_ = new ol.Projection(this.defaults.projection);
this.projection_ = new ol.Projection(this.DEFAULT_PROJECTION);
}
return this.projection_;
};
@@ -74,7 +78,7 @@ ol.Map.prototype.getProjection = function() {
*/
ol.Map.prototype.getUserProjection = function() {
if (!goog.isDef(this.userProjection_)) {
this.userProjection_ = new ol.Projection(this.defaults.userProjection_);
this.userProjection_ = new ol.Projection(this.DEFAULT_USER_PROJECTION);
}
return this.userProjection_;
};

View File

@@ -63,8 +63,8 @@ describe("ol.Map", function() {
center = map.center();
zoom = map.zoom();
expect(center.x().toFixed(3)).toBe("1.000");
expect(center.y().toFixed(3)).toBe("2.000");
expect(center.x().toFixed(3)).toBe("4.000");
expect(center.y().toFixed(3)).toBe("5.000");
expect(zoom).toBe(6);
});