Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Map "view" option may be a View2DOptions #400

Closed
wants to merge 2 commits into from

4 participants

Éric Lemoine Tom Payne Tim Schaub Andreas Hocevar
Éric Lemoine
Owner

Implements what's discussed in #340. To be discussed ; I don't mind throwing this away if people don't like it.

Requires #398.

Tom Payne

I like this.

Éric Lemoine
Owner

Branch updated. Still interested in opinions. Thank you @twpayne for giving yours already.

Tim Schaub
Owner

Is the build failure due to a different JSDoc version?

Éric Lemoine
Owner

I guess so. It looks like every build fails on Travis right now.

Andreas Hocevar
Owner

JSDoc3 now tries to parse Google Closure type declarations and fails with many types. I'm currently working on making our jsdoc story better, but I'll send a quick pull request that fixes this issue. Hold on, should be there in 5 min.

Andreas Hocevar
Owner

Travis build fails because of #405. Unfortunately I wasn't able to provide a quick fix.

Tom Payne

Can this be merged? The jsdoc3 build problems have been fixed in #415. It's a nice API clean up and problem just needs a little TLC to be merged.

Éric Lemoine
Owner

I think others probably don't like the typecast in the examples, and I'd understand that.

Éric Lemoine
Owner

I'm going to rebase my mapviewoption branch onto current master, and merge it, unless I get pushback before I get to it.

Éric Lemoine
Owner

Now rebased. I don't want to force this in, so please speak up if you don't want it.

Tom Payne

+1 from me.

Tom Payne

@elemoine, do you still want to merge this? Personally, I like it. The branch needs a little rebase loving to be merged, but is otherwise good.

Éric Lemoine
Owner

The ol.Map2D discussion makes me hesitant on this one. If we do want ol.Map2D or equivalent this PR probably doesn't make sense anymore.

Tom Payne

Thanks @elemoine. Personally, I prefer this PR to the ol.Map2D PR. (The ol.Map2D adds a lot of extra complexity to save the eight characters in view: { ... }.)

Éric Lemoine
Owner

Stalled issue. No consensus. Closing.

Éric Lemoine elemoine closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 144 additions and 68 deletions.
  1. +3 −2 examples/animation.js
  2. +3 −2 examples/bind-input.js
  3. +3 −2 examples/bing-maps.js
  4. +3 −2 examples/brightness-contrast.js
  5. +3 −2 examples/canvas-tiles.js
  6. +3 −2 examples/epsg-4326.js
  7. +3 −2 examples/export-map.js
  8. +1 −6 examples/full-screen.js
  9. +3 −2 examples/geolocation.js
  10. +3 −2 examples/hue-saturation.js
  11. +3 −2 examples/mapquest.js
  12. +3 −2 examples/mouse-position.js
  13. +3 −2 examples/overlay.js
  14. +3 −2 examples/preload.js
  15. +3 −2 examples/rotation.js
  16. +3 −2 examples/scale-line.js
  17. +3 −2 examples/semi-transparent-layer.js
  18. +3 −2 examples/side-by-side.js
  19. +3 −2 examples/simple.js
  20. +3 −2 examples/stamen.js
  21. +3 −2 examples/style-rules.js
  22. +3 −2 examples/tilejson.js
  23. +3 −3 examples/vector-layer.js
  24. +3 −2 examples/wms-custom-proj.js
  25. +3 −2 examples/wms-single-image-custom-proj.js
  26. +3 −2 examples/wms-single-image.js
  27. +3 −2 examples/wms-tiled.js
  28. +3 −2 examples/wmts-from-capabilities.js
  29. +3 −2 examples/wmts.js
  30. +3 −2 examples/zoomslider.js
  31. +1 −1  src/objectliterals.exports
  32. +11 −2 src/ol/map.js
  33. +1 −0  src/ol/view.exports
  34. +43 −0 test/spec/ol/map.test.js
5 examples/animation.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.animation');
goog.require('ol.easing');
goog.require('ol.layer.TileLayer');
@@ -29,7 +28,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: instanbul,
zoom: 6
})
5 examples/bind-input.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.dom.Input');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OpenStreetMap');
@@ -13,7 +12,9 @@ var map = new ol.Map({
layers: [layer],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
5 examples/bing-maps.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.BingMaps');
@@ -23,7 +22,9 @@ var map = new ol.Map({
layers: layers,
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: ol.projection.transform(
new ol.Coordinate(-123.1, 49.25), 'EPSG:4326', 'EPSG:3857'),
zoom: 8
5 examples/brightness-contrast.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.MapQuestOpenAerial');
@@ -14,7 +13,9 @@ var map = new ol.Map({
layers: [layer],
renderer: ol.RendererHint.WEBGL,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
5 examples/canvas-tiles.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.DebugTileSource');
@@ -25,7 +24,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: ol.projection.transform(
new ol.Coordinate(-0.1275, 51.507222), 'EPSG:4326', 'EPSG:3857'),
zoom: 10
5 examples/epsg-4326.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.control.ScaleLine');
goog.require('ol.control.ScaleLineUnits');
goog.require('ol.control.defaults');
@@ -32,7 +31,9 @@ var map = new ol.Map({
// The OSgeo server does not set cross origin headers, so we cannot use WebGL
renderers: [ol.RendererHint.CANVAS, ol.RendererHint.DOM],
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
projection: 'EPSG:4326',
center: new ol.Coordinate(0, 0),
zoom: 2
5 examples/export-map.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OpenStreetMap');
@@ -14,7 +13,9 @@ var map = new ol.Map({
],
renderer: ol.RendererHint.CANVAS,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
7 examples/full-screen.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.MapQuestOpenAerial');
@@ -12,11 +11,7 @@ var layer = new ol.layer.TileLayer({
var map = new ol.Map({
layers: [layer],
renderers: ol.RendererHints.createFromQueryData(),
- target: 'map',
- view: new ol.View2D({
- center: new ol.Coordinate(0, 0),
- zoom: 0
- })
+ target: 'map'
});
var view2d = map.getView().getView2D();
view2d.fitExtent(view2d.getProjection().getExtent(), map.getSize());
5 examples/geolocation.js
View
@@ -3,7 +3,6 @@ goog.require('ol.Geolocation');
goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OpenStreetMap');
@@ -16,7 +15,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
5 examples/hue-saturation.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.BingMaps');
@@ -18,7 +17,9 @@ var map = new ol.Map({
layers: [layer],
renderer: ol.RendererHint.WEBGL,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: ol.projection.transform(
new ol.Coordinate(-9.375, 51.483333), 'EPSG:4326', 'EPSG:3857'),
zoom: 15
5 examples/mapquest.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.MapQuestOSM');
@@ -15,7 +14,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: ol.projection.transform(
new ol.Coordinate(139.6917, 35.689506), 'EPSG:4326', 'EPSG:3857'),
zoom: 9
5 examples/mouse-position.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.control.MousePosition');
goog.require('ol.control.defaults');
goog.require('ol.layer.TileLayer');
@@ -24,7 +23,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
5 examples/overlay.js
View
@@ -2,7 +2,6 @@ goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
@@ -16,7 +15,9 @@ var map = new ol.Map({
layers: [layer],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
5 examples/preload.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.BingMaps');
@@ -18,7 +17,9 @@ var map1 = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map1',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(-4808600, -2620936),
zoom: 8
})
5 examples/rotation.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OpenStreetMap');
@@ -15,7 +14,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(-25860000, 4130000),
rotation: Math.PI / 6,
zoom: 10
5 examples/scale-line.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.control.ScaleLine');
goog.require('ol.control.ScaleLineUnits');
goog.require('ol.control.defaults');
@@ -22,7 +21,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
5 examples/semi-transparent-layer.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
@@ -22,7 +21,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: ol.projection.transform(
new ol.Coordinate(-77.93255, 37.9555), 'EPSG:4326', 'EPSG:3857'),
zoom: 5
5 examples/side-by-side.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.MapQuestOpenAerial');
@@ -14,7 +13,9 @@ var domMap = new ol.Map({
],
renderer: ol.RendererHint.DOM,
target: 'domMap',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 1
})
5 examples/simple.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OpenStreetMap');
@@ -14,7 +13,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
5 examples/stamen.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.Stamen');
@@ -23,7 +22,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: ol.projection.transform(
new ol.Coordinate(-122.416667, 37.783333), 'EPSG:4326', 'EPSG:3857'),
zoom: 12
5 examples/style-rules.js
View
@@ -3,7 +3,6 @@ goog.require('ol.Coordinate');
goog.require('ol.Expression');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.control.defaults');
goog.require('ol.filter.Filter');
goog.require('ol.layer.Vector');
@@ -127,7 +126,9 @@ var map = new ol.Map({
}),
renderer: ol.RendererHint.CANVAS,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 1
})
5 examples/tilejson.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.TileJSON');
@@ -17,7 +16,9 @@ var map = new ol.Map({
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
6 examples/vector-layer.js
View
@@ -2,7 +2,6 @@ goog.require('ol.Collection');
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
@@ -37,7 +36,9 @@ var map = new ol.Map({
layers: new ol.Collection([raster, vector]),
renderer: ol.RendererHint.CANVAS,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 1
})
@@ -61,4 +62,3 @@ xhr.onload = function() {
}
};
xhr.send();
-
5 examples/wms-custom-proj.js
View
@@ -3,7 +3,6 @@ goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.control.ScaleLine');
goog.require('ol.control.ScaleLineUnits');
goog.require('ol.control.defaults');
@@ -57,7 +56,9 @@ var map = new ol.Map({
layers: layers,
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
projection: projection,
center: new ol.Coordinate(660000, 190000),
zoom: 2
5 examples/wms-single-image-custom-proj.js
View
@@ -3,7 +3,6 @@ goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHints');
-goog.require('ol.View2D');
goog.require('ol.layer.ImageLayer');
goog.require('ol.projection');
goog.require('ol.source.SingleImageWMS');
@@ -49,7 +48,9 @@ var map = new ol.Map({
layers: layers,
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
projection: projection,
center: new ol.Coordinate(660000, 190000),
zoom: 2
5 examples/wms-single-image.js
View
@@ -2,7 +2,6 @@ goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.ImageLayer');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.MapQuestOpenAerial');
@@ -25,7 +24,9 @@ var map = new ol.Map({
renderer: ol.RendererHint.CANVAS,
layers: layers,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(-10997148, 4569099),
zoom: 4
})
5 examples/wms-tiled.js
View
@@ -2,7 +2,6 @@ goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.TiledWMS');
@@ -24,7 +23,9 @@ var map = new ol.Map({
renderer: ol.RendererHint.CANVAS,
layers: layers,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(-10997148, 4569099),
zoom: 4
})
5 examples/wmts-from-capabilities.js
View
@@ -1,7 +1,6 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.parser.ogc.WMTSCapabilities');
goog.require('ol.source.WMTS');
@@ -39,7 +38,9 @@ xhr.onload = function() {
],
renderer: ol.RendererHint.CANVAS,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(1823849, 6143760),
projection: 'EPSG:3857',
zoom: 11
5 examples/wmts.js
View
@@ -2,7 +2,6 @@ goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.Map');
goog.require('ol.RendererHint');
-goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.projection');
goog.require('ol.source.OpenStreetMap');
@@ -46,7 +45,9 @@ var map = new ol.Map({
],
renderer: ol.RendererHint.CANVAS,
target: 'map',
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(-13677832, 5213272),
zoom: 13
})
5 examples/zoomslider.js
View
@@ -1,6 +1,5 @@
goog.require('ol.Coordinate');
goog.require('ol.Map');
-goog.require('ol.View2D');
goog.require('ol.control.ZoomSlider');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.MapQuestOpenAerial');
@@ -25,7 +24,9 @@ var createMap = function(divId) {
map = new ol.Map({
layers: [layer],
target: divId,
- view: new ol.View2D({
+ // ol.View2DOptions typecast required only when example
+ // code is compiled with Closure Compiler
+ view: /** @type {ol.View2DOptions} */ ({
center: new ol.Coordinate(0, 0),
zoom: 2
})
2  src/objectliterals.exports
View
@@ -5,7 +5,7 @@
@exportObjectLiteralProperty ol.MapOptions.renderer ol.RendererHint|undefined
@exportObjectLiteralProperty ol.MapOptions.renderers Array.<ol.RendererHint>|undefined
@exportObjectLiteralProperty ol.MapOptions.target Element|string
-@exportObjectLiteralProperty ol.MapOptions.view ol.IView|undefined
+@exportObjectLiteralProperty ol.MapOptions.view ol.View|ol.View2DOptions|undefined
@exportObjectLiteral ol.View2DOptions
@exportObjectLiteralProperty ol.View2DOptions.center ol.Coordinate|undefined
13 src/ol/map.js
View
@@ -880,8 +880,17 @@ ol.Map.createOptionsInternal = function(mapOptions) {
}
values[ol.MapProperty.LAYERS] = layers;
- values[ol.MapProperty.VIEW] = goog.isDef(mapOptions.view) ?
- mapOptions.view : new ol.View2D();
+ var view;
+ if (goog.isDefAndNotNull(mapOptions.view)) {
+ if (!(mapOptions.view instanceof ol.View)) {
+ view = new ol.View2D(mapOptions.view);
+ } else {
+ view = mapOptions.view;
+ }
+ } else {
+ view = new ol.View2D();
+ }
+ values[ol.MapProperty.VIEW] = view;
/**
* @type {function(new: ol.renderer.Map, Element, ol.Map)}
1  src/ol/view.exports
View
@@ -0,0 +1 @@
+@exportSymbol ol.View
43 test/spec/ol/map.test.js
View
@@ -120,6 +120,48 @@ describe('ol.Map', function() {
});
});
+ describe('#createOptionsInternal', function() {
+
+ describe('create view', function() {
+
+ var options;
+ beforeEach(function() {
+ options = {
+ target: document.createElement('div')
+ };
+ });
+
+ describe('no view property provided', function() {
+ it('creates a View2D object', function() {
+ var o = ol.Map.createOptionsInternal(options);
+ expect(o.values.view).to.be.a(ol.View2D);
+ });
+ });
+
+ describe('ol.View object provided', function() {
+ it('does not create a new object', function() {
+ var view = new ol.View2D();
+ options.view = view;
+ var o = ol.Map.createOptionsInternal(options);
+ expect(o.values.view).to.be.a(ol.View2D);
+ expect(o.values.view).to.be(view);
+ });
+ });
+
+ describe('view options provided', function() {
+ it('creates a View2D object with expected states', function() {
+ var view = {center: new ol.Coordinate(1, 1)};
+ options.view = view;
+ var o = ol.Map.createOptionsInternal(options);
+ expect(o.values.view).to.be.a(ol.View2D);
+ var center = o.values.view.getCenter();
+ expect(center.x).to.be.eql(1);
+ expect(center.y).to.be.eql(1);
+ });
+ });
+ });
+ });
+
describe('user animation', function() {
var layer, map;
@@ -229,6 +271,7 @@ goog.require('ol.Coordinate');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.RendererHints');
+goog.require('ol.View');
goog.require('ol.View2D');
goog.require('ol.interaction.DblClickZoom');
goog.require('ol.interaction.MouseWheelZoom');
Something went wrong with that request. Please try again.