From 77c07a500ef02d5ed5aa9b8402d64599288f031f Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 19 Jun 2012 11:14:53 +0200 Subject: [PATCH] A passing test. --- main.js | 14 -------------- main.json | 8 ++------ src/api/projection.js | 25 +++++++++++++++---------- src/ol.js | 4 ++++ test/index.html | 5 +---- test/spec/ol/Projection.test.js | 5 ++++- 6 files changed, 26 insertions(+), 35 deletions(-) delete mode 100644 main.js create mode 100644 src/ol.js diff --git a/main.js b/main.js deleted file mode 100644 index ab8ea1c9e5..0000000000 --- a/main.js +++ /dev/null @@ -1,14 +0,0 @@ - -goog.provide('ol'); - -goog.require('ol.map'); -goog.require('goog.dom'); - -var map; -ol.main = function() { - goog.dom.getElement('output').innerHTML = 'test'; - map = ol.map().center([45, 5]); -}; - -window['main'] = ol.main; -goog.exportSymbol('map', map); diff --git a/main.json b/main.json index 7d7a018743..58dc4c978d 100644 --- a/main.json +++ b/main.json @@ -1,15 +1,11 @@ { - "id": "main", + "id": "ol", - "inputs": "main.js", + "inputs": "src/ol.js", "paths": [ "." ], - "externs": [ - "//google_maps_api_v3.js" - ], - "define": { // "goog.dom.ASSUME_STANDARDS_MODE": true, "goog.DEBUG": true diff --git a/src/api/projection.js b/src/api/projection.js index 403fc88d0e..75d0bda3b0 100644 --- a/src/api/projection.js +++ b/src/api/projection.js @@ -15,20 +15,25 @@ ol.ProjectionLike; * @return {ol.Projection} Projection. */ ol.projection = function(opt_arg){ - var code; - if (arguments.length == 1) { + var code, units; + if (arguments.length == 1 && goog.isDef(opt_arg)) { if (opt_arg instanceof ol.Projection) { return opt_arg; } - else - if (goog.isString(arguments[0])) { - code = arguments[0]; - } - else { - throw new Error('ol.projection'); - } + else if (goog.isString(opt_arg)) { + code = opt_arg; + } + else if (goog.isObject(opt_arg)) { + code = opt_arg['code']; + units = opt_arg['units']; + } + else { + throw new Error('ol.projection'); + } } - return new ol.Projection(code); + var proj = new ol.Projection(); + proj.setCode(code); + return proj; }; diff --git a/src/ol.js b/src/ol.js new file mode 100644 index 0000000000..db0827deb2 --- /dev/null +++ b/src/ol.js @@ -0,0 +1,4 @@ +goog.provide("ol"); +goog.require("ol.map"); +goog.require("ol.loc"); +goog.require("ol.projection"); diff --git a/test/index.html b/test/index.html index f6e1e1c88d..9bdbde2ab7 100644 --- a/test/index.html +++ b/test/index.html @@ -9,10 +9,7 @@ - - - - + diff --git a/test/spec/ol/Projection.test.js b/test/spec/ol/Projection.test.js index b6a4666538..fa51cebaa9 100644 --- a/test/spec/ol/Projection.test.js +++ b/test/spec/ol/Projection.test.js @@ -6,7 +6,10 @@ describe("ol.Projection", function() { p = ol.projection("foo"); expect(p.code()).toBe("foo"); - p = ol.projection({code: "bar"}); + p = ol.projection({ + code: "bar", + units: "m" + }); expect(p.code()).toBe("bar"); });