allow people to specify projection as a string #272

Merged
merged 4 commits into from Mar 7, 2013
Jump to file
+176 −163
Split
@@ -25,7 +25,7 @@ var map = new ol.Map({
// Vienna label
var vienna = new ol.AnchoredElement({
map: map,
- position: ol.projection.transformWithCodes(
+ position: ol.projection.transform(
new ol.Coordinate(16.3725, 48.208889), 'EPSG:4326', 'EPSG:3857'),
element: document.getElementById('vienna')
});
@@ -39,7 +39,7 @@ map.addEventListener('click', function(evt) {
var coordinate = evt.getCoordinate();
popup.getElement().innerHTML =
'Welcome to ol3. The location you clicked was<br>' +
- ol.Coordinate.toStringHDMS(ol.projection.transformWithCodes(
+ ol.Coordinate.toStringHDMS(ol.projection.transform(
coordinate, 'EPSG:3857', 'EPSG:4326'));
popup.setPosition(coordinate);
});
View
@@ -9,15 +9,15 @@ goog.require('ol.projection');
goog.require('ol.source.OpenStreetMap');
-var london = ol.projection.transformWithCodes(
+var london = ol.projection.transform(
new ol.Coordinate(-0.12755, 51.507222), 'EPSG:4326', 'EPSG:3857');
-var moscow = ol.projection.transformWithCodes(
+var moscow = ol.projection.transform(
new ol.Coordinate(37.6178, 55.7517), 'EPSG:4326', 'EPSG:3857');
-var instanbul = ol.projection.transformWithCodes(
+var instanbul = ol.projection.transform(
new ol.Coordinate(28.9744, 41.0128), 'EPSG:4326', 'EPSG:3857');
-var rome = ol.projection.transformWithCodes(
+var rome = ol.projection.transform(
new ol.Coordinate(12.5, 41.9), 'EPSG:4326', 'EPSG:3857');
-var bern = ol.projection.transformWithCodes(
+var bern = ol.projection.transform(
new ol.Coordinate(7.4458, 46.95), 'EPSG:4326', 'EPSG:3857');
var map = new ol.Map({
View
@@ -19,7 +19,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
- center: ol.projection.transformWithCodes(
+ center: ol.projection.transform(
new ol.Coordinate(-123.1, 49.25), 'EPSG:4326', 'EPSG:3857'),
zoom: 8
})
View
@@ -15,7 +15,7 @@ var layers = [
}),
new ol.layer.TileLayer({
source: new ol.source.DebugTileSource({
- projection: ol.projection.getFromCode('EPSG:3857'),
+ projection: 'EPSG:3857',
tileGrid: new ol.tilegrid.XYZ({
maxZoom: 22
})
@@ -25,7 +25,7 @@ var layers = [
var webglMap = new ol.Map({
view: new ol.View2D({
- center: ol.projection.transformWithCodes(
+ center: ol.projection.transform(
new ol.Coordinate(-0.1275, 51.507222), 'EPSG:4326', 'EPSG:3857'),
zoom: 10
}),
View
@@ -35,7 +35,7 @@ var map = new ol.Map({
renderers: [ol.RendererHint.CANVAS, ol.RendererHint.DOM],
target: 'map',
view: new ol.View2D({
- projection: ol.projection.getFromCode('EPSG:4326'),
+ projection: 'EPSG:4326',
center: new ol.Coordinate(0, 0),
zoom: 2
})
View
@@ -16,7 +16,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
- center: ol.projection.transformWithCodes(
+ center: ol.projection.transform(
new ol.Coordinate(139.6917, 35.689506), 'EPSG:4326', 'EPSG:3857'),
zoom: 9
})
@@ -13,7 +13,7 @@ var map = new ol.Map({
controls: ol.control.defaults({}, [
new ol.control.MousePosition({
coordinateFormat: ol.Coordinate.toStringHDMS,
- projection: ol.projection.getFromCode('EPSG:4326'),
+ projection: 'EPSG:4326',
target: document.getElementById('mouse-position'),
undefinedHTML: '&nbsp;'
})
View
@@ -11,9 +11,9 @@ goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
-var LONDON = ol.projection.transformWithCodes(
+var LONDON = ol.projection.transform(
new ol.Coordinate(-0.12755, 51.507222), 'EPSG:4326', 'EPSG:3857');
-var MOSCOW = ol.projection.transformWithCodes(
+var MOSCOW = ol.projection.transform(
new ol.Coordinate(37.6178, 55.7517), 'EPSG:4326', 'EPSG:3857');
var layer = new ol.layer.TileLayer({
View
@@ -23,7 +23,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
- center: ol.projection.transformWithCodes(
+ center: ol.projection.transform(
new ol.Coordinate(-122.416667, 37.783333), 'EPSG:4326', 'EPSG:3857'),
zoom: 12
})
View
@@ -11,7 +11,7 @@
@exportObjectLiteralProperty ol.View2DOptions.center ol.Coordinate|undefined
@exportObjectLiteralProperty ol.View2DOptions.maxResolution number|undefined
@exportObjectLiteralProperty ol.View2DOptions.numZoomLevels number|undefined
-@exportObjectLiteralProperty ol.View2DOptions.projection ol.Projection|string|undefined
+@exportObjectLiteralProperty ol.View2DOptions.projection ol.ProjectionLike
@exportObjectLiteralProperty ol.View2DOptions.resolution number|undefined
@exportObjectLiteralProperty ol.View2DOptions.resolutions Array.<number>|undefined
@exportObjectLiteralProperty ol.View2DOptions.rotation number|undefined
@@ -61,7 +61,7 @@
@exportObjectLiteral ol.control.MousePositionOptions
@exportObjectLiteralProperty ol.control.MousePositionOptions.coordinateFormat ol.CoordinateFormatType|undefined
@exportObjectLiteralProperty ol.control.MousePositionOptions.map ol.Map|undefined
-@exportObjectLiteralProperty ol.control.MousePositionOptions.projection ol.Projection|undefined
+@exportObjectLiteralProperty ol.control.MousePositionOptions.projection ol.ProjectionLike
@exportObjectLiteralProperty ol.control.MousePositionOptions.target Element|undefined
@exportObjectLiteralProperty ol.control.MousePositionOptions.undefinedHTML string|undefined
@@ -103,15 +103,15 @@
@exportObjectLiteral ol.source.DebugTileSourceOptions
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.extent ol.Extent|undefined
-@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.projection ol.Projection|undefined
+@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.projection ol.ProjectionLike
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.tileGrid ol.tilegrid.TileGrid|undefined
@exportObjectLiteral ol.source.SingleImageWMSOptions
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.attributions Array.<ol.Attribution>|undefined
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.crossOrigin null|string|undefined
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.extent ol.Extent|undefined
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.params Object.<string,*>
-@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.projection ol.Projection|undefined
+@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.projection ol.ProjectionLike
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.resolutions Array.<number>|undefined
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.url string|undefined
@@ -128,7 +128,7 @@
@exportObjectLiteralProperty ol.source.StaticImageOptions.extent ol.Extent|undefined
@exportObjectLiteralProperty ol.source.StaticImageOptions.imageExtent ol.Extent|undefined
@exportObjectLiteralProperty ol.source.StaticImageOptions.imageSize ol.Size|undefined
-@exportObjectLiteralProperty ol.source.StaticImageOptions.projection ol.Projection|undefined
+@exportObjectLiteralProperty ol.source.StaticImageOptions.projection ol.ProjectionLike
@exportObjectLiteralProperty ol.source.StaticImageOptions.url string|undefined
@exportObjectLiteral ol.source.TiledWMSOptions
@@ -138,7 +138,7 @@
@exportObjectLiteralProperty ol.source.TiledWMSOptions.extent ol.Extent|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.tileGrid ol.tilegrid.TileGrid|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.maxZoom number|undefined
-@exportObjectLiteralProperty ol.source.TiledWMSOptions.projection ol.Projection|undefined
+@exportObjectLiteralProperty ol.source.TiledWMSOptions.projection ol.ProjectionLike
@exportObjectLiteralProperty ol.source.TiledWMSOptions.url string|undefined
@exportObjectLiteralProperty ol.source.TiledWMSOptions.urls Array.<string>|undefined
@@ -41,9 +41,9 @@ ol.control.MousePosition = function(opt_options) {
/**
* @private
- * @type {ol.Projection|undefined}
+ * @type {ol.Projection}
*/
- this.projection_ = options.projection;
+ this.projection_ = ol.projection.get(options.projection);
/**
* @private
@@ -168,8 +168,8 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
var html = this.undefinedHTML_;
if (!goog.isNull(pixel)) {
if (this.renderedProjection_ != this.mapProjection_) {
- if (goog.isDef(this.projection_)) {
- this.transform_ = ol.projection.getTransform(
+ if (!goog.isNull(this.projection_)) {
+ this.transform_ = ol.projection.getTransformFromProjections(
this.mapProjection_, this.projection_);
} else {
this.transform_ = ol.projection.identityTransform;
@@ -176,8 +176,8 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
// Convert pointResolution from meters or feet to degrees
if (goog.isNull(this.toEPSG4326_)) {
- this.toEPSG4326_ = ol.projection.getTransform(
- projection, ol.projection.getFromCode('EPSG:4326'));
+ this.toEPSG4326_ = ol.projection.getTransformFromProjections(
+ projection, ol.projection.get('EPSG:4326'));
}
var vertex = [center.x, center.y];
vertex = this.toEPSG4326_(vertex, vertex, 2);
View
@@ -76,8 +76,8 @@ ol.Geolocation.prototype.disposeInternal = function() {
ol.Geolocation.prototype.handleProjectionChanged_ = function() {
var projection = this.getProjection();
if (goog.isDefAndNotNull(projection)) {
- this.transformFn_ = ol.projection.getTransform(
- ol.projection.getFromCode('EPSG:4326'), projection);
+ this.transformFn_ = ol.projection.getTransformFromProjections(
+ ol.projection.get('EPSG:4326'), projection);
if (!goog.isNull(this.position_)) {
var vertex = [this.position_.x, this.position_.y];
vertex = this.transformFn_(vertex, vertex, 2);
@@ -79,7 +79,7 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
var topLeftCorner = this.getChildValue(node);
var coords = topLeftCorner.split(' ');
var axisOrientation =
- ol.projection.getFromCode(obj['supportedCRS']).getAxisOrientation();
+ ol.projection.get(obj['supportedCRS']).getAxisOrientation();
obj['topLeftCorner'] = ol.Coordinate.fromProjectedArray(
[parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation);
},
@@ -13,9 +13,9 @@
@exportProperty ol.ProjectionUnits.METERS
@exportSymbol ol.projection.addProjection
-@exportSymbol ol.projection.getFromCode
+@exportSymbol ol.projection.get
@exportSymbol ol.projection.getTransform
-@exportSymbol ol.projection.getTransformFromCodes
+@exportSymbol ol.projection.getTransformFromProjections
@exportSymbol ol.projection.transform
-@exportSymbol ol.projection.transformWithCodes
+@exportSymbol ol.projection.transformWithProjections
@exportSymbol ol.projection.configureProj4jsProjection
Oops, something went wrong.