Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Map "view" option may be a View2DOptions #400

Closed
wants to merge 2 commits into from

4 participants

@elemoine
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.

@twpayne

I like this.

@elemoine
Owner

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

@tschaub
Owner

Is the build failure due to a different JSDoc version?

@elemoine
Owner

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

@ahocevar
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.

@ahocevar
Owner

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

@twpayne

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.

@elemoine
Owner

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

@elemoine
Owner

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

@elemoine
Owner

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

@twpayne

+1 from me.

@twpayne

@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.

@elemoine
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.

@twpayne

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: { ... }.)

@elemoine
Owner

Stalled issue. No consensus. Closing.

@elemoine elemoine closed this
@elemoine elemoine deleted the elemoine:mapviewoption branch
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
View
5 examples/animation.js
@@ -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
})
View
5 examples/bind-input.js
@@ -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
})
View
5 examples/bing-maps.js
@@ -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
View
5 examples/brightness-contrast.js
@@ -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
})
View
5 examples/canvas-tiles.js
@@ -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
View
5 examples/epsg-4326.js
@@ -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
View
5 examples/export-map.js
@@ -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
})
View
7 examples/full-screen.js
@@ -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());
View
5 examples/geolocation.js
@@ -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
})
View
5 examples/hue-saturation.js
@@ -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
View
5 examples/mapquest.js
@@ -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
View
5 examples/mouse-position.js
@@ -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
})
View
5 examples/overlay.js
@@ -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
})
View
5 examples/preload.js
@@ -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
})
View
5 examples/rotation.js
@@ -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
View
5 examples/scale-line.js
@@ -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
})
View
5 examples/semi-transparent-layer.js
@@ -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
View
5 examples/side-by-side.js
@@ -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
})
View
5 examples/simple.js
@@ -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
})
View
5 examples/stamen.js
@@ -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
View
5 examples/style-rules.js
@@ -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
})
View
5 examples/tilejson.js
@@ -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
})
View
6 examples/vector-layer.js
@@ -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();
-
View
5 examples/wms-custom-proj.js
@@ -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
View
5 examples/wms-single-image-custom-proj.js
@@ -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
View
5 examples/wms-single-image.js
@@ -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
})
View
5 examples/wms-tiled.js
@@ -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
})
View
5 examples/wmts-from-capabilities.js
@@ -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
View
5 examples/wmts.js
@@ -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
})
View
5 examples/zoomslider.js
@@ -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
})
View
2  src/objectliterals.exports
@@ -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
View
13 src/ol/map.js
@@ -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)}
View
1  src/ol/view.exports
@@ -0,0 +1 @@
+@exportSymbol ol.View
View
43 test/spec/ol/map.test.js
@@ -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.