From 7fbc4e3bff748e80937be23bf6c207f87b15cb93 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Mon, 21 Jul 2014 12:27:59 +0200 Subject: [PATCH 1/9] Rename ol3Logo to logo in map options --- externs/olx.js | 4 ++-- src/ol/map.js | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index f00d92a889..e20d456049 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -106,7 +106,7 @@ olx.GeolocationOptions.prototype.projection; * interactions: (ol.Collection|Array.|undefined), * keyboardEventTarget: (Element|Document|string|undefined), * layers: (Array.|ol.Collection|undefined), - * ol3Logo: (boolean|undefined), + * logo: (boolean|string|Object|undefined), * overlays: (ol.Collection|Array.|undefined), * renderer: (ol.RendererType|Array.|string|undefined), * target: (Element|string|undefined), @@ -171,7 +171,7 @@ olx.MapOptions.prototype.layers; * Show ol3 logo. Default is `true`. * @type {boolean|undefined} */ -olx.MapOptions.prototype.ol3Logo; +olx.MapOptions.prototype.logo; /** diff --git a/src/ol/map.js b/src/ol/map.js index 5b52b621ce..0bdf3f0f5d 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -172,9 +172,9 @@ ol.Map = function(options) { /** * @private - * @type {boolean} + * @type {Object} */ - this.ol3Logo_ = optionsInternal.ol3Logo; + this.logos_ = optionsInternal.logos; /** * @private @@ -1209,7 +1209,7 @@ ol.Map.prototype.renderFrame_ = function(time) { index: this.frameIndex_++, layerStates: layerStates, layerStatesArray: layerStatesArray, - logos: {}, + logos: this.logos_, pixelRatio: this.pixelRatio_, pixelToCoordinateMatrix: this.pixelToCoordinateMatrix_, postRenderFunctions: [], @@ -1222,9 +1222,6 @@ ol.Map.prototype.renderFrame_ = function(time) { viewHints: viewHints, wantedTiles: {} }); - if (this.ol3Logo_) { - frameState.logos[ol.OL3_LOGO_URL] = ol.OL3_URL; - } } var preRenderFunctions = this.preRenderFunctions_; @@ -1382,7 +1379,7 @@ ol.Map.prototype.unskipFeature = function(feature) { * deviceOptions: olx.DeviceOptions, * interactions: ol.Collection, * keyboardEventTarget: (Element|Document), - * ol3Logo: boolean, + * logos: Object, * overlays: ol.Collection, * rendererConstructor: * function(new: ol.renderer.Map, Element, ol.Map), @@ -1414,7 +1411,11 @@ ol.Map.createOptionsInternal = function(options) { */ var values = {}; - var ol3Logo = goog.isDef(options.ol3Logo) ? options.ol3Logo : true; + var logos = {}; + if (!goog.isDef(options.logo) || + (goog.isBoolean(options.logo) && options.logo)) { + logos[ol.OL3_LOGO_URL] = ol.OL3_URL; + } var layerGroup = (options.layers instanceof ol.layer.Group) ? options.layers : new ol.layer.Group({layers: options.layers}); @@ -1512,7 +1513,7 @@ ol.Map.createOptionsInternal = function(options) { deviceOptions: deviceOptions, interactions: interactions, keyboardEventTarget: keyboardEventTarget, - ol3Logo: ol3Logo, + logos: logos, overlays: overlays, rendererConstructor: rendererConstructor, values: values From a71714e8b6c28054dd6394e3af40f7283a451754 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Mon, 21 Jul 2014 13:49:17 +0200 Subject: [PATCH 2/9] Allow string & object to be passed as map logo --- src/ol/map.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ol/map.js b/src/ol/map.js index 0bdf3f0f5d..9e3841d942 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1415,6 +1415,15 @@ ol.Map.createOptionsInternal = function(options) { if (!goog.isDef(options.logo) || (goog.isBoolean(options.logo) && options.logo)) { logos[ol.OL3_LOGO_URL] = ol.OL3_URL; + } else { + var logo = options.logo; + if (goog.isString(logo)) { + logos[logo] = ''; + } else if (goog.isObject(logo)) { + goog.asserts.assertString(logo.href); + goog.asserts.assertString(logo.src); + logos[logo.src] = logo.href; + } } var layerGroup = (options.layers instanceof ol.layer.Group) ? From a43c5466672d074135aa9b33c0a6ae2e29e8c63c Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Mon, 21 Jul 2014 14:38:26 +0200 Subject: [PATCH 3/9] =?UTF-8?q?Uncollapse=20when=20there=E2=80=99s=20only?= =?UTF-8?q?=20logos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/ol.css | 10 ++++++++++ src/ol/control/attributioncontrol.js | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/css/ol.css b/css/ol.css index e2714500f3..a76ab56407 100644 --- a/css/ol.css +++ b/css/ol.css @@ -219,6 +219,9 @@ button.ol-full-screen-true:after { .ol-attribution.ol-collapsed ul { display: none; } +.ol-attribution.ol-logo-only ul { + display: block; +} .ol-attribution:not(.ol-collapsed) { background: rgba(255,255,255,0.8); } @@ -229,10 +232,17 @@ button.ol-full-screen-true:after { height: 1.1em; line-height: 1em; } +.ol-attribution.ol-logo-only { + background: transparent; + bottom: .4em; + height: 1.1em; + line-height: 1em; +} .ol-attribution.ol-uncollapsible img { margin-top: -.2em; max-height: 1.6em; } +.ol-attribution.ol-logo-only button, .ol-attribution.ol-uncollapsible button { display: none; } diff --git a/src/ol/control/attributioncontrol.js b/src/ol/control/attributioncontrol.js index d12e054404..f1fe7ae883 100644 --- a/src/ol/control/attributioncontrol.js +++ b/src/ol/control/attributioncontrol.js @@ -272,6 +272,12 @@ ol.control.Attribution.prototype.updateElement_ = function(frameState) { goog.style.setElementShown(this.element, renderVisible); this.renderedVisible_ = renderVisible; } + if (renderVisible && + goog.object.isEmpty(this.attributionElementRenderedVisible_)) { + goog.dom.classlist.add(this.element, 'ol-logo-only'); + } else { + goog.dom.classlist.remove(this.element, 'ol-logo-only'); + } this.insertLogos_(frameState); From a314203e1299d281e9ebb39e6554a62fad7dd878 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Mon, 21 Jul 2014 14:39:58 +0200 Subject: [PATCH 4/9] Fixes wording in comments --- src/ol/control/attributioncontrol.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ol/control/attributioncontrol.js b/src/ol/control/attributioncontrol.js index f1fe7ae883..beb2218031 100644 --- a/src/ol/control/attributioncontrol.js +++ b/src/ol/control/attributioncontrol.js @@ -360,7 +360,7 @@ ol.control.Attribution.prototype.handleToggle_ = function() { /** - * @return {boolean} True is the widget is collapsible. + * @return {boolean} True if the widget is collapsible. * @api */ ol.control.Attribution.prototype.getCollapsible = function() { @@ -369,7 +369,7 @@ ol.control.Attribution.prototype.getCollapsible = function() { /** - * @param {boolean} collapsible True is the widget is collapsible. + * @param {boolean} collapsible True if the widget is collapsible. * @api */ ol.control.Attribution.prototype.setCollapsible = function(collapsible) { @@ -385,7 +385,7 @@ ol.control.Attribution.prototype.setCollapsible = function(collapsible) { /** - * @param {boolean} collapsed True is the widget is collapsed. + * @param {boolean} collapsed True if the widget is collapsed. * @api */ ol.control.Attribution.prototype.setCollapsed = function(collapsed) { @@ -397,7 +397,7 @@ ol.control.Attribution.prototype.setCollapsed = function(collapsed) { /** - * @return {boolean} True is the widget is collapsed. + * @return {boolean} True if the widget is collapsed. * @api */ ol.control.Attribution.prototype.getCollapsed = function() { From c1f7db9611aa874a74147943e727d5f005c86b13 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Mon, 21 Jul 2014 15:48:00 +0200 Subject: [PATCH 5/9] Set type=button to avoid forms submit --- src/ol/control/attributioncontrol.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ol/control/attributioncontrol.js b/src/ol/control/attributioncontrol.js index beb2218031..6239585d5d 100644 --- a/src/ol/control/attributioncontrol.js +++ b/src/ol/control/attributioncontrol.js @@ -96,7 +96,8 @@ ol.control.Attribution = function(opt_options) { */ this.labelSpan_ = label; var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { - 'class': 'ol-has-tooltip' + 'class': 'ol-has-tooltip', + 'type': 'button' }, this.labelSpan_); goog.dom.appendChild(button, tip); From ba8077010aa8c8db45a2e6bd0bc40ee16d98437d Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Mon, 21 Jul 2014 17:27:47 +0200 Subject: [PATCH 6/9] Add link support for source logos --- externs/olx.js | 76 ++++++++++++++++---------------- src/ol/renderer/layerrenderer.js | 9 +++- src/ol/source/imagesource.js | 2 +- src/ol/source/source.js | 8 ++-- src/ol/source/tilesource.js | 2 +- 5 files changed, 52 insertions(+), 45 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index e20d456049..de03a496ea 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2559,7 +2559,7 @@ olx.source.BingMapsOptions.prototype.tileLoadFunction; * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), * format: ol.format.Feature, - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike}} * @api */ @@ -2589,7 +2589,7 @@ olx.source.FormatVectorOptions.prototype.format; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.FormatVectorOptions.prototype.logo; @@ -2605,7 +2605,7 @@ olx.source.FormatVectorOptions.prototype.projection; * @typedef {{attributions: (Array.|undefined), * defaultProjection: ol.proj.ProjectionLike, * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * object: (GeoJSONObject|undefined), * projection: ol.proj.ProjectionLike, * text: (string|undefined), @@ -2639,7 +2639,7 @@ olx.source.GeoJSONOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.GeoJSONOptions.prototype.logo; @@ -2684,7 +2684,7 @@ olx.source.GeoJSONOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * doc: (Document|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * node: (Node|undefined), * projection: ol.proj.ProjectionLike, * text: (string|undefined), @@ -2718,7 +2718,7 @@ olx.source.GPXOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.GPXOptions.prototype.logo; @@ -2763,7 +2763,7 @@ olx.source.GPXOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * crossOrigin: (null|string|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * opaque: (boolean|undefined), * projection: ol.proj.ProjectionLike, * tileClass: (function(new: ol.ImageTile, ol.TileCoord, @@ -2801,7 +2801,7 @@ olx.source.TileImageOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.TileImageOptions.prototype.logo; @@ -2865,7 +2865,7 @@ olx.source.TileImageOptions.prototype.tileUrlFunction; * defaultProjection: ol.proj.ProjectionLike, * extent: (ol.Extent|undefined), * format: ol.format.Feature, - * logo: (string|undefined), + * logo: (string|Object|undefined), * object: (GeoJSONObject|undefined), * projection: ol.proj.ProjectionLike, * tileGrid: ol.tilegrid.TileGrid, @@ -2907,7 +2907,7 @@ olx.source.TileVectorOptions.prototype.format; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.TileVectorOptions.prototype.logo; @@ -2960,7 +2960,7 @@ olx.source.TileVectorOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * defaultProjection: ol.proj.ProjectionLike, * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * object: (GeoJSONObject|undefined), * projection: ol.proj.ProjectionLike, * text: (string|undefined), @@ -2993,7 +2993,7 @@ olx.source.TopoJSONOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.TopoJSONOptions.prototype.logo; @@ -3168,7 +3168,7 @@ olx.source.MapGuideOptions.prototype.params; * defaultStyle: (Array.|undefined), * doc: (Document|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * node: (Node|undefined), * projection: ol.proj.ProjectionLike, * text: (string|undefined), @@ -3209,7 +3209,7 @@ olx.source.KMLOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.KMLOptions.prototype.logo; @@ -3354,7 +3354,7 @@ olx.source.OSMOptions.prototype.url; * defaultStyle: (Array.|undefined), * doc: (Document|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * node: (Node|undefined), * projection: ol.proj.ProjectionLike, * reprojectTo: ol.proj.ProjectionLike, @@ -3396,7 +3396,7 @@ olx.source.OSMXMLOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.OSMXMLOptions.prototype.logo; @@ -3447,7 +3447,7 @@ olx.source.OSMXMLOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * canvasFunction: ol.CanvasFunctionType, * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike, * ratio: (number|undefined), * resolutions: (Array.|undefined), @@ -3487,7 +3487,7 @@ olx.source.ImageCanvasOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.ImageCanvasOptions.prototype.logo; @@ -3525,7 +3525,7 @@ olx.source.ImageCanvasOptions.prototype.state; /** * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike, * ratio: (number|undefined), * resolutions: (Array.|undefined), @@ -3552,7 +3552,7 @@ olx.source.ImageVectorOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.ImageVectorOptions.prototype.logo; @@ -3601,7 +3601,7 @@ olx.source.ImageVectorOptions.prototype.style; * extent: (ol.Extent|undefined), * hidpi: (boolean|undefined), * serverType: (ol.source.wms.ServerType|string|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * params: Object., * projection: ol.proj.ProjectionLike, * ratio: (number|undefined), @@ -3651,7 +3651,7 @@ olx.source.ImageWMSOptions.prototype.serverType; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.ImageWMSOptions.prototype.logo; @@ -3754,7 +3754,7 @@ olx.source.StamenOptions.prototype.url; * extent: (ol.Extent|undefined), * imageExtent: (ol.Extent|undefined), * imageSize: (ol.Size|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike, * url: string}} * @api @@ -3799,7 +3799,7 @@ olx.source.ImageStaticOptions.prototype.imageSize; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.ImageStaticOptions.prototype.logo; @@ -3824,7 +3824,7 @@ olx.source.ImageStaticOptions.prototype.url; * format: ol.format.Feature, * loader: function(this: ol.source.ServerVector, ol.Extent, number, ol.proj.Projection), * strategy: (function(ol.Extent, number): Array.|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike}} * @api */ @@ -3869,7 +3869,7 @@ olx.source.ServerVectorOptions.prototype.strategy; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.ServerVectorOptions.prototype.logo; @@ -3918,7 +3918,7 @@ olx.source.TileJSONOptions.prototype.url; * extent: (ol.Extent|undefined), * gutter: (number|undefined), * hidpi: (boolean|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * tileGrid: (ol.tilegrid.TileGrid|undefined), * maxZoom: (number|undefined), * projection: ol.proj.ProjectionLike, @@ -3985,7 +3985,7 @@ olx.source.TileWMSOptions.prototype.hidpi; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.TileWMSOptions.prototype.logo; @@ -4049,7 +4049,7 @@ olx.source.TileWMSOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), * features: (Array.|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike, * state: (ol.source.State|string|undefined)}} * @api @@ -4080,7 +4080,7 @@ olx.source.VectorOptions.prototype.features; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.VectorOptions.prototype.logo; @@ -4105,7 +4105,7 @@ olx.source.VectorOptions.prototype.state; * doc: (Document|undefined), * extent: (ol.Extent|undefined), * format: ol.format.Feature, - * logo: (string|undefined), + * logo: (string|Object|undefined), * node: (Node|undefined), * object: (Object|undefined), * projection: ol.proj.ProjectionLike, @@ -4154,7 +4154,7 @@ olx.source.StaticVectorOptions.prototype.format; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.StaticVectorOptions.prototype.logo; @@ -4205,7 +4205,7 @@ olx.source.StaticVectorOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * crossOrigin: (string|null|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * tileGrid: ol.tilegrid.WMTS, * projection: ol.proj.ProjectionLike, * requestEncoding: (ol.source.WMTSRequestEncoding|undefined), @@ -4248,7 +4248,7 @@ olx.source.WMTSOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.WMTSOptions.prototype.logo; @@ -4358,7 +4358,7 @@ olx.source.WMTSOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * crossOrigin: (null|string|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike, * maxZoom: (number|undefined), * minZoom: (number|undefined), @@ -4396,7 +4396,7 @@ olx.source.XYZOptions.prototype.extent; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.XYZOptions.prototype.logo; @@ -4471,7 +4471,7 @@ olx.source.XYZOptions.prototype.wrapX; /** * @typedef {{attributions: (Array.|undefined), * crossOrigin: (null|string|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * url: !string, * tierSizeCalculation: (string|undefined), * size: ol.Size}} @@ -4496,7 +4496,7 @@ olx.source.ZoomifyOptions.prototype.crossOrigin; /** * Logo. - * @type {string|undefined} + * @type{string|Object|undefined} */ olx.source.ZoomifyOptions.prototype.logo; diff --git a/src/ol/renderer/layerrenderer.js b/src/ol/renderer/layerrenderer.js index d6ac324095..a4d0bb1966 100644 --- a/src/ol/renderer/layerrenderer.js +++ b/src/ol/renderer/layerrenderer.js @@ -1,6 +1,7 @@ goog.provide('ol.renderer.Layer'); goog.require('goog.Disposable'); +goog.require('goog.asserts'); goog.require('ol.ImageState'); goog.require('ol.TileRange'); goog.require('ol.TileState'); @@ -160,7 +161,13 @@ ol.renderer.Layer.prototype.updateAttributions = ol.renderer.Layer.prototype.updateLogos = function(frameState, source) { var logo = source.getLogo(); if (goog.isDef(logo)) { - frameState.logos[logo] = ''; + if (goog.isString(logo)) { + frameState.logos[logo] = ''; + } else if (goog.isObject(logo)) { + goog.asserts.assertString(logo.href); + goog.asserts.assertString(logo.src); + frameState.logos[logo.src] = logo.href; + } } }; diff --git a/src/ol/source/imagesource.js b/src/ol/source/imagesource.js index bf5554fb45..b83ee13814 100644 --- a/src/ol/source/imagesource.js +++ b/src/ol/source/imagesource.js @@ -11,7 +11,7 @@ goog.require('ol.source.Source'); /** * @typedef {{attributions: (Array.|undefined), * extent: (null|ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike, * resolutions: (Array.|undefined), * state: (ol.source.State|string|undefined)}} diff --git a/src/ol/source/source.js b/src/ol/source/source.js index 8f68d39b45..27c6543bbb 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -23,7 +23,7 @@ ol.source.State = { /** * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * projection: ol.proj.ProjectionLike, * state: (ol.source.State|string|undefined)}} */ @@ -69,7 +69,7 @@ ol.source.Source = function(options) { /** * @private - * @type {string|undefined} + * @type {string|Object|undefined} */ this.logo_ = options.logo; @@ -115,7 +115,7 @@ ol.source.Source.prototype.getExtent = function() { /** - * @return {string|undefined} Logo. + * @return {string|Object|undefined} Logo. */ ol.source.Source.prototype.getLogo = function() { return this.logo_; @@ -162,7 +162,7 @@ ol.source.Source.prototype.setExtent = function(extent) { /** - * @param {string|undefined} logo Logo. + * @param {string|Object|undefined} logo Logo. */ ol.source.Source.prototype.setLogo = function(logo) { this.logo_ = logo; diff --git a/src/ol/source/tilesource.js b/src/ol/source/tilesource.js index 94cfad60ca..fe14524e4b 100644 --- a/src/ol/source/tilesource.js +++ b/src/ol/source/tilesource.js @@ -13,7 +13,7 @@ goog.require('ol.tilegrid.TileGrid'); /** * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), - * logo: (string|undefined), + * logo: (string|Object|undefined), * opaque: (boolean|undefined), * tilePixelRatio: (number|undefined), * projection: ol.proj.ProjectionLike, From 31c9f5806e09eea0c2076e62fba6dc3ff0c31478 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Mon, 21 Jul 2014 17:33:15 +0200 Subject: [PATCH 7/9] Wording in docs --- externs/olx.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index de03a496ea..0e88c731c8 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -168,8 +168,8 @@ olx.MapOptions.prototype.layers; /** - * Show ol3 logo. Default is `true`. - * @type {boolean|undefined} + * The map logo. Default is `true`, showing ol3’s logo. + * @type {boolean|string|Object|undefined} */ olx.MapOptions.prototype.logo; From 280a7c520fdc3738b8e8692d55505f5bb3a15e5e Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Thu, 24 Jul 2014 15:20:18 +0200 Subject: [PATCH 8/9] More complete doc for `logo` option --- externs/olx.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/externs/olx.js b/externs/olx.js index 0e88c731c8..e8f339958f 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -168,7 +168,11 @@ olx.MapOptions.prototype.layers; /** - * The map logo. Default is `true`, showing ol3’s logo. + * The map logo. A logo to be displayed on the map at all times. If a string is + * provided, it will be set as the image source of the logo. If an object is + * provided, the `src` property should be the URL for an image and the `href` + * property should be a URL for creating a link. To disable the map logo, set + * the option to `false`. By default, the OpenLayers 3 logo is shown. * @type {boolean|string|Object|undefined} */ olx.MapOptions.prototype.logo; From d50f40dcce6a2ef13d59db15177afd8146313f61 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Thu, 24 Jul 2014 16:40:34 +0200 Subject: [PATCH 9/9] Type check with `olx.LogoOptions` --- externs/olx.js | 88 ++++++++++++++++++++---------------- src/ol/source/imagesource.js | 2 +- src/ol/source/source.js | 8 ++-- src/ol/source/tilesource.js | 2 +- 4 files changed, 54 insertions(+), 46 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index e8f339958f..ad1c275762 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -98,6 +98,14 @@ olx.GeolocationOptions.prototype.trackingOptions; olx.GeolocationOptions.prototype.projection; +/** + * Object literal with config options for the map logo. + * @typedef {{href: (string), src: (string)}} + * @api + */ +olx.LogoOptions; + + /** * Object literal with config options for the map. * @typedef {{controls: (ol.Collection|Array.|undefined), @@ -106,7 +114,7 @@ olx.GeolocationOptions.prototype.projection; * interactions: (ol.Collection|Array.|undefined), * keyboardEventTarget: (Element|Document|string|undefined), * layers: (Array.|ol.Collection|undefined), - * logo: (boolean|string|Object|undefined), + * logo: (boolean|string|olx.LogoOptions|undefined), * overlays: (ol.Collection|Array.|undefined), * renderer: (ol.RendererType|Array.|string|undefined), * target: (Element|string|undefined), @@ -173,7 +181,7 @@ olx.MapOptions.prototype.layers; * provided, the `src` property should be the URL for an image and the `href` * property should be a URL for creating a link. To disable the map logo, set * the option to `false`. By default, the OpenLayers 3 logo is shown. - * @type {boolean|string|Object|undefined} + * @type {boolean|string|olx.LogoOptions|undefined} */ olx.MapOptions.prototype.logo; @@ -2563,7 +2571,7 @@ olx.source.BingMapsOptions.prototype.tileLoadFunction; * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), * format: ol.format.Feature, - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike}} * @api */ @@ -2593,7 +2601,7 @@ olx.source.FormatVectorOptions.prototype.format; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.FormatVectorOptions.prototype.logo; @@ -2609,7 +2617,7 @@ olx.source.FormatVectorOptions.prototype.projection; * @typedef {{attributions: (Array.|undefined), * defaultProjection: ol.proj.ProjectionLike, * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * object: (GeoJSONObject|undefined), * projection: ol.proj.ProjectionLike, * text: (string|undefined), @@ -2643,7 +2651,7 @@ olx.source.GeoJSONOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.GeoJSONOptions.prototype.logo; @@ -2688,7 +2696,7 @@ olx.source.GeoJSONOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * doc: (Document|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * node: (Node|undefined), * projection: ol.proj.ProjectionLike, * text: (string|undefined), @@ -2722,7 +2730,7 @@ olx.source.GPXOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.GPXOptions.prototype.logo; @@ -2767,7 +2775,7 @@ olx.source.GPXOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * crossOrigin: (null|string|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * opaque: (boolean|undefined), * projection: ol.proj.ProjectionLike, * tileClass: (function(new: ol.ImageTile, ol.TileCoord, @@ -2805,7 +2813,7 @@ olx.source.TileImageOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.TileImageOptions.prototype.logo; @@ -2869,7 +2877,7 @@ olx.source.TileImageOptions.prototype.tileUrlFunction; * defaultProjection: ol.proj.ProjectionLike, * extent: (ol.Extent|undefined), * format: ol.format.Feature, - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * object: (GeoJSONObject|undefined), * projection: ol.proj.ProjectionLike, * tileGrid: ol.tilegrid.TileGrid, @@ -2911,7 +2919,7 @@ olx.source.TileVectorOptions.prototype.format; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.TileVectorOptions.prototype.logo; @@ -2964,7 +2972,7 @@ olx.source.TileVectorOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * defaultProjection: ol.proj.ProjectionLike, * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * object: (GeoJSONObject|undefined), * projection: ol.proj.ProjectionLike, * text: (string|undefined), @@ -2997,7 +3005,7 @@ olx.source.TopoJSONOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.TopoJSONOptions.prototype.logo; @@ -3172,7 +3180,7 @@ olx.source.MapGuideOptions.prototype.params; * defaultStyle: (Array.|undefined), * doc: (Document|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * node: (Node|undefined), * projection: ol.proj.ProjectionLike, * text: (string|undefined), @@ -3213,7 +3221,7 @@ olx.source.KMLOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.KMLOptions.prototype.logo; @@ -3358,7 +3366,7 @@ olx.source.OSMOptions.prototype.url; * defaultStyle: (Array.|undefined), * doc: (Document|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * node: (Node|undefined), * projection: ol.proj.ProjectionLike, * reprojectTo: ol.proj.ProjectionLike, @@ -3400,7 +3408,7 @@ olx.source.OSMXMLOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.OSMXMLOptions.prototype.logo; @@ -3451,7 +3459,7 @@ olx.source.OSMXMLOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * canvasFunction: ol.CanvasFunctionType, * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike, * ratio: (number|undefined), * resolutions: (Array.|undefined), @@ -3491,7 +3499,7 @@ olx.source.ImageCanvasOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.ImageCanvasOptions.prototype.logo; @@ -3529,7 +3537,7 @@ olx.source.ImageCanvasOptions.prototype.state; /** * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike, * ratio: (number|undefined), * resolutions: (Array.|undefined), @@ -3556,7 +3564,7 @@ olx.source.ImageVectorOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.ImageVectorOptions.prototype.logo; @@ -3605,7 +3613,7 @@ olx.source.ImageVectorOptions.prototype.style; * extent: (ol.Extent|undefined), * hidpi: (boolean|undefined), * serverType: (ol.source.wms.ServerType|string|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * params: Object., * projection: ol.proj.ProjectionLike, * ratio: (number|undefined), @@ -3655,7 +3663,7 @@ olx.source.ImageWMSOptions.prototype.serverType; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.ImageWMSOptions.prototype.logo; @@ -3758,7 +3766,7 @@ olx.source.StamenOptions.prototype.url; * extent: (ol.Extent|undefined), * imageExtent: (ol.Extent|undefined), * imageSize: (ol.Size|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike, * url: string}} * @api @@ -3803,7 +3811,7 @@ olx.source.ImageStaticOptions.prototype.imageSize; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.ImageStaticOptions.prototype.logo; @@ -3828,7 +3836,7 @@ olx.source.ImageStaticOptions.prototype.url; * format: ol.format.Feature, * loader: function(this: ol.source.ServerVector, ol.Extent, number, ol.proj.Projection), * strategy: (function(ol.Extent, number): Array.|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike}} * @api */ @@ -3873,7 +3881,7 @@ olx.source.ServerVectorOptions.prototype.strategy; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.ServerVectorOptions.prototype.logo; @@ -3922,7 +3930,7 @@ olx.source.TileJSONOptions.prototype.url; * extent: (ol.Extent|undefined), * gutter: (number|undefined), * hidpi: (boolean|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * tileGrid: (ol.tilegrid.TileGrid|undefined), * maxZoom: (number|undefined), * projection: ol.proj.ProjectionLike, @@ -3989,7 +3997,7 @@ olx.source.TileWMSOptions.prototype.hidpi; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.TileWMSOptions.prototype.logo; @@ -4053,7 +4061,7 @@ olx.source.TileWMSOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), * features: (Array.|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike, * state: (ol.source.State|string|undefined)}} * @api @@ -4084,7 +4092,7 @@ olx.source.VectorOptions.prototype.features; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.VectorOptions.prototype.logo; @@ -4109,7 +4117,7 @@ olx.source.VectorOptions.prototype.state; * doc: (Document|undefined), * extent: (ol.Extent|undefined), * format: ol.format.Feature, - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * node: (Node|undefined), * object: (Object|undefined), * projection: ol.proj.ProjectionLike, @@ -4158,7 +4166,7 @@ olx.source.StaticVectorOptions.prototype.format; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.StaticVectorOptions.prototype.logo; @@ -4209,7 +4217,7 @@ olx.source.StaticVectorOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * crossOrigin: (string|null|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * tileGrid: ol.tilegrid.WMTS, * projection: ol.proj.ProjectionLike, * requestEncoding: (ol.source.WMTSRequestEncoding|undefined), @@ -4252,7 +4260,7 @@ olx.source.WMTSOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.WMTSOptions.prototype.logo; @@ -4362,7 +4370,7 @@ olx.source.WMTSOptions.prototype.urls; * @typedef {{attributions: (Array.|undefined), * crossOrigin: (null|string|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike, * maxZoom: (number|undefined), * minZoom: (number|undefined), @@ -4400,7 +4408,7 @@ olx.source.XYZOptions.prototype.extent; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.XYZOptions.prototype.logo; @@ -4475,7 +4483,7 @@ olx.source.XYZOptions.prototype.wrapX; /** * @typedef {{attributions: (Array.|undefined), * crossOrigin: (null|string|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * url: !string, * tierSizeCalculation: (string|undefined), * size: ol.Size}} @@ -4500,7 +4508,7 @@ olx.source.ZoomifyOptions.prototype.crossOrigin; /** * Logo. - * @type{string|Object|undefined} + * @type{string|olx.LogoOptions|undefined} */ olx.source.ZoomifyOptions.prototype.logo; diff --git a/src/ol/source/imagesource.js b/src/ol/source/imagesource.js index b83ee13814..ed438518d9 100644 --- a/src/ol/source/imagesource.js +++ b/src/ol/source/imagesource.js @@ -11,7 +11,7 @@ goog.require('ol.source.Source'); /** * @typedef {{attributions: (Array.|undefined), * extent: (null|ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike, * resolutions: (Array.|undefined), * state: (ol.source.State|string|undefined)}} diff --git a/src/ol/source/source.js b/src/ol/source/source.js index 27c6543bbb..a7633ecd9f 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -23,7 +23,7 @@ ol.source.State = { /** * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * projection: ol.proj.ProjectionLike, * state: (ol.source.State|string|undefined)}} */ @@ -69,7 +69,7 @@ ol.source.Source = function(options) { /** * @private - * @type {string|Object|undefined} + * @type {string|olx.LogoOptions|undefined} */ this.logo_ = options.logo; @@ -115,7 +115,7 @@ ol.source.Source.prototype.getExtent = function() { /** - * @return {string|Object|undefined} Logo. + * @return {string|olx.LogoOptions|undefined} Logo. */ ol.source.Source.prototype.getLogo = function() { return this.logo_; @@ -162,7 +162,7 @@ ol.source.Source.prototype.setExtent = function(extent) { /** - * @param {string|Object|undefined} logo Logo. + * @param {string|olx.LogoOptions|undefined} logo Logo. */ ol.source.Source.prototype.setLogo = function(logo) { this.logo_ = logo; diff --git a/src/ol/source/tilesource.js b/src/ol/source/tilesource.js index fe14524e4b..51b021f3a1 100644 --- a/src/ol/source/tilesource.js +++ b/src/ol/source/tilesource.js @@ -13,7 +13,7 @@ goog.require('ol.tilegrid.TileGrid'); /** * @typedef {{attributions: (Array.|undefined), * extent: (ol.Extent|undefined), - * logo: (string|Object|undefined), + * logo: (string|olx.LogoOptions|undefined), * opaque: (boolean|undefined), * tilePixelRatio: (number|undefined), * projection: ol.proj.ProjectionLike,