From a6fb72c240891ab766aa875dc42d178d336d8738 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 10 Sep 2013 17:44:43 -0600 Subject: [PATCH 1/6] Export XYZ source --- src/ol/source/xyzsource.exports | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/ol/source/xyzsource.exports diff --git a/src/ol/source/xyzsource.exports b/src/ol/source/xyzsource.exports new file mode 100644 index 0000000000..03f275a2ed --- /dev/null +++ b/src/ol/source/xyzsource.exports @@ -0,0 +1 @@ +@exportSymbol ol.source.XYZ \ No newline at end of file From 0df6cebff9a6e0d4dd7399cc4c9e13ab97572a13 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 10 Sep 2013 18:21:15 -0600 Subject: [PATCH 2/6] minZoom is not a supported property of ol.tilegrid.XYZOptions --- src/ol/source/xyzsource.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index 0711564798..bbb91c2808 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -50,8 +50,7 @@ ol.source.XYZ = function(options) { } var tileGrid = new ol.tilegrid.XYZ({ - maxZoom: options.maxZoom, - minZoom: options.minZoom + maxZoom: options.maxZoom }); var tileCoordTransform = tileGrid.createTileCoordTransform({ From 8d7d1412c9eea29950b73e2c0a799945524272fa Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 10 Sep 2013 18:23:48 -0600 Subject: [PATCH 3/6] Adding XYZOptions to objectliterals.jsdoc I remain uncertain about when to use the @exportClass annotation and when to use the @exportSymbol. osmsource.exports seems to get away with simply @exportSymbol, but many other sources use @exportProperty. --- src/objectliterals.jsdoc | 18 ++++++++++++++++++ src/ol/source/xyzsource.exports | 2 +- src/ol/source/xyzsource.js | 16 ---------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 67add829a9..5d5f2e11eb 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -605,6 +605,24 @@ * @property {Array.|undefined} urls Urls. */ +/** + * @typedef {Object} ol.source.XYZOptions + * @property {Array.|undefined} attributions Attributions. + * @property {null|string|undefined} crossOrigin Cross origin setting for image + * requests. + * @property {ol.Extent|undefined} extent Extent. + * @property {string|undefined} logo Logo. + * @property {ol.ProjectionLike} projection Projection. + * @property {number} maxZoom Max zoom. + * @property {number|undefined} minZoom Unsupported (TODO: remove this). + * @property {ol.TileUrlFunctionType|undefined} tileUrlFunction Optional + * function to get tile URL given a tile coordinate and the projection. + * Required if url or urls are not provided. + * @property {string|undefined} url URL template. Must include '{x}', '{y}', + * and '{z}' placeholders. + * @property {Array.|undefined} urls An array of URL templates. + */ + /** * @typedef {Object} ol.style.IconOptions * @property {string|ol.expr.Expression} url Icon image url. diff --git a/src/ol/source/xyzsource.exports b/src/ol/source/xyzsource.exports index 03f275a2ed..6384d2777f 100644 --- a/src/ol/source/xyzsource.exports +++ b/src/ol/source/xyzsource.exports @@ -1 +1 @@ -@exportSymbol ol.source.XYZ \ No newline at end of file +@exportClass ol.source.XYZ ol.source.XYZOptions diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index bbb91c2808..c40d20865e 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -1,5 +1,4 @@ goog.provide('ol.source.XYZ'); -goog.provide('ol.source.XYZOptions'); goog.require('ol.Attribution'); goog.require('ol.Projection'); @@ -10,21 +9,6 @@ goog.require('ol.source.TileImage'); goog.require('ol.tilegrid.XYZ'); -/** - * @typedef {{attributions: (Array.|undefined), - * crossOrigin: (string|undefined), - * extent: (ol.Extent|undefined), - * logo: (string|undefined), - * maxZoom: number, - * minZoom: (number|undefined), - * projection: (ol.Projection|undefined), - * tileUrlFunction: (ol.TileUrlFunctionType|undefined), - * url: (string|undefined), - * urls: (Array.|undefined)}} - */ -ol.source.XYZOptions; - - /** * @constructor From 843334627ed91f464d91591b94885d7adbf6fce2 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 10 Sep 2013 18:27:53 -0600 Subject: [PATCH 4/6] Moving maxZoom default to XYZ source. No reason this convenience should be restricted to the OSM layer. --- src/objectliterals.jsdoc | 3 ++- src/ol/source/osmsource.js | 4 +--- src/ol/source/xyzsource.js | 4 +++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 5d5f2e11eb..47e3fd108e 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -613,7 +613,8 @@ * @property {ol.Extent|undefined} extent Extent. * @property {string|undefined} logo Logo. * @property {ol.ProjectionLike} projection Projection. - * @property {number} maxZoom Max zoom. + * @property {number|undefined} maxZoom Optional max zoom level. The default is + * 18. * @property {number|undefined} minZoom Unsupported (TODO: remove this). * @property {ol.TileUrlFunctionType|undefined} tileUrlFunction Optional * function to get tile URL given a tile coordinate and the projection. diff --git a/src/ol/source/osmsource.js b/src/ol/source/osmsource.js index cc759a3653..cab05acca9 100644 --- a/src/ol/source/osmsource.js +++ b/src/ol/source/osmsource.js @@ -23,8 +23,6 @@ ol.source.OSM = function(opt_options) { attributions = ol.source.OSM.ATTRIBUTIONS; } - var maxZoom = goog.isDef(options.maxZoom) ? options.maxZoom : 18; - var url = goog.isDef(options.url) ? options.url : 'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'; @@ -32,7 +30,7 @@ ol.source.OSM = function(opt_options) { attributions: attributions, crossOrigin: 'anonymous', opaque: true, - maxZoom: maxZoom, + maxZoom: options.maxZoom, url: url }); diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index c40d20865e..885964eab2 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -33,8 +33,10 @@ ol.source.XYZ = function(options) { ol.TileUrlFunction.expandUrl(options.url)); } + var maxZoom = goog.isDef(options.maxZoom) ? options.maxZoom : 18; + var tileGrid = new ol.tilegrid.XYZ({ - maxZoom: options.maxZoom + maxZoom: maxZoom }); var tileCoordTransform = tileGrid.createTileCoordTransform({ From cf3756660625a5e60643d74b8571fdcbf47f352b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 10 Sep 2013 18:33:08 -0600 Subject: [PATCH 5/6] Remove unused require This was unused before 03f7bb66374b162aab26289b761e7918b79c0ca7 as well. It would be interesting to see how many other unused requires there are (types that are only referenced in comments but not used in code). --- src/ol/source/xyzsource.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index 885964eab2..0f00bc385a 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -1,7 +1,6 @@ goog.provide('ol.source.XYZ'); goog.require('ol.Attribution'); -goog.require('ol.Projection'); goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunctionType'); goog.require('ol.proj'); From 1ee2da76afbc7af493bbf5d1529bce5fa0c1f516 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 11 Sep 2013 00:41:25 -0600 Subject: [PATCH 6/6] Add example using XYZ tiles from Esri --- examples/xyz-esri.html | 56 ++++++++++++++++++++++++++++++++++++++++++ examples/xyz-esri.js | 24 ++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 examples/xyz-esri.html create mode 100644 examples/xyz-esri.js diff --git a/examples/xyz-esri.html b/examples/xyz-esri.html new file mode 100644 index 0000000000..5d59d7b0aa --- /dev/null +++ b/examples/xyz-esri.html @@ -0,0 +1,56 @@ + + + + + + + + + + + XYZ Esri example + + + + + +
+ +
+
+
+
+
+ +
+ +
+

XYZ Esri example

+

Example of a XYZ source using Esri tiles.

+
+

See the xyz-esri.js source for details on how this is done.

+
+
xyz, esri
+
+ +
+ +
+ + + + + + diff --git a/examples/xyz-esri.js b/examples/xyz-esri.js new file mode 100644 index 0000000000..aede312ea2 --- /dev/null +++ b/examples/xyz-esri.js @@ -0,0 +1,24 @@ +goog.require('ol.Map'); +goog.require('ol.RendererHint'); +goog.require('ol.View2D'); +goog.require('ol.layer.Tile'); +goog.require('ol.proj'); +goog.require('ol.source.XYZ'); + + +var map = new ol.Map({ + target: 'map', + layers: [ + new ol.layer.Tile({ + source: new ol.source.XYZ({ + url: 'http://server.arcgisonline.com/ArcGIS/rest/services/' + + 'World_Topo_Map/MapServer/tile/{z}/{y}/{x}' + }) + }) + ], + renderer: ol.RendererHint.CANVAS, + view: new ol.View2D({ + center: ol.proj.transform([-121.1, 47.5], 'EPSG:4326', 'EPSG:3857'), + zoom: 7 + }) +});