Compare commits

..

1 Commits

Author SHA1 Message Date
Tim Schaub
980ea4a977 5.0.0-beta.11 2018-05-08 08:58:08 -06:00
103 changed files with 1695 additions and 407 deletions

View File

@@ -19,6 +19,8 @@ Use one of the following methods to use OpenLayers in your project:
* If you just want to add a `<script>` tag to test things out, you can link directly to one of the full builds from [cdnjs](https://cdnjs.com/libraries/openlayers) (not recommended for production)
* For use with Closure Library (rare), install the [`openlayers` package](https://npmjs.com/package/openlayers) and read the [tutorial](http://openlayers.org/en/latest/doc/tutorials/closure.html).
## Supported Browsers
OpenLayers runs on all modern browsers that support [HTML5](https://html.spec.whatwg.org/multipage/) and [ECMAScript 5](http://www.ecma-international.org/ecma-262/5.1/). This includes Chrome, Firefox, Safari and Edge. For older browsers and platforms like Internet Explorer (down to version 9) and Android 4.x, [polyfills](http://polyfill.io) for `requestAnimationFrame` and `Element.prototype.classList` are required, and using the KML format requires a polyfill for `URL`.

View File

@@ -1,36 +1,37 @@
{
"opts": {
"recurse": true,
"template": "config/jsdoc/api/template"
},
"tags": {
"allowUnknownTags": true
},
"source": {
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_",
"include": [
"src/ol"
]
},
"plugins": [
"plugins/markdown",
"config/jsdoc/api/plugins/normalize-exports",
"config/jsdoc/api/plugins/inline-options",
"config/jsdoc/api/plugins/events",
"config/jsdoc/api/plugins/observable",
"config/jsdoc/api/plugins/api"
],
"markdown": {
"parser": "gfm"
},
"templates": {
"cleverLinks": true,
"monospaceLinks": true,
"default": {
"outputSourceFiles": false
"opts": {
"recurse": true,
"template": "config/jsdoc/api/template"
},
"applicationName": "OpenLayers"
},
"jsVersion": 180
"tags": {
"allowUnknownTags": true
},
"source": {
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_",
"include": [
"src",
"externs/oli.js"
]
},
"plugins": [
"plugins/markdown",
"config/jsdoc/api/plugins/inheritdoc",
"config/jsdoc/api/plugins/typedefs",
"config/jsdoc/api/plugins/events",
"config/jsdoc/api/plugins/observable",
"config/jsdoc/api/plugins/api"
],
"markdown": {
"parser": "gfm"
},
"templates": {
"cleverLinks": true,
"monospaceLinks": true,
"default": {
"outputSourceFiles": false
},
"applicationName": "OpenLayers"
},
"jsVersion": 180
}

View File

@@ -1,43 +1,43 @@
<table><tr>
<th width="33.3%">Map</th><th width="33.3%">View</th><th width="33.3%">Layers</th>
</tr><tr>
<td><p>A [map](module-ol_Map-Map.html) is made of [layers](module-ol_layer_Base-BaseLayer.html), a [view](module-ol_View-View.html) to visualize them, [interactions](module-ol_interaction_Interaction-Interaction.html) to modify map content and [controls](module-ol_control_Control-Control.html) with UI components.</p>
[Overview](module-ol_Map-Map.html)<br>
[Creation](module-ol_Map-Map.html#Map)<br>
[Events](module-ol_MapBrowserEvent-MapBrowserEvent.html)</td>
<td><p>A [map](ol.Map.html) is made of [layers](ol.layer.html), a [view](ol.View.html) to visualize them, [interactions](ol.interaction.html) to modify map content and [controls](ol.control.html) with UI components.</p>
[Overview](ol.Map.html)<br>
[Creation](ol.Map.html#Map)<br>
[Events](ol.MapBrowserEvent.html)</td>
<td><p>The view manages the visual parameters of the map view, like resolution or rotation.</p>
[View](module-ol_View-View.html) with center, projection, resolution and rotation</td>
<td><p>Layers are lightweight containers that get their data from [sources](module-ol_source_Source-Source.html).</p>
[layer/Tile](module-ol_layer_Tile-TileLayer.html)<br>
[layer/Image](module-ol_layer_Image-ImageLayer.html)<br>
[layer/Vector](module-ol_layer_Vector-VectorLayer.html)<br>
[layer/VectorTile](module-ol_layer_VectorTile-VectorTileLayer.html)</td>
[ol.View](ol.View.html) with center, projection, resolution and rotation</td>
<td><p>Layers are lightweight containers that get their data from [sources](ol.source.html).</p>
[ol.layer.Tile](ol.layer.Tile.html)<br>
[ol.layer.Image](ol.layer.Image.html)<br>
[ol.layer.Vector](ol.layer.Vector.html)<br>
[ol.layer.VectorTile](ol.layer.VectorTile.html)</td>
</tr><tr>
<th>Controls</th><th>Interactions</th><th>Sources and formats</th>
</tr><tr>
<td>[Map default controls](module-ol_control_util.html#.defaults)<br>
[All controls](module-ol_control_Control-Control.html)
<td>[Map default controls](ol.control.html#.defaults)<br>
[All controls](ol.control.html)
</td>
<td>
[Map default interactions](module-ol_interaction.html#~defaults)<br>
Interactions for [vector features](module-ol_Feature-Feature.html)
<ul><li>[interaction/Select](module-ol_interaction_Select-Select.html)</li>
<li>[interaction/Draw](module-ol_interaction_Draw-Draw.html)</li>
<li>[interaction/Modify](module-ol_interaction_Modify-Modify.html)</li></ul>
[All interactions](module-ol_interaction_Interaction-Interaction.html)</td>
<td>[Tile sources](module-ol_source_Tile-TileSource.html) for [layer/Tile](module-ol_layer_Tile-TileLayer.html)
<br>[Image sources](module-ol_source_Image-ImageSource.html) for [layer/Image](module-ol_layer_Image-ImageLayer.html)
<br>[Vector sources](module-ol_source_Vector-VectorSource.html) for [layer/Vector](module-ol_layer_Vector-VectorLayer.html)
<br>[Vector tile sources](module-ol_source_VectorTile-VectorTile.html) for [layer/VectorTile](module-ol_layer_VectorTile-VectorTileLayer.html)
<br>[Formats](module-ol_format_Feature-FeatureFormat.html) for reading/writing vector data
<br>[format/WMSCapabilities](module-ol_format_WMSCapabilities-WMSCapabilities.html)</td></tr>
[Map default interactions](ol.interaction.html#.defaults)<br>
Interactions for [vector features](ol.Feature.html)
<ul><li>[ol.interaction.Select](ol.interaction.Select.html)</li>
<li>[ol.interaction.Draw](ol.interaction.Draw.html)</li>
<li>[ol.interaction.Modify](ol.interaction.Modify.html)</li></ul>
[All interactions](ol.interaction.html)</td>
<td>[Tile sources](ol.source.Tile.html) for [ol.layer.Tile](ol.layer.Tile.html)
<br>[Image sources](ol.source.Image.html) for [ol.layer.Image](ol.layer.Image.html)
<br>[Vector sources](ol.source.Vector.html) for [ol.layer.Vector](ol.layer.Vector.html)
<br>[Vector tile sources](ol.source.VectorTile.html) for [ol.layer.VectorTile](ol.layer.VectorTile.html)
<br>[Formats](ol.format.Feature.html) for reading/writing vector data
<br>[ol.format.WMSCapabilities](ol.format.WMSCapabilities.html)</td></tr>
<tr><th>Projections</th><th>Observable objects</th><th>Other components</th></tr>
<tr><td><p>All coordinates and extents need to be provided in view projection (default: EPSG:3857). To transform, use [proj.transform()](module-ol_proj.html#.transform) and [proj.transformExtent()](module-ol_proj.html#.transformExtent).</p>
[ol/proj](module-ol_proj.html)</td>
<td><p>Changes to all [ol/Object](module-ol_Object-BaseObject.html)s can be observed by calling the [object.on('propertychange')](module-ol_Object-BaseObject.html#on) method. Listeners receive an [ol/Object~ObjectEvent](module-ol_Object-ObjectEvent.html) with information on the changed property and old value.</p>
<tr><td><p>All coordinates and extents need to be provided in view projection (default: EPSG:3857). To transform, use [ol.proj.transform()](ol.proj.html#.transform) and [ol.proj.transformExtent()](ol.proj.html#.transformExtent).</p>
[ol.proj](ol.proj.html)</td>
<td><p>Changes to all [ol.Objects](ol.Object.html) can be observed by calling the [object.on('propertychange')](ol.Object.html#on) method. Listeners receive an [ol.Object.Event](ol.Object.Event.html) with information on the changed property and old value.</p>
<td>
[ol/Geolocation](module-ol_Geolocation.html)<br>
[ol/Overlay](module-ol_Overlay-Overlay.html)<br></td>
[ol.Geolocation](ol.Geolocation.html)<br>
[ol.Overlay](ol.Overlay.html)<br></td>
</tr></table>
&nbsp;
@@ -52,4 +52,11 @@ The OpenLayers API consists of
Within a major release series, the API will not be changed. Any changes to the API will be accompanied by a new major release.
*Note*: The API change policy does not cover CSS class names that are used to style the OpenLayers UI. It also does not cover any typedefs and enums.
*Note*: The API change policy does not cover CSS class names that are used to style the
OpenLayers UI.
*Note for Closure Compiler users compiling their application code together with OpenLayers*:
The names of types other than those in the list above (e.g. `ol.Coordinate`) are subject to change. It
is therefore recommended to either use the resolved type as listed in the API docs (e.g.
`Array.<number>` instead of `ol.Coordinate`), or pay attention to the upgrade notes, which will list
the changes for those types.

View File

@@ -24,7 +24,6 @@ exports.defineTags = function(dictionary) {
const api = [];
const classes = {};
const types = {};
const modules = {};
function hasApiMembers(doclet) {
return doclet.longname.split('#')[0] == this.longname;
@@ -58,8 +57,10 @@ function includeAugments(doclet) {
}
});
}
cls._hideConstructor = true;
delete cls.undocumented;
if (cls.longname.indexOf('oli.') !== 0) {
cls._hideConstructor = true;
delete cls.undocumented;
}
}
}
}
@@ -69,21 +70,20 @@ function extractTypes(item) {
item.type.names.forEach(function(type) {
const match = type.match(/^(.*<)?([^>]*)>?$/);
if (match) {
modules[match[2]] = true;
types[match[2]] = true;
}
});
}
function includeTypes(doclet) {
if (doclet.params) {
if (doclet.params && doclet.kind != 'class') {
doclet.params.forEach(extractTypes);
}
if (doclet.returns) {
doclet.returns.forEach(extractTypes);
}
if (doclet.properties) {
doclet.properties.forEach(extractTypes);
if (doclet.isEnum) {
types[doclet.meta.code.name] = true;
}
if (doclet.type && doclet.meta.code.type == 'MemberExpression') {
extractTypes(doclet);
@@ -95,7 +95,6 @@ exports.handlers = {
newDoclet: function(e) {
const doclet = e.doclet;
if (doclet.stability) {
modules[doclet.longname.split('~').shift()] = true;
api.push(doclet);
}
// Mark explicity defined namespaces - needed in parseComplete to keep
@@ -104,7 +103,6 @@ exports.handlers = {
doclet.namespace_ = true;
}
if (doclet.kind == 'class') {
modules[doclet.longname.split('~').shift()] = true;
classes[doclet.longname] = doclet;
}
},
@@ -130,13 +128,6 @@ exports.handlers = {
// Always document namespaces and items with stability annotation
continue;
}
if (doclet.kind == 'module' && doclet.longname in modules) {
// Document all modules that are referenced by the API
continue;
}
if (doclet.isEnum || doclet.kind == 'typedef') {
continue;
}
if (doclet.kind == 'class' && api.some(hasApiMembers, doclet)) {
// Mark undocumented classes with documented members as unexported.
// This is used in ../template/tmpl/container.tmpl to hide the

View File

@@ -0,0 +1,109 @@
/*
* This is a hack to prevent inheritDoc tags from entirely removing
* documentation of the method that inherits the documentation.
*
* TODO: Remove this hack when https://github.com/jsdoc3/jsdoc/issues/53
* is addressed.
*/
exports.defineTags = function(dictionary) {
dictionary.defineTag('inheritDoc', {
mustHaveValue: false,
canHaveType: false,
canHaveName: false,
onTagged: function(doclet, tag) {
doclet.inheritdoc = true;
}
});
};
const lookup = {};
const incompleteByClass = {};
const keepKeys = ['comment', 'meta', 'name', 'memberof', 'longname', 'augment',
'stability'];
exports.handlers = {
newDoclet: function(e) {
const doclet = e.doclet;
let incompletes;
if (!(doclet.longname in lookup)) {
lookup[doclet.longname] = [];
}
lookup[doclet.longname].push(doclet);
if (doclet.inheritdoc) {
if (!(doclet.memberof in incompleteByClass)) {
incompleteByClass[doclet.memberof] = [];
}
incompletes = incompleteByClass[doclet.memberof];
if (incompletes.indexOf(doclet.name) == -1) {
incompletes.push(doclet.name);
}
}
},
parseComplete: function(e) {
let ancestors, candidate, candidates, doclet, i, j, k, l, key;
let incompleteDoclet, stability, incomplete, incompletes;
const doclets = e.doclets;
for (i = doclets.length - 1; i >= 0; --i) {
doclet = doclets[i];
if (doclet.augments) {
ancestors = [].concat(doclet.augments);
}
incompletes = incompleteByClass[doclet.longname];
if (ancestors && incompletes) {
// collect ancestors from the whole hierarchy
for (j = 0; j < ancestors.length; ++j) {
candidates = lookup[ancestors[j]];
if (candidates) {
for (k = candidates.length - 1; k >= 0; --k) {
candidate = candidates[k];
if (candidate.augments) {
ancestors = ancestors.concat(candidate.augments);
}
}
}
}
// walk through all inheritDoc members
for (j = incompletes.length - 1; j >= 0; --j) {
incomplete = incompletes[j];
candidates = lookup[doclet.longname + '#' + incomplete];
if (candidates) {
// get the incomplete doclet that needs to be augmented
for (k = candidates.length - 1; k >= 0; --k) {
incompleteDoclet = candidates[k];
if (incompleteDoclet.inheritdoc) {
break;
}
}
}
// find the documented ancestor
for (k = ancestors.length - 1; k >= 0; --k) {
candidates = lookup[ancestors[k] + '#' + incomplete];
if (candidates) {
for (l = candidates.length - 1; l >= 0; --l) {
candidate = candidates[l];
if (candidate && !candidate.inheritdoc) {
stability = candidate.stability || incompleteDoclet.stability;
if (stability) {
incompleteDoclet.stability = stability;
for (key in candidate) {
if (candidate.hasOwnProperty(key) &&
keepKeys.indexOf(key) == -1) {
incompleteDoclet[key] = candidate[key];
}
}
}
}
}
}
}
}
}
}
}
};

View File

@@ -1,49 +0,0 @@
/**
* @filedesc
* Inlines option params from typedefs
*/
const properties = {};
exports.handlers = {
/**
* Collects all typedefs, keyed by longname
* @param {Object} e Event object.
*/
newDoclet: function(e) {
if (e.doclet.kind == 'typedef' && e.doclet.properties) {
properties[e.doclet.longname] = e.doclet.properties;
}
},
/**
* Adds `options.*` params for options that match the longname of one of the
* collected typedefs.
* @param {Object} e Event object.
*/
parseComplete: function(e) {
const doclets = e.doclets;
for (let i = 0, ii = doclets.length; i < ii; ++i) {
const doclet = doclets[i];
if (doclet.params) {
const params = doclet.params;
for (let j = 0, jj = params.length; j < jj; ++j) {
const param = params[j];
if (param.type && param.type.names) {
const type = param.type.names[0];
if (type in properties) {
param.type.names[0] = type;
params.push.apply(params, properties[type].map(p => {
const property = Object.assign({}, p);
property.name = `${param.name}.${property.name}`;
return property;
}));
}
}
}
}
}
}
};

View File

@@ -1,106 +0,0 @@
/**
* @filedesc
* Expands module path type to point to default export when no name is given
*/
const fs = require('fs');
const path = require('path');
let moduleRoot;
function addDefaultExportPath(obj) {
if (!Array.isArray(obj)) {
obj = obj.names;
}
obj.forEach((name, index) => {
const matches = name.match(/module\:([^>|),\.<]|)+/g);
if (matches) {
matches.forEach(module => {
if (!/[~\.]/.test(module)) {
const checkFile = path.resolve(moduleRoot, module.replace(/^module\:/, ''));
const file = fs.readFileSync(require.resolve(checkFile), 'utf-8');
const lines = file.split('\n');
let hasDefaultExport = false;
for (let i = 0, ii = lines.length; i < ii; ++i) {
hasDefaultExport = hasDefaultExport || /^export default [^\{]/.test(lines[i]);
const match = lines[i].match(/^export default ([A-Za-z_$][A-Za-z0-9_$]+);$/);
if (match) {
// Use variable name if default export is assigned to a variable.
obj[index] = name = name.replace(module, `${module}~${match[1]}`);
return;
}
}
if (hasDefaultExport) {
// Duplicate last part if default export is not assigned to a variable.
obj[index] = name = name.replace(module, `${module}~${module.split('/').pop()}`);
}
}
});
}
});
}
function replaceLinks(comment) {
const matches = comment.match(/\{@link [^\} #]+}/g);
if (matches) {
const modules = matches.map(m => {
const mm = m.match(/(module:[^\}]+)}$/);
if (mm) {
return mm[1];
}
}).filter(m => !!m);
const newModules = modules.concat();
addDefaultExportPath(newModules);
modules.forEach((module, i) => {
comment = comment.replace(module, newModules[i]);
});
}
return comment;
}
exports.handlers = {
/**
* Adds default export to module path types without name
* @param {Object} e Event object.
*/
newDoclet: function(e) {
const doclet = e.doclet;
if (doclet.kind == 'module') {
const levelsUp = doclet.longname.replace(/^module\:/, '').split('/');
if (doclet.meta.filename != 'index.js') {
levelsUp.pop();
}
const pathArgs = [doclet.meta.path].concat(levelsUp.map(() => '../'));
moduleRoot = path.resolve.apply(null, pathArgs);
} else {
if (doclet.description) {
doclet.description = replaceLinks(doclet.description);
}
if (doclet.classdesc) {
doclet.classdesc = replaceLinks(doclet.classdesc);
}
const module = doclet.longname.split('#').shift();
if (module.indexOf('module:') == 0 && module.indexOf('.') !== -1) {
doclet.longname = doclet.longname.replace(module, module.replace('.', '~'));
}
if (doclet.augments) {
addDefaultExportPath(doclet.augments);
}
if (doclet.params) {
doclet.params.forEach(p => addDefaultExportPath(p.type));
}
if (doclet.returns) {
doclet.returns.forEach(r => addDefaultExportPath(r.type));
}
if (doclet.properties) {
doclet.properties.forEach(p => addDefaultExportPath(p.type));
}
if (doclet.type) {
addDefaultExportPath(doclet.type);
}
}
}
};

View File

@@ -47,7 +47,7 @@ exports.handlers = {
if (!cls.fires) {
cls.fires = [];
}
event = 'module:ol/Object~ObjectEvent#event:change:' + name;
event = 'ol.Object.Event#event:change:' + name;
if (cls.fires.indexOf(event) == -1) {
cls.fires.push(event);
}

View File

@@ -47,6 +47,21 @@ ol.MapBrowserEventType = {
```
Note the value of the `@event` annotation. The text before the hash refers to the event class that the event belongs to, and the text after the hash is the type of the event.
To export event properties, they need to be defined in `externs/oli.js` (also see `readme.md` in `externs/`) and marked with an @api annotation:
```js
/** @interface */
oli.MapBrowserEvent;
/**
* @type {ol.Coordinate}
* @api
*/
oli.MapBrowserEvent.prototype.coordinate;
// ...
};
```
To document which events are fired by a class or method, the `@fires` annotation is used:
```js
/**

View File

@@ -1,13 +1,4 @@
/*global env: true */
const hasOwnProp = Object.prototype.hasOwnProperty;
// Work around an issue with hasOwnProperty in JSDoc's templateHelper.js.
//TODO Fix in JSDoc.
Object.prototype.hasOwnProperty = function(property) {
return property in this;
};
const template = require('jsdoc/lib/jsdoc/template');
const fs = require('jsdoc/lib/jsdoc/fs');
const path = require('jsdoc/lib/jsdoc/path');
@@ -18,12 +9,9 @@ const _ = require('underscore');
const htmlsafe = helper.htmlsafe;
const linkto = helper.linkto;
const resolveAuthorLinks = helper.resolveAuthorLinks;
const hasOwnProp = Object.prototype.hasOwnProperty;
const outdir = env.opts.destination;
// Work around an issue with hasOwnProperty in JSDoc's templateHelper.js.
//TODO Fix in JSDoc.
Object.prototype.hasOwnProperty = hasOwnProp;
let view;
let data;
@@ -204,7 +192,7 @@ function attachModuleSymbols(doclets, modules) {
function buildNav(members) {
const nav = [];
// merge namespaces and classes, then sort
const merged = members.modules.concat(members.classes);
const merged = members.namespaces.concat(members.classes);
merged.sort(function(a, b) {
if (a.longname > b.longname) {
return 1;
@@ -217,9 +205,9 @@ function buildNav(members) {
_.each(merged, function(v) {
// exclude interfaces from sidebar
if (v.interface !== true) {
if (v.kind == 'module') {
if (v.kind == 'namespace') {
nav.push({
type: 'module',
type: 'namespace',
longname: v.longname,
name: v.name,
members: find({

View File

@@ -85,7 +85,7 @@ $(function () {
var srcLinks = $('div.tag-source');
srcLinks.each(function(i, el) {
var textParts = el.innerHTML.trim().split(', ');
var link = 'https://github.com/openlayers/openlayers/blob/v' + currentVersion + '/src/ol/' +
var link = 'https://github.com/openlayers/openlayers/blob/v' + currentVersion + '/' +
textParts[0];
el.innerHTML = '<a href="' + link + '">' + textParts[0] + '</a>, ' +
'<a href="' + link + textParts[1].replace('line ', '#L') + '">' +

View File

@@ -20,10 +20,12 @@
<br>
<?js if (doc.stability || doc.kind == 'namespace') {
var ancestors = doc.ancestors.map(a => a.replace(/>\./g, '>').replace(/\.</g, '<')).join('/');
var name = doc.name.toLowerCase();
var parts = [];
if (ancestors) {
parts.push(ancestors.split('~').shift());
parts.push(ancestors);
}
parts.push(name);
var importPath = parts.join('/');
?>
<pre class="prettyprint source"><code>import <?js= doc.name ?> from '<?js= importPath ?>';</code></pre>

View File

@@ -11,7 +11,7 @@ var self = this;
?>
<li class="item" data-name="<?js= item.longname ?>">
<span class="title">
<?js= self.linkto(item.longname, item.longname.replace('module:', '')) ?>
<?js= self.linkto(item.longname, item.longname) ?>
<?js if (item.type === 'namespace' &&
(item.members.length + item.typedefs.length + item.methods.length +
item.events.length > 0)) { ?>

View File

@@ -8,7 +8,7 @@
<th>Name</th>
<th>Type</th>
<th>Settable</th>
<th><a href="module-ol_Object-ObjectEvent.html">ol/Object~ObjectEvent</a> type</th>
<th><a href="ol.Object.Event.html">ol.Object.Event</a> type</th>
<th class="last">Description</th>
</tr>
</thead>

View File

@@ -21,6 +21,9 @@ Table of contents:
* [Why aren't there any features in my source?](#why-aren-t-there-any-features-in-my-source-)
* [How do I force a re-render of the map?](#how-do-i-force-a-re-render-of-the-map-)
* [Why are my features not found?](#why-are-my-features-not-found-)
* [How do I create a custom build of OpenLayers?](#how-do-i-create-a-custom-build-of-openlayers-)
* [Do I need to write my own code using Closure library?](#do-i-need-to-write-my-own-code-using-closure-library-)
* [Do I need to compress my code with Closure compiler?](#do-i-need-to-compress-my-code-with-closure-compiler-)
## What projection is OpenLayers using?
@@ -332,3 +335,37 @@ var vectorLayer = new ol.layer.Vector({
```
The recommended value is the size of the largest symbol, line width or label.
## How do I create a custom build of OpenLayers?
Please refer to the [official create custom builds tutorial](tutorials/custom-builds.html)
which explains how to create a custom build of OpenLayers with just those parts
included that you want.
## Do I need to write my own code using Closure library?
OpenLayers is built on top of the [Google Closure JavaScript
library](https://developers.google.com/closure/library/), but this
does not mean that you must use that library in your application code.
OpenLayers should play well with all sorts of JavaScript libraries out there,
and you are in no way forced to use a specific one. Choose one that looks
right for you.
## Do I need to compress my code with Closure compiler?
No, you don't need to do compress your code with the [Google Closure
compiler](https://developers.google.com/closure/compiler/).
It may be a good choice though, because when your application code and the
OpenLayers source code is compiled together using closure compiler, the
resulting build will most probably be the smallest in terms of byte-size. For
more details refer to the
[compile application and OpenLayers together tutorial](tutorials/closure.html).
If you don't want to use the closure compiler, or you can't, you are not at all
forced to use it.

301
doc/tutorials/closure.md Normal file
View File

@@ -0,0 +1,301 @@
---
title: Compiling Application with Closure Compiler
layout: doc.hbs
---
# Compiling Application with Closure Compiler
**Note**: When building an application with dependencies that are available as [npm](https://npmjs.com/) packages, it will probably be easier to use the [ol](https://npmjs.com/package/ol) package and follow the instructions there.
The OpenLayers code uses the Closure Library, and it is compiled with the
Closure Compiler. Using OpenLayers in an application does not require using
Closure. But using Closure in an OpenLayers application is possible. And this
is what this tutorial is about.
When you want to include OpenLayers as separate script without bundling with your application, follow the [Creating custom builds](./custom-builds.html) tutorial instead.
This tutorial will teach you how to set up an OpenLayers application based on
the [`closure-util`](https://github.com/openlayers/closure-util) node package,
which provides utilities for working with Closure. Using `closure-util` is one
way to use Closure in a web application, but there are others. This tutorial
just covers the "`closure-util`" way.
The `closure-util` documentation is available on the [`closure-util` readme
page](https://github.com/openlayers/closure-util/blob/master/readme.md). You
don't need to read the `closure-util` documentation to follow this tutorial,
but it's available in `closure-util`'s [readme
file](https://github.com/openlayers/closure-util/blob/master/readme.md) if you
need it.
Also, the sample application built in this tutorial is
[available](https://github.com/openlayers/openlayers-closure-application) on
GitHub.
## Advantages of using Closure
This tutorial will show you how to use the Closure Compiler to compile an
application and OpenLayers together. Compiling the application code together
with the OpenLayers code has a number of advantages.
First of all, it allows you to only "pay" for the OpenLayers code your
application uses, as the compiler will exclude the OpenLayers code that the
application doesn't use. And there is no need to write and maintain a list of
"exports", which is necessary when creating custom builds of OpenLayers.
Also, compiling the application and OpenLayers together allows using
OpenLayers functions and objects that are not part of the official OpenLayers
3 API. Using non-API functions and objects may be risky, but it is mitigated by
the fact that the compiler will complain if you use functions or objects
that are not in OpenLayers anymore.
## Setting up the Application
First, create a directory for the application. We will name that directory
`openlayers-closure-application` in this tutorial.
$ mkdir openlayers-closure-application
Now change to that directory:
$ cd openlayers-closure-application
Our application will be a `node` application, and the `openlayers` and
`closure-util` node packages will be downloaded from the node package registry
using the `npm` command line tool.
So we're going to create a `package.json` file for the application, which every
node application includes. This file basically includes metadata for the
application.
Create the application's `package.json` file:
$ npm init
You can pretty much use the default answers to the questions `npm init` asks
you.
Now install OpenLayers using:
$ npm install openlayers --save
The `--save` flag persists the `openlayers` dependency in the application's
`package.json` file. You can edit `package.json` to verify that the dependency
was added.
`closure-util` is a dependency of the `openlayers` package, so it should have
been installed with `openlayers`. Use the following to verify that
`closure-util` is installed:
$ ./node_modules/openlayers/node_modules/.bin/closure-util
command argument is required
Usage: node closure-util <command> [options]
command
update-compiler Update the Compiler
update-library Update the Library
update Update both the Library and the Compiler
build Build with Closure Compiler
serve Start the development server
Options:
-l LEVEL, --loglevel LEVEL Log level [info]
## Create an OpenLayers map
You're now going to create a JavaScript file that creates an OpenLayers map.
This is the file that we will define the application's entry point.
First of all create an `src` directory at the root of the application:
$ mkdir src
Now add a file `main.js` to `src`, with the following content:
```js
goog.provide('app');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
/**
* @type {ol.PluggableMap}
*/
app.map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: [0, 0],
zoom: 4
})
});
```
`goog.provide('app')` creates the namespace `app` for the application. The
`goog.require` statements that follow define the OpenLayers constructors and
namespaces that the application uses. The rest of the code just creates the
OpenLayers map as you would do in any OpenLayers application.
## Compiling the Application
We're now going to compile the application and OpenLayers together, using the
Closure Compiler and `closure-util`. For this we need to create a JSON config
file, that we will then pass as an input file to the `closure-util` command.
The minimum config file looks like this:
```json
{
"lib": [
"node_modules/openlayers/src/**/*.js",
"node_modules/openlayers/build/ol.ext/**/*.js",
"src/**/*.js"
],
"compile": {
"closure_entry_point": "app",
"externs": [
"node_modules/openlayers/externs/bingmaps.js",
"node_modules/openlayers/externs/cartodb.js",
"node_modules/openlayers/externs/closure-compiler.js",
"node_modules/openlayers/externs/esrijson.js",
"node_modules/openlayers/externs/geojson.js",
"node_modules/openlayers/externs/proj4js.js",
"node_modules/openlayers/externs/tilejson.js",
"node_modules/openlayers/externs/topojson.js"
],
"define": [
"ol.ENABLE_WEBGL=false"
],
"js": [
"node_modules/openlayers/externs/oli.js"
],
"extra_annotation_name": [
"api", "observable"
],
"rewrite_polyfills": "false",
"compilation_level": "ADVANCED",
"warning_level": "VERBOSE",
"output_wrapper": "(function(){%output%})();",
"use_types_for_optimization": true
}
}
```
Create a `config.json` file with the above content at the root of the
application directory.
We can now use `closure-util` to compile the code:
$ ./node_modules/openlayers/node_modules/.bin/closure-util build config.json app.js
The resulting `app.js` file, which you can view in your editor if you're
curious, includes a minified version of the application code (`main.js`), and
the OpenLayers code that the application code uses.
Here is a version of `config.json` with more compilation checks enabled:
```json
{
"lib": [
"node_modules/openlayers/src/**/*.js",
"node_modules/openlayers/build/ol.ext/**/*.js",
"src/**/*.js"
],
"compile": {
"closure_entry_point": "app",
"externs": [
"node_modules/openlayers/externs/bingmaps.js",
"node_modules/openlayers/externs/cartodb.js",
"node_modules/openlayers/externs/closure-compiler.js",
"node_modules/openlayers/externs/esrijson.js",
"node_modules/openlayers/externs/geojson.js",
"node_modules/openlayers/externs/proj4js.js",
"node_modules/openlayers/externs/tilejson.js",
"node_modules/openlayers/externs/topojson.js"
],
"define": [
"ol.ENABLE_WEBGL=false"
],
"js": [
"node_modules/openlayers/externs/oli.js"
],
"jscomp_error": [
"*"
],
"jscomp_off": [
"unknownDefines",
"lintChecks",
"analyzerChecks"
],
"extra_annotation_name": [
"api", "observable"
],
"compilation_level": "ADVANCED",
"warning_level": "VERBOSE",
"output_wrapper": "(function(){%output%})();",
"use_types_for_optimization": true
}
}
```
## Create an HTML file for the Application
You can now go ahead and create a simple HTML for the application. Create
a `index.html` file with the following content at the root the application
directory:
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="node_modules/openlayers/css/ol.css" type="text/css">
<title>Simple example</title>
<style>
#map {
width: 600px;
height: 400px;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="app.js" type="text/javascript"></script>
</body>
</html>
```
Note that the page includes a `script` tag referencing the `app.js` file,
which is the file resulting from the compilation.
You are done!
## Run Application in Debug Mode
As a bonus, we're going to show how to use `closure-util` to run the
application in "debug" mode, where the original application and OpenLayers
scripts are loaded one by one in the page.
Start the `closure-util` development server:
$ ./node_modules/openlayers/node_modules/.bin/closure-util serve config.json
Now change the `script` tag to the following in the `index.html` file:
```html
<script src="@?main=src/main.js" type="text/javascript"></script>
```
Reload the page in your browser and you should see that scripts are now loaded
individually, making debugging much easier.

View File

@@ -0,0 +1,233 @@
---
title: Custom builds
layout: doc.hbs
---
# Creating custom builds
OpenLayers is a big library providing a lot of functionality. So it is unlikely that an application will need and use all the functionality OpenLayers provides. This is why creating application-specific OpenLayers builds, with just the functionality your application needs, is often a good idea.
An alternative to creating custom builds is to compile your application code together with OpenLayers. See the [Compiling Application with Closure Compiler](closure.html) tutorial for more information.
This particular tutorial explains how to create custom builds of OpenLayers.
## Requirements
OpenLayers's build tools use Node and Java, so you need to have Node and Java installed on your machine. You can run `node --version` and `java -version` to test that Node and Java are installed, respectively. See [developing guide](https://github.com/openlayers/openlayers/blob/master/DEVELOPING.md) for minimum version numbers required.
## Download OpenLayers
Obviously, creating a custom build requires the OpenLayers source and specific build scripts.
To get the OpenLayers source and the build scripts you can clone the openlayers [repository](https://github.com/openlayers/openlayers), or you can download one of the release archives. You can also download the `openlayers` Node package from the Node package registry, using NPM (the Node Package Manager). This is the method we are going to use in this tutorial.
Create a directory:
$ mkdir openlayers
Download the OpenLayers distribution using NPM:
$ npm install openlayers
This will download the latest stable version of OpenLayers, and install it under `node_modules`. You can list the content of `node_modules` to verify that it effectively contains a directory named "openlayers".
The Node packages onto which the `openlayers` package depends are installed under `node_modules/openlayers/node_modules`. That directory should, for example, include `closure-util`, which is the utility library OpenLayers uses for Closure.
You should now have everything you need to create custom builds of OpenLayers!
## Create a build configuration file
Creating a custom build requires writing a build configuration file. The format of build configuration files is JSON. Here is a simple example of a build configuration file:
```json
{
"exports": [
"ol.Map",
"ol.View",
"ol.control.defaults",
"ol.layer.Tile",
"ol.source.OSM"
],
"compile": {
"externs": [
"externs/bingmaps.js",
"externs/cartodb.js",
"externs/closure-compiler.js",
"externs/esrijson.js",
"externs/geojson.js",
"externs/oli.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js"
],
"extra_annotation_name": [
"api", "observable"
],
"compilation_level": "ADVANCED",
"manage_closure_dependencies": true,
"rewrite_polyfills": false
}
}
```
Create a file named `ol-custom.json` with that content, and save it under the `node_modules/openlayers/build` directory. (You can save it to any location really.)
The most relevant part of this configuration object is the `"exports"` array. This array declares the functions/constructors you use in your JavaScript code. For example, the above configuration file is what you'd use for the following JavaScript code:
```js
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
controls: ol.control.defaults({
attributionOptions: {
collapsible: false
}
}),
view: new ol.View({
center: [0, 0],
zoom: 4
})
});
```
Note that this JavaScript code corresponds to OpenLayers's [`simple`](https://openlayers.org/en/master/examples/simple.html) example.
You are now ready to create your first OpenLayers build. Use the following command to create the build:
$ cd node_modules/openlayers
$ node tasks/build.js build/ol-custom.json build/ol-custom.js
The build command may take some time, but it should end with an output in the console such as the following:
info ol Parsing dependencies
info ol Compiling 364 sources
The build command should have created an `ol-custom.js` file in the `node_modules/openlayers/build` directory. You can verify that the file was created. You can even open it in your editor if you're curious.
As a test, you can use the following HTML file to verify that your custom build works as expected:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>OpenLayers example</title>
<link rel="stylesheet" href="node_modules/openlayers/css/ol.css" />
<style>
#map {
width: 600px;
height: 400px;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="node_modules/openlayers/build/ol-custom.js"></script>
<script>
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: [0, 0],
zoom: 4
})
});
</script>
</body>
</html>
```
## More on the config file
### `define`'s
Closure allows you to define constants that can be set at compile time. The OpenLayers code defines several such values.
Setting some of these to `false` means that the portions of the code relating to this setting become "dead", i.e. are never executed. As Closure Compiler's `ADVANCED` mode removes dead code, this makes the size of the advanced compiled file smaller.
You might have noticed that the build file you've just created is considerably smaller than the full build, but it can be reduced further. This is because both renderers and other optional code are included by default. We only need one renderer, and we do not use the optional code, so can exclude what we don't use by setting properties with `define`s. So add a define section to the config above:
```
"define": [
"ol.ENABLE_WEBGL=false",
"ol.ENABLE_PROJ4JS=false",
"ol.ENABLE_RASTER_REPROJECTION=false"
],
```
and re-run the build script. The build size should now be smaller.
### Externs
The Closure documentation explains that "externs" are for external names used in the code being compiled. The compiler includes externs for built-ins such as `document`. The `externs` directory of the OpenLayers code includes files for all those used in some part of the library. For example, if you use Bing Maps, you should include the Bing externs file in the `externs` section of the config file.
### Other compiler options
There are a couple of other compiler options in the config file above. `manage_closure_dependencies` and `rewrite_polyfills` should always be used.
You can specify any of the other compiler options here as needed, such as the renaming reports, output manifest, or source maps. There is a full list of available options in [closure-util](https://github.com/openlayers/closure-util/blob/master/compiler-options.txt).
Note that `build.js` currently requires you to enter an output file and will write the output from the compiler to it; it does not use the `js_output_file` compiler option. If you specify this in the config file, there will be no compiler output, so `build.js`'s output file will be empty.
## A more complicated example
Now let's try a more complicated example: [`heatmaps-earthquakes`](https://openlayers.org/en/master/examples/heatmap-earthquakes.html). The build configuration file looks like this:
```json
{
"exports": [
"ol.layer.Heatmap",
"ol.source.Vector",
"ol.format.KML",
"ol.layer.Heatmap#getSource",
"ol.source.Vector#on",
"ol.source.Vector.Event#feature",
"ol.Feature#get",
"ol.Feature#set",
"ol.layer.Tile",
"ol.source.Stamen",
"ol.Map",
"ol.View",
"ol.layer.Heatmap#setRadius",
"ol.layer.Heatmap#setBlur"
],
"compile": {
"externs": [
"externs/bingmaps.js",
"externs/cartodb.js",
"externs/closure-compiler.js",
"externs/esrijson.js",
"externs/geojson.js",
"externs/oli.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js"
],
"define": [
"ol.ENABLE_WEBGL=false",
"ol.ENABLE_PROJ4JS=false",
"ol.ENABLE_RASTER_REPROJECTION=false"
],
"compilation_level": "ADVANCED",
"manage_closure_dependencies": true,
"rewrite_polyfills": false
}
}
```
The exports are given here in the order in which they occur in the `heatmaps-earthquakes` example's JavaScript code. In this example we not only use the `ol.` functions and constructors, but also `prototype` methods where the `ol` namespace is not directly used. In the code, we have for example `vector.getSource().on()`. This means we are using the `getSource` method of `layer.Heatmap` and the `on` method of `source.KML`, so this is what has to be exported. Similarly, `event.feature.get()` means we are using the `feature` property of `source.Vector.Event` and the `get` method of `Feature`. If any of these names are left out, the compile will complete successfully, but the missing names will be obfuscated and you will get a 'property undefined' error when you try and run the script.
## Maintaining the code
If you installed OpenLayers from the Node package, you can use `npm` to upgrade to the latest version. If you cloned the Github repo, simply pulling in the latest code may not be enough, as some of the packages used, for example, the compiler, may need upgrading too. Do this by using `npm install` rather than `npm update`.
## Conclusion
This tutorial should have given you the information you need to create custom builds, i.e. builds tailored to your application. See the [tasks readme](https://github.com/openlayers/openlayers/tree/master/tasks/readme.md) for more information on the build scripts and the properties you can use in the build configuration file.

View File

@@ -9,4 +9,5 @@ layout: doc.hbs
* [Basic Concepts](concepts.html)
* [Create Custom Builds](custom-builds.html)
* [Bundle Application and OpenLayers using Browserify](browserify.html)
* [Compile Application and OpenLayers together](closure.html)
* [Raster Reprojection](raster-reprojection.html)

View File

@@ -12,6 +12,9 @@ The initial release aims to support much of the functionality provided by versio
It is also designed such that major new features, such as displaying 3D maps, or using WebGL to quickly display large vector data sets, can be added in later releases.
## Google Closure
OpenLayers was written in a way so it can be compiled with [__Closure Compiler__](https://developers.google.com/closure/compiler/). Its 'advanced' compilation mode offers a level of compression that exceeds anything else available.
## Public API
Using the advanced optimizations of the Closure Compiler means that properties and methods are renamed &ndash; `longMeaningfulName` might become `xB` &ndash; and so are effectively unusable in applications using the library. To be usable, they have to be explicitly `exported`. This means the exported names, those not renamed, effectively become the public API of the library. These __exportable__ properties and methods are marked in the source, and documented in the [API docs](../../apidoc). This is the officially supported API of the library. A build containing all these exportable names is known as a __full build__. A hosted version of this is available, which can be used by any application.

View File

@@ -42,7 +42,8 @@ map.addOverlay(marker);
// LineString to store the different geolocation positions. This LineString
// is time aware.
// The Z dimension is actually used to store the rotation (heading).
const positions = new LineString([], /** @type {module:ol/geom/GeometryLayout} */ ('XYZM'));
const positions = new LineString([],
/** @type {module:ol/geom/GeometryLayout~GeometryLayout} */ ('XYZM'));
// Geolocation Control
const geolocation = new Geolocation({

View File

@@ -58,7 +58,7 @@
<div class="row-fluid">
<div id="source-controls">
<a id="copy-button" data-clipboard-target="#example-source"><i class="fa fa-clipboard"></i> Copy</a>
<!-- <a id="codepen-button"><i class="fa fa-codepen"></i> Edit</a> -->
<a id="codepen-button"><i class="fa fa-codepen"></i> Edit</a>
</div>
<form method="POST" id="codepen-form" target="_blank" action="https://codepen.io/pen/define/">
<textarea class="hidden" name="title">{{ title }}</textarea>
@@ -66,6 +66,7 @@
<textarea class="hidden" name="js">{{ js.source }}</textarea>
<textarea class="hidden" name="css">{{ css.source }}</textarea>
<textarea class="hidden" name="html">{{ contents }}</textarea>
<input type="hidden" name="resources" value="https://openlayers.org/en/v{{ olVersion }}/css/ol.css,https://openlayers.org/en/v{{ olVersion }}/build/ol.js{{ extraResources }}">
<input type="hidden" name="data">
</form>
<pre><code id="example-source" class="language-markup">&lt;!DOCTYPE html&gt;
@@ -75,7 +76,7 @@
&lt;link rel="stylesheet" href="https://openlayers.org/en/v{{ olVersion }}/css/ol.css" type="text/css"&gt;
&lt;!-- The line below is only needed for old environments like Internet Explorer and Android 4.x --&gt;
&lt;script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"&gt;&lt;/script&gt;
{{#if extraHead.remote}}
&lt;script src="https://openlayers.org/en/v{{ olVersion }}/build/ol.js"&gt;&lt;/script&gt;{{#if extraHead.remote}}
{{ indent extraHead.remote spaces=4 }}{{/if}}{{#if css.source}}
&lt;style&gt;
{{ indent css.source spaces=6 }} &lt;/style&gt;{{/if}}

View File

@@ -38,6 +38,7 @@ const main = {
{from: 'index.html', to: 'index.html'}
])
],
devtool: 'source-map',
output: {
filename: '[name].js',
path: path.join(__dirname, '..', '..', 'build', 'examples')
@@ -46,7 +47,6 @@ const main = {
// configuration specific to the dev environment
const dev = {
devtool: 'source-map',
plugins: [
new webpack.EnvironmentPlugin(
Object.assign({NODE_ENV: 'development'}, process.env)

View File

@@ -150,7 +150,6 @@ ExampleBuilder.prototype.render = async function(dir, chunk) {
break;
}
}
jsSource = jsSource.replace(/'\.\.\/src\//g, '\'');
if (data.cloak) {
for (const entry of data.cloak) {
jsSource = jsSource.replace(new RegExp(entry.key, 'g'), entry.value);

385
externs/oli.js Normal file
View File

@@ -0,0 +1,385 @@
/**
* @externs
*/
/**
* @type {Object}
*/
let oli;
/**
* @interface
*/
oli.AssertionError = function() {};
/**
* @type {number}
*/
oli.AssertionError.prototype.code;
/**
* @interface
*/
oli.events.Event = function() {};
/**
* @type {Object}
*/
oli.events.Event.prototype.target;
/**
* @type {string}
*/
oli.events.Event.prototype.type;
/**
*/
oli.events.Event.prototype.preventDefault = function() {};
/**
*/
oli.events.Event.prototype.stopPropagation = function() {};
/**
* @interface
*/
oli.Collection.Event = function() {};
/**
* @type {*}
*/
oli.Collection.Event.prototype.element;
/**
* @interface
*/
oli.DragBoxEvent = function() {};
/**
* @type {ol.Coordinate}
*/
oli.DragBoxEvent.prototype.coordinate;
/**
* @type {module:ol/MapBrowserEvent~MapBrowserEvent}
*/
oli.DragBoxEvent.prototype.mapBrowserEvent;
/**
* @interface
*/
oli.DrawEvent = function() {};
/**
* @type {module:ol/Feature~Feature}
*/
oli.DrawEvent.prototype.feature;
/**
* @interface
*/
oli.ExtentEvent = function() {};
/**
* @type {ol.Extent}
*/
oli.ExtentEvent.prototype.extent;
/**
* @interface
*/
oli.ModifyEvent = function() {};
/**
* @type {ol.Collection.<module:ol/Feature~Feature>}
*/
oli.ModifyEvent.prototype.features;
/**
* @type {module:ol/MapBrowserEvent~MapBrowserEvent}
*/
oli.ModifyEvent.prototype.mapBrowserEvent;
/**
* @type {Object}
*/
oli.Object;
/**
* @interface
*/
oli.Object.Event = function() {};
/**
* @type {string}
*/
oli.Object.Event.prototype.key;
/**
* @type {*}
*/
oli.Object.Event.prototype.oldValue;
/**
* @interface
*/
oli.MapBrowserEvent = function() {};
/**
* @type {ol.Coordinate}
*/
oli.MapBrowserEvent.prototype.coordinate;
/**
* @type {Event}
*/
oli.MapBrowserEvent.prototype.originalEvent;
/**
* @type {ol.Pixel}
*/
oli.MapBrowserEvent.prototype.pixel;
/**
* @type {boolean}
*/
oli.MapBrowserEvent.prototype.dragging;
/**
* @interface
*/
oli.MapEvent = function() {};
/**
* @type {ol.PluggableMap}
*/
oli.MapEvent.prototype.map;
/**
* @type {module:ol/PluggableMap~FrameState}
*/
oli.MapEvent.prototype.frameState;
/**
* @interface
*/
oli.SelectEvent = function() {};
/**
* @type {Array.<module:ol/Feature~Feature>}
*/
oli.SelectEvent.prototype.deselected;
/**
* @type {Array.<module:ol/Feature~Feature>}
*/
oli.SelectEvent.prototype.selected;
/**
* @type {module:ol/MapBrowserEvent~MapBrowserEvent}
*/
oli.SelectEvent.prototype.mapBrowserEvent;
/**
* @type {Object}
*/
oli.control;
/**
* @interface
*/
oli.control.Control = function() {};
/**
* @param {ol.PluggableMap} map Map.
* @return {undefined} Undefined.
*/
oli.control.Control.prototype.setMap = function(map) {};
/**
* @type {Object}
*/
oli.interaction;
/**
* @interface
*/
oli.interaction.DragAndDropEvent = function() {};
/**
* @type {Array.<module:ol/Feature~Feature>|undefined}
*/
oli.interaction.DragAndDropEvent.prototype.features;
/**
* @type {module:ol/proj/Projection~Projection|undefined}
*/
oli.interaction.DragAndDropEvent.prototype.projection;
/**
* @type {File}
*/
oli.interaction.DragAndDropEvent.prototype.file;
/**
* @interface
*/
oli.interaction.TranslateEvent = function() {};
/**
* @type {ol.Collection.<module:ol/Feature~Feature>}
*/
oli.interaction.TranslateEvent.prototype.features;
/**
* @type {ol.Coordinate}
*/
oli.interaction.TranslateEvent.prototype.coordinate;
/**
* @type {Object}
*/
oli.render;
/**
* @interface
*/
oli.render.Event = function() {};
/**
* @type {CanvasRenderingContext2D|null|undefined}
*/
oli.render.Event.prototype.context;
/**
* @type {module:ol/PluggableMap~FrameState|undefined}
*/
oli.render.Event.prototype.frameState;
/**
* @type {ol.webgl.Context|null|undefined}
*/
oli.render.Event.prototype.glContext;
/**
* @type {ol.render.VectorContext|undefined}
*/
oli.render.Event.prototype.vectorContext;
/**
* @type {Object}
*/
oli.source;
/**
* @interface
*/
oli.source.ImageEvent = function() {};
/**
* @type {ol.Image}
*/
oli.source.ImageEvent.prototype.image;
/**
* @interface
*/
oli.source.RasterEvent = function() {};
/**
* @type {ol.Extent}
*/
oli.source.RasterEvent.prototype.extent;
/**
* @type {number}
*/
oli.source.RasterEvent.prototype.resolution;
/**
* @type {Object}
*/
oli.source.RasterEvent.prototype.data;
/**
* @interface
*/
oli.source.Tile.Event = function() {};
/**
* @type {ol.Tile}
*/
oli.source.Tile.Event.prototype.tile;
/**
* @interface
*/
oli.source.Vector.Event = function() {};
/**
* @type {module:ol/Feature~Feature|undefined}
*/
oli.source.Vector.Event.prototype.feature;

View File

@@ -1,3 +1,84 @@
# Externs
TODO: remove this directory
This directory contains externs files, which tell the Closure compiler about symbols and properties that it should not rename.
## oli.js
These are special externs that belong to OpenLayers, and this document explains their purpose and how they are used.
### Prevent class properties from being renamed
For events, we make properties available to the application. Methods can be made available by just marking them with the `@api` annotation directly where they are defined; properties should also be added to `oli.js`:
```js
/**
* @interface
*/
oli.MapBrowserEvent = function() {};
/**
* @type {ol.Coordinate}
*/
oli.MapBrowserEvent.prototype.coordinate;
```
In the source file (`src/ol/MapBrowserEvent.js`), the class needs to implement this interface:
```js
/**
* ...
* @constructor
* @implements {oli.MapBrowserEvent}
*/
ol.MapBrowserEvent = function(type, map, originalEvent, opt_frameState) {
// ...
/**
* @type {ol.Coordinate}
* @api
*/
this.coordinate = map.getEventCoordinate(this.originalEvent);
// ...
};
```
### Override methods in custom classes
For custom subclasses in applications, which can be created using `ol.inherits`, the API may want to make certain methods available to override. In addition to marking such methods as `@api`, they should also be added to an interface in `oli.js`:
```js
/**
* @interface
*/
oli.control.Control = function() {};
/**
* @param {ol.PluggableMap} map Map.
* @return {undefined} Undefined.
*/
oli.control.Control.prototype.setMap = function(map) {};
```
This interface must be implemented by the class in the source file (`src/ol/control/control.js`):
```js
/**
* ...
* @constructor
* @implements {oli.control.Control}
*/
ol.control.Control = function(options) {
// ...
};
// ...
/**
* Application subclasses may override this.
* @param {ol.PluggableMap} map Map.
* @api
*/
ol.control.Control.prototype.setMap = function(map) {
// ...
};
```
See Custom controls example for an example of how this can be used.

View File

@@ -1,6 +1,6 @@
{
"name": "openlayers",
"version": "5.0.0-beta.12",
"version": "4.6.5",
"description": "Build tools and sources for developing OpenLayers based mapping applications",
"keywords": [
"map",
@@ -22,8 +22,7 @@
"presrc-closure": "npm run prebuild",
"src-closure": "babel -q --out-dir build/src-closure src/",
"pretypecheck": "npm run src-closure",
"typecheck": "node tasks/typecheck",
"apidoc": "jsdoc config/jsdoc/api/index.md -c config/jsdoc/api/conf.json -P package.json -d build/apidoc"
"typecheck": "node tasks/typecheck"
},
"main": "src/ol/index.js",
"repository": {
@@ -56,7 +55,7 @@
"expect.js": "0.3.1",
"front-matter": "^2.1.2",
"fs-extra": "^6.0.0",
"google-closure-compiler": "20180506.0.0",
"google-closure-compiler": "20180402.0.0",
"handlebars": "4.0.11",
"html-webpack-plugin": "^3.0.1",
"istanbul": "0.4.5",

View File

@@ -9,6 +9,7 @@ import {VERSION, inherits} from './index.js';
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
* @constructor
* @extends {Error}
* @implements {oli.AssertionError}
* @param {number} code Error code.
*/
const AssertionError = function(code) {

View File

@@ -24,6 +24,7 @@ const Property = {
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.CollectionEvent}
* @param {module:ol/CollectionEventType} type Type.
* @param {*=} opt_element Element.
*/

View File

@@ -23,7 +23,7 @@ import {getHeight} from './extent.js';
* post requests or - in general - through XHR requests, where the src of the
* image element would be set to a data URI when the content is loaded.
*
* @typedef {function(module:ol/Image, string)} LoadFunction
* @typedef {function(module:ol/Image~Image, string)} LoadFunction
* @api
*/

View File

@@ -94,7 +94,7 @@ ImageCanvas.prototype.load = function() {
/**
* @return {HTMLCanvasElement} Canvas element.
* @inheritDoc
*/
ImageCanvas.prototype.getImage = function() {
return this.canvas_;

View File

@@ -35,7 +35,7 @@ import CanvasVectorTileLayerRenderer from './renderer/canvas/VectorTileLayer.js'
* target: 'map'
* });
*
* The above snippet creates a map using a {@link module:ol/layer/Tile} to
* The above snippet creates a map using a {@link module:ol/layer/Tile~Tile} to
* display {@link module:ol/source/OSM~OSM} OSM data and render it to a DOM
* element with the id `map`.
*

View File

@@ -11,6 +11,7 @@ import MapEvent from './MapEvent.js';
*
* @constructor
* @extends {module:ol/MapEvent}
* @implements {oli.MapBrowserEvent}
* @param {string} type Event type.
* @param {module:ol/PluggableMap} map Map.
* @param {Event} browserEvent Browser event.

View File

@@ -11,6 +11,7 @@ import Event from './events/Event.js';
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.MapEvent}
* @param {string} type Event type.
* @param {module:ol/PluggableMap} map Map.
* @param {?module:ol/PluggableMap~FrameState=} opt_frameState Frame state.

View File

@@ -17,6 +17,7 @@ import {assign} from './obj.js';
* @param {string} key The property name.
* @param {*} oldValue The old value for `key`.
* @extends {module:ol/events/Event}
* @implements {oli.Object.Event}
* @constructor
*/
const ObjectEvent = function(type, key, oldValue) {

View File

@@ -8,7 +8,7 @@
export default {
/**
* Triggered when a property is changed.
* @event module:ol/Object~ObjectEvent#propertychange
* @event module:ol/Object~Event#propertychange
* @api
*/
PROPERTYCHANGE: 'propertychange'

View File

@@ -87,7 +87,7 @@ import {create as createTransform, apply as applyTransform} from './transform.js
* @typedef {Object} MapOptions
* @property {module:ol/Collection.<module:ol/control/Control>|Array.<module:ol/control/Control>} [controls]
* Controls initially added to the map. If not specified,
* {@link module:ol/control/util~defaults} is used.
* {@link module:ol/control~defaults} is used.
* @property {number} [pixelRatio=window.devicePixelRatio] The ratio between
* physical pixels and device-independent pixels (dips) on the device.
* @property {module:ol/Collection.<module:ol/interaction/Interaction>|Array.<module:ol/interaction/Interaction>} [interactions]
@@ -790,13 +790,13 @@ PluggableMap.prototype.getInteractions = function() {
/**
* Get the layergroup associated with this map.
* @return {module:ol/layer/Group} A layer group containing the layers in this map.
* @return {module:ol/layer/Group~Group} A layer group containing the layers in this map.
* @observable
* @api
*/
PluggableMap.prototype.getLayerGroup = function() {
return (
/** @type {module:ol/layer/Group} */ (this.get(MapProperty.LAYERGROUP))
/** @type {module:ol/layer/Group~Group} */ (this.get(MapProperty.LAYERGROUP))
);
};
@@ -1310,7 +1310,8 @@ PluggableMap.prototype.renderFrame_ = function(time) {
/**
* Sets the layergroup of this map.
* @param {module:ol/layer/Group} layerGroup A layer group containing the layers in this map.
* @param {module:ol/layer/Group~Group} layerGroup A layer group containing the layers in
* this map.
* @observable
* @api
*/

View File

@@ -1175,7 +1175,7 @@ View.prototype.setCenter = function(center) {
/**
* @param {module:ol/ViewHint} hint Hint.
* @param {module:ol/ViewHint~ViewHint} hint Hint.
* @param {number} delta Delta.
* @return {number} New value.
*/

View File

@@ -231,13 +231,6 @@ Attribution.prototype.updateElement_ = function(frameState) {
}
const attributions = this.getSourceAttributions_(frameState);
const visible = attributions.length > 0;
if (this.renderedVisible_ != visible) {
this.element.style.display = visible ? '' : 'none';
this.renderedVisible_ = visible;
}
if (equals(attributions, this.renderedAttributions_)) {
return;
}
@@ -251,6 +244,13 @@ Attribution.prototype.updateElement_ = function(frameState) {
this.ulElement_.appendChild(element);
}
const visible = attributions.length > 0;
if (this.renderedVisible_ != visible) {
this.element.style.display = visible ? '' : 'none';
this.renderedVisible_ = visible;
}
this.renderedAttributions_ = attributions;
};

View File

@@ -46,6 +46,7 @@ import {listen, unlistenByKey} from '../events.js';
*
* @constructor
* @extends {module:ol/Object}
* @implements {oli.control.Control}
* @param {module:ol/control/Control~Options} options Control options.
* @api
*/
@@ -115,6 +116,7 @@ Control.prototype.getMap = function() {
* Subclasses may set up event handlers to get notified about changes to
* the map here.
* @param {module:ol/PluggableMap} map Map.
* @override
* @api
*/
Control.prototype.setMap = function(map) {

View File

@@ -10,14 +10,14 @@
* @return {CanvasRenderingContext2D} The context.
*/
export function createCanvasContext2D(opt_width, opt_height) {
const canvas = /** @type {HTMLCanvasElement} */ (document.createElement('CANVAS'));
const canvas = document.createElement('CANVAS');
if (opt_width) {
canvas.width = opt_width;
}
if (opt_height) {
canvas.height = opt_height;
}
return /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d'));
return canvas.getContext('2d');
}

View File

@@ -12,6 +12,7 @@
* {@link module:ol/events/EventTarget~EventTarget}.
*
* @constructor
* @implements {oli.events.Event}
* @param {string} type Type.
*/
const Event = function(type) {
@@ -41,6 +42,7 @@ const Event = function(type) {
/**
* Stop event propagation.
* @function
* @override
* @api
*/
Event.prototype.preventDefault =
@@ -48,6 +50,7 @@ Event.prototype.preventDefault =
/**
* Stop event propagation.
* @function
* @override
* @api
*/
Event.prototype.stopPropagation = function() {

View File

@@ -11,7 +11,7 @@ import {WEBKIT, MAC} from '../has.js';
* A function that takes an {@link module:ol/MapBrowserEvent} and returns a
* `{boolean}`. If the condition is met, true should be returned.
*
* @typedef {function(this: ?, module:ol/MapBrowserEvent): boolean} Condition
* @typedef {function(module:ol/MapBrowserEvent): boolean} Condition
*/

View File

@@ -165,7 +165,7 @@ export function containsXY(extent, x, y) {
* Get the relationship between a coordinate and extent.
* @param {module:ol/extent~Extent} extent The extent.
* @param {module:ol/coordinate~Coordinate} coordinate The coordinate.
* @return {module:ol/extent/Relationship} The relationship (bitwise compare with
* @return {module:ol/extent/Relationship~Relationship} The relationship (bitwise compare with
* module:ol/extent/Relationship~Relationship).
*/
export function coordinateRelationship(extent, coordinate) {
@@ -478,7 +478,7 @@ export function getCenter(extent) {
/**
* Get a corner coordinate of an extent.
* @param {module:ol/extent~Extent} extent Extent.
* @param {module:ol/extent/Corner} corner Corner.
* @param {module:ol/extent/Corner~Corner} corner Corner.
* @return {module:ol/coordinate~Coordinate} Corner coordinate.
*/
export function getCorner(extent, corner) {

View File

@@ -127,7 +127,7 @@ function readGeometry(object, opt_options) {
* array. It is used for checking for holes.
* Logic inspired by: https://github.com/Esri/terraformer-arcgis-parser
* @param {Array.<!Array.<!Array.<number>>>} rings Rings.
* @param {module:ol/geom/GeometryLayout} layout Geometry layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Geometry layout.
* @return {Array.<!Array.<!Array.<number>>>} Transformed rings.
*/
function convertRings(rings, layout) {
@@ -218,7 +218,7 @@ function readMultiLineStringGeometry(object) {
/**
* @param {EsriJSONGeometry} object Object.
* @return {module:ol/geom/GeometryLayout} The geometry layout to use.
* @return {module:ol/geom/GeometryLayout~GeometryLayout} The geometry layout to use.
*/
function getGeometryLayout(object) {
let layout = GeometryLayout.XY;

View File

@@ -428,7 +428,7 @@ function appendCoordinate(flatCoordinates, layoutOptions, node, values) {
* @param {module:ol/format/GPX~LayoutOptions} layoutOptions Layout options.
* @param {Array.<number>} flatCoordinates Flat coordinates.
* @param {Array.<number>=} ends Ends.
* @return {module:ol/geom/GeometryLayout} Layout.
* @return {module:ol/geom/GeometryLayout~GeometryLayout} Layout.
*/
function applyLayoutOptions(layoutOptions, flatCoordinates, ends) {
let layout = GeometryLayout.XY;

View File

@@ -17,7 +17,7 @@ import {get as getProjection} from '../proj.js';
/**
* @typedef {Object} Options
* @property {number} [factor=1e5] The factor by which the coordinates values will be scaled.
* @property {module:ol/geom/GeometryLayout} [geometryLayout='XY'] Layout of the
* @property {module:ol/geom/GeometryLayout~GeometryLayout} [geometryLayout='XY'] Layout of the
* feature geometries created by the format reader.
*/
@@ -51,7 +51,7 @@ const Polyline = function(opt_options) {
/**
* @private
* @type {module:ol/geom/GeometryLayout}
* @type {module:ol/geom/GeometryLayout~GeometryLayout}
*/
this.geometryLayout_ = options.geometryLayout ?
options.geometryLayout : GeometryLayout.XY;

View File

@@ -229,7 +229,7 @@ const Parser = function(lexer) {
this.token_;
/**
* @type {module:ol/geom/GeometryLayout}
* @type {module:ol/geom/GeometryLayout~GeometryLayout}
* @private
*/
this.layout_ = GeometryLayout.XY;
@@ -282,7 +282,7 @@ Parser.prototype.parse = function() {
/**
* Try to parse the dimensional info.
* @return {module:ol/geom/GeometryLayout} The layout.
* @return {module:ol/geom/GeometryLayout~GeometryLayout} The layout.
* @private
*/
Parser.prototype.parseGeometryLayout_ = function() {
@@ -815,7 +815,7 @@ WKT.prototype.readGeometryFromText = function(text, opt_options) {
/**
* @enum {function (new:module:ol/geom/Geometry, Array, module:ol/geom/GeometryLayout)}
* @enum {function (new:module:ol/geom/Geometry, Array, module:ol/geom/GeometryLayout~GeometryLayout)}
*/
const GeometryConstructor = {
'POINT': Point,

View File

@@ -16,7 +16,7 @@ import {deflateCoordinate} from '../geom/flat/deflate.js';
* @extends {module:ol/geom/SimpleGeometry}
* @param {module:ol/coordinate~Coordinate} center Center.
* @param {number=} opt_radius Radius.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
const Circle = function(center, opt_radius, opt_layout) {
@@ -179,7 +179,7 @@ Circle.prototype.setCenter = function(center) {
* number) of the circle.
* @param {module:ol/coordinate~Coordinate} center Center.
* @param {number} radius Radius.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
Circle.prototype.setCenterAndRadius = function(center, radius, opt_layout) {
@@ -217,7 +217,7 @@ Circle.prototype.setCoordinates = function(coordinates, opt_layout) {};
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
*/
Circle.prototype.setFlatCoordinates = function(layout, flatCoordinates) {

View File

@@ -23,7 +23,7 @@ import {douglasPeucker} from '../geom/flat/simplify.js';
* @constructor
* @extends {module:ol/geom/SimpleGeometry}
* @param {Array.<module:ol/coordinate~Coordinate>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
const LineString = function(coordinates, opt_layout) {
@@ -238,7 +238,7 @@ LineString.prototype.intersectsExtent = function(extent) {
/**
* Set the coordinates of the linestring.
* @param {Array.<module:ol/coordinate~Coordinate>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @override
* @api
*/
@@ -258,7 +258,7 @@ LineString.prototype.setCoordinates = function(coordinates, opt_layout) {
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
*/
LineString.prototype.setFlatCoordinates = function(layout, flatCoordinates) {

View File

@@ -20,7 +20,7 @@ import {douglasPeucker} from '../geom/flat/simplify.js';
* @constructor
* @extends {module:ol/geom/SimpleGeometry}
* @param {Array.<module:ol/coordinate~Coordinate>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
const LinearRing = function(coordinates, opt_layout) {
@@ -132,7 +132,7 @@ LinearRing.prototype.intersectsExtent = function(extent) {};
/**
* Set the coordinates of the linear ring.
* @param {Array.<module:ol/coordinate~Coordinate>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @override
* @api
*/
@@ -152,7 +152,7 @@ LinearRing.prototype.setCoordinates = function(coordinates, opt_layout) {
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
*/
LinearRing.prototype.setFlatCoordinates = function(layout, flatCoordinates) {

View File

@@ -22,7 +22,7 @@ import {douglasPeuckerArray} from '../geom/flat/simplify.js';
* @constructor
* @extends {module:ol/geom/SimpleGeometry}
* @param {Array.<Array.<module:ol/coordinate~Coordinate>>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
const MultiLineString = function(coordinates, opt_layout) {
@@ -255,7 +255,7 @@ MultiLineString.prototype.intersectsExtent = function(extent) {
/**
* Set the coordinates of the multilinestring.
* @param {Array.<Array.<module:ol/coordinate~Coordinate>>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @override
* @api
*/
@@ -276,7 +276,7 @@ MultiLineString.prototype.setCoordinates = function(coordinates, opt_layout) {
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
* @param {Array.<number>} ends Ends.
*/

View File

@@ -19,7 +19,7 @@ import {squaredDistance as squaredDx} from '../math.js';
* @constructor
* @extends {module:ol/geom/SimpleGeometry}
* @param {Array.<module:ol/coordinate~Coordinate>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
const MultiPoint = function(coordinates, opt_layout) {
@@ -162,7 +162,7 @@ MultiPoint.prototype.intersectsExtent = function(extent) {
/**
* Set the coordinates of the multipoint.
* @param {Array.<module:ol/coordinate~Coordinate>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @override
* @api
*/
@@ -182,7 +182,7 @@ MultiPoint.prototype.setCoordinates = function(coordinates, opt_layout) {
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
*/
MultiPoint.prototype.setFlatCoordinates = function(layout, flatCoordinates) {

View File

@@ -27,7 +27,7 @@ import {quantizeMultiArray} from '../geom/flat/simplify.js';
* @constructor
* @extends {module:ol/geom/SimpleGeometry}
* @param {Array.<Array.<Array.<module:ol/coordinate~Coordinate>>>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
const MultiPolygon = function(coordinates, opt_layout) {
@@ -352,7 +352,7 @@ MultiPolygon.prototype.intersectsExtent = function(extent) {
/**
* Set the coordinates of the multipolygon.
* @param {Array.<Array.<Array.<module:ol/coordinate~Coordinate>>>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @override
* @api
*/
@@ -379,7 +379,7 @@ MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout) {
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
* @param {Array.<Array.<number>>} endss Endss.
*/

View File

@@ -16,7 +16,7 @@ import {squaredDistance as squaredDx} from '../math.js';
* @constructor
* @extends {module:ol/geom/SimpleGeometry}
* @param {module:ol/coordinate~Coordinate} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
const Point = function(coordinates, opt_layout) {
@@ -116,7 +116,7 @@ Point.prototype.setCoordinates = function(coordinates, opt_layout) {
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
*/
Point.prototype.setFlatCoordinates = function(layout, flatCoordinates) {

View File

@@ -33,7 +33,7 @@ import {modulo} from '../math.js';
* linear ring defines a hole in the surface of the polygon. A linear ring
* is an array of vertices' coordinates where the first coordinate and the
* last are equivalent.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @api
*/
const Polygon = function(coordinates, opt_layout) {
@@ -333,7 +333,7 @@ Polygon.prototype.intersectsExtent = function(extent) {
/**
* Set the coordinates of the polygon.
* @param {Array.<Array.<module:ol/coordinate~Coordinate>>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
* @override
* @api
*/
@@ -354,7 +354,7 @@ Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
* @param {Array.<number>} ends Ends.
*/

View File

@@ -25,7 +25,7 @@ const SimpleGeometry = function() {
/**
* @protected
* @type {module:ol/geom/GeometryLayout}
* @type {module:ol/geom/GeometryLayout~GeometryLayout}
*/
this.layout = GeometryLayout.XY;
@@ -48,7 +48,7 @@ inherits(SimpleGeometry, Geometry);
/**
* @param {number} stride Stride.
* @return {module:ol/geom/GeometryLayout} layout Layout.
* @return {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
*/
function getLayoutForStride(stride) {
let layout;
@@ -60,13 +60,13 @@ function getLayoutForStride(stride) {
layout = GeometryLayout.XYZM;
}
return (
/** @type {module:ol/geom/GeometryLayout} */ (layout)
/** @type {module:ol/geom/GeometryLayout~GeometryLayout} */ (layout)
);
}
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @return {number} Stride.
*/
export function getStrideForLayout(layout) {
@@ -134,7 +134,7 @@ SimpleGeometry.prototype.getLastCoordinate = function() {
/**
* Return the {@link module:ol/geom/GeometryLayout~GeometryLayout layout} of the geometry.
* @return {module:ol/geom/GeometryLayout} Layout.
* @return {module:ol/geom/GeometryLayout~GeometryLayout} Layout.
* @api
*/
SimpleGeometry.prototype.getLayout = function() {
@@ -201,7 +201,7 @@ SimpleGeometry.prototype.getStride = function() {
/**
* @param {module:ol/geom/GeometryLayout} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout} layout Layout.
* @param {Array.<number>} flatCoordinates Flat coordinates.
* @protected
*/
@@ -215,13 +215,13 @@ SimpleGeometry.prototype.setFlatCoordinatesInternal = function(layout, flatCoord
/**
* @abstract
* @param {Array} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout=} opt_layout Layout.
*/
SimpleGeometry.prototype.setCoordinates = function(coordinates, opt_layout) {};
/**
* @param {module:ol/geom/GeometryLayout|undefined} layout Layout.
* @param {module:ol/geom/GeometryLayout~GeometryLayout|undefined} layout Layout.
* @param {Array} coordinates Coordinates.
* @param {number} nesting Nesting.
* @protected

View File

@@ -45,6 +45,7 @@ const DragAndDropEventType = {
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.interaction.DragAndDropEvent}
* @param {module:ol/interaction/DragAndDrop~DragAndDropEventType} type Type.
* @param {File} file File.
* @param {Array.<module:ol/Feature>=} opt_features Features.

View File

@@ -14,7 +14,7 @@ import RenderBox from '../render/Box.js';
* A function that takes a {@link module:ol/MapBrowserEvent} and two
* {@link module:ol~Pixel}s and returns a `{boolean}`. If the condition is met,
* true should be returned.
* @typedef {function(this: ?, module:ol/MapBrowserEvent, module:ol~Pixel, module:ol~Pixel):boolean} EndCondition
* @typedef {function(module:ol/MapBrowserEvent, module:ol~Pixel, module:ol~Pixel):boolean} EndCondition
*/
@@ -69,6 +69,7 @@ const DragBoxEventType = {
* @param {module:ol/MapBrowserEvent} mapBrowserEvent Originating event.
* @extends {module:ol/events/Event}
* @constructor
* @implements {oli.DragBoxEvent}
*/
const DragBoxEvent = function(type, coordinate, mapBrowserEvent) {
Event.call(this, type);
@@ -121,7 +122,7 @@ const DragBox = function(opt_options) {
const options = opt_options ? opt_options : {};
/**
* @type {module:ol/render/Box}
* @type {module:ol/render/Box~Box}
* @private
*/
this.box_ = new RenderBox(options.className || 'ol-dragbox');

View File

@@ -131,6 +131,7 @@ const DrawEventType = {
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.DrawEvent}
* @param {module:ol/interaction/Draw~DrawEventType} type Type.
* @param {module:ol/Feature} feature The feature drawn.
*/
@@ -388,7 +389,7 @@ const Draw = function(options) {
/**
* Draw overlay where our sketch features are drawn.
* @type {module:ol/layer/Vector}
* @type {module:ol/layer/Vector~Vector}
* @private
*/
this.overlay_ = new VectorLayer({

View File

@@ -53,6 +53,7 @@ const ExtentEventType = {
* instances of this type.
*
* @constructor
* @implements {oli.ExtentEvent}
* @param {module:ol/extent~Extent} extent the new extent
* @extends {module:ol/events/Event}
*/
@@ -142,7 +143,7 @@ const ExtentInteraction = function(opt_options) {
/**
* Layer for the extentFeature
* @type {module:ol/layer/Vector}
* @type {module:ol/layer/Vector~Vector}
* @private
*/
this.extentOverlay_ = new VectorLayer({
@@ -157,7 +158,7 @@ const ExtentInteraction = function(opt_options) {
/**
* Layer for the vertexFeature
* @type {module:ol/layer/Vector}
* @type {module:ol/layer/Vector~Vector}
* @private
*/
this.vertexOverlay_ = new VectorLayer({

View File

@@ -93,6 +93,7 @@ const ModifyEventType = {
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.ModifyEvent}
* @param {ModifyEventType} type Type.
* @param {module:ol/Collection.<module:ol/Feature>} features
* The features modified.
@@ -249,7 +250,7 @@ const Modify = function(options) {
/**
* Draw overlay where sketch features are drawn.
* @type {module:ol/layer/Vector}
* @type {module:ol/layer/Vector~Vector}
* @private
*/
this.overlay_ = new VectorLayer({

View File

@@ -107,6 +107,7 @@ const SelectEventType = {
* @param {Array.<module:ol/Feature>} deselected Deselected features.
* @param {module:ol/MapBrowserEvent} mapBrowserEvent Associated
* {@link module:ol/MapBrowserEvent}.
* @implements {oli.SelectEvent}
* @extends {module:ol/events/Event}
* @constructor
*/
@@ -220,7 +221,7 @@ const Select = function(opt_options) {
/**
* @private
* @type {module:ol/layer/Vector}
* @type {module:ol/layer/Vector~Vector}
*/
this.featureOverlay_ = featureOverlay;
@@ -301,13 +302,13 @@ Select.prototype.getHitTolerance = function() {
* programmatic method like pushing features to
* {@link module:ol/interaction/Select~Select#getFeatures collection}.
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature
* @return {module:ol/layer/Vector} Layer.
* @return {module:ol/layer/Vector~Vector} Layer.
* @api
*/
Select.prototype.getLayer = function(feature) {
const key = getUid(feature);
return (
/** @type {module:ol/layer/Vector} */ (this.featureLayerAssociation_[key])
/** @type {module:ol/layer/Vector~Vector} */ (this.featureLayerAssociation_[key])
);
};

View File

@@ -59,6 +59,7 @@ const TranslateEventType = {
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.interaction.TranslateEvent}
* @param {module:ol/interaction/Translate~TranslateEventType} type Type.
* @param {module:ol/Collection.<module:ol/Feature>} features The features translated.
* @param {module:ol/coordinate~Coordinate} coordinate The event coordinate.

View File

@@ -28,7 +28,7 @@ import {assign} from '../obj.js';
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Note that with {@link module:ol/layer/Base} and all its subclasses, any property set in
* the options is set as a {@link module:ol/Object} property on the layer object, so
* the options is set as a {@link module:ol/Object property on the layer object, so
* is observable, and has get/set accessors.
*
* @constructor
@@ -171,7 +171,7 @@ BaseLayer.prototype.getOpacity = function() {
/**
* @abstract
* @return {module:ol/source/State} Source state.
* @return {module:ol/source/State~State} Source state.
*/
BaseLayer.prototype.getSourceState = function() {};

View File

@@ -58,7 +58,7 @@ const DEFAULT_GRADIENT = ['#00f', '#0ff', '#0f0', '#ff0', '#f00'];
/**
* @classdesc
* Layer for rendering vector data as a heatmap.
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*

View File

@@ -30,7 +30,7 @@ import Layer from '../layer/Layer.js';
* @classdesc
* Server-rendered images that are available for arbitrary extents and
* resolutions.
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*

View File

@@ -35,7 +35,7 @@ import {assign} from '../obj.js';
* @classdesc
* For layer sources that provide pre-rendered, tiled images in grids that are
* organized by zoom levels for specific resolutions.
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*

View File

@@ -80,7 +80,7 @@ const Property = {
/**
* @classdesc
* Vector data that is rendered client-side.
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
* Note that any property set in the options is set as a {@link }
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*
@@ -147,7 +147,7 @@ const VectorLayer = function(opt_options) {
/**
* @private
* @type {module:ol/layer/VectorTileRenderType|string}
* @type {module:ol/layer/VectorTileRenderType~VectorTileRenderType|string}
*/
this.renderMode_ = options.renderMode || VectorRenderType.VECTOR;

View File

@@ -91,7 +91,7 @@ export const RenderType = {
/**
* @classdesc
* Layer for vector tile data that is rendered client-side.
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject
* property on the layer object; for example, setting `title: 'My Title'` in the
* options means that `title` is observable, and has get/set accessors.
*

251
src/ol/ol.css Normal file
View File

@@ -0,0 +1,251 @@
.ol-box {
box-sizing: border-box;
border-radius: 2px;
border: 2px solid blue;
}
.ol-mouse-position {
top: 8px;
right: 8px;
position: absolute;
}
.ol-scale-line {
background: rgba(0,60,136,0.3);
border-radius: 4px;
bottom: 8px;
left: 8px;
padding: 2px;
position: absolute;
}
.ol-scale-line-inner {
border: 1px solid #eee;
border-top: none;
color: #eee;
font-size: 10px;
text-align: center;
margin: 1px;
will-change: contents, width;
}
.ol-overlay-container {
will-change: left,right,top,bottom;
}
.ol-unsupported {
display: none;
}
.ol-viewport, .ol-unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
.ol-selectable {
-webkit-touch-callout: default;
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
.ol-grabbing {
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing;
}
.ol-grab {
cursor: move;
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab;
}
.ol-control {
position: absolute;
background-color: rgba(255,255,255,0.4);
border-radius: 4px;
padding: 2px;
}
.ol-control:hover {
background-color: rgba(255,255,255,0.6);
}
.ol-zoom {
top: .5em;
left: .5em;
}
.ol-rotate {
top: .5em;
right: .5em;
transition: opacity .25s linear, visibility 0s linear;
}
.ol-rotate.ol-hidden {
opacity: 0;
visibility: hidden;
transition: opacity .25s linear, visibility 0s linear .25s;
}
.ol-zoom-extent {
top: 4.643em;
left: .5em;
}
.ol-full-screen {
right: .5em;
top: .5em;
}
@media print {
.ol-control {
display: none;
}
}
.ol-control button {
display: block;
margin: 1px;
padding: 0;
color: white;
font-size: 1.14em;
font-weight: bold;
text-decoration: none;
text-align: center;
height: 1.375em;
width: 1.375em;
line-height: .4em;
background-color: rgba(0,60,136,0.5);
border: none;
border-radius: 2px;
}
.ol-control button::-moz-focus-inner {
border: none;
padding: 0;
}
.ol-zoom-extent button {
line-height: 1.4em;
}
.ol-compass {
display: block;
font-weight: normal;
font-size: 1.2em;
will-change: transform;
}
.ol-touch .ol-control button {
font-size: 1.5em;
}
.ol-touch .ol-zoom-extent {
top: 5.5em;
}
.ol-control button:hover,
.ol-control button:focus {
text-decoration: none;
background-color: rgba(0,60,136,0.7);
}
.ol-zoom .ol-zoom-in {
border-radius: 2px 2px 0 0;
}
.ol-zoom .ol-zoom-out {
border-radius: 0 0 2px 2px;
}
.ol-attribution {
text-align: right;
bottom: .5em;
right: .5em;
max-width: calc(100% - 1.3em);
}
.ol-attribution ul {
margin: 0;
padding: 0 .5em;
font-size: .7rem;
line-height: 1.375em;
color: #000;
text-shadow: 0 0 2px #fff;
}
.ol-attribution li {
display: inline;
list-style: none;
line-height: inherit;
}
.ol-attribution li:not(:last-child):after {
content: " ";
}
.ol-attribution img {
max-height: 2em;
max-width: inherit;
vertical-align: middle;
}
.ol-attribution ul, .ol-attribution button {
display: inline-block;
}
.ol-attribution.ol-collapsed ul {
display: none;
}
.ol-attribution:not(.ol-collapsed) {
background: rgba(255,255,255,0.8);
}
.ol-attribution.ol-uncollapsible {
bottom: 0;
right: 0;
border-radius: 4px 0 0;
height: 1.1em;
line-height: 1em;
}
.ol-attribution.ol-uncollapsible img {
margin-top: -.2em;
max-height: 1.6em;
}
.ol-attribution.ol-uncollapsible button {
display: none;
}
.ol-zoomslider {
top: 4.5em;
left: .5em;
height: 200px;
}
.ol-zoomslider button {
position: relative;
height: 10px;
}
.ol-touch .ol-zoomslider {
top: 5.5em;
}
.ol-overviewmap {
left: 0.5em;
bottom: 0.5em;
}
.ol-overviewmap.ol-uncollapsible {
bottom: 0;
left: 0;
border-radius: 0 4px 0 0;
}
.ol-overviewmap .ol-overviewmap-map,
.ol-overviewmap button {
display: inline-block;
}
.ol-overviewmap .ol-overviewmap-map {
border: 1px solid #7b98bc;
height: 150px;
margin: 2px;
width: 150px;
}
.ol-overviewmap:not(.ol-collapsed) button{
bottom: 1px;
left: 2px;
position: absolute;
}
.ol-overviewmap.ol-collapsed .ol-overviewmap-map,
.ol-overviewmap.ol-uncollapsible button {
display: none;
}
.ol-overviewmap:not(.ol-collapsed) {
background: rgba(255,255,255,0.8);
}
.ol-overviewmap-box {
border: 2px dotted rgba(0,60,136,0.7);
}
.ol-overviewmap .ol-overviewmap-box:hover {
cursor: move;
}

13
src/ol/package.json Normal file
View File

@@ -0,0 +1,13 @@
{
"name": "ol",
"version": "5.0.0-beta.11",
"description": "OpenLayers mapping library",
"main": "index.js",
"module": "index.js",
"license": "BSD-2-Clause",
"dependencies": {
"pbf": "3.1.0",
"pixelworks": "1.1.0",
"rbush": "2.0.2"
}
}

View File

@@ -54,7 +54,7 @@ const MsSource = function(dispatcher) {
/**
* @const
* @type {!Object.<string, MSPointerEvent|Object>}
* @type {!Object.<string, Event|Object>}
*/
this.pointerMap = dispatcher.pointerMap;
};
@@ -79,7 +79,7 @@ const POINTER_TYPES = [
* for the fake pointer event.
*
* @private
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
* @return {Object} The copied event.
*/
MsSource.prototype.prepareEvent_ = function(inEvent) {
@@ -105,7 +105,7 @@ MsSource.prototype.cleanup = function(pointerId) {
/**
* Handler for `msPointerDown`.
*
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
*/
MsSource.prototype.msPointerDown = function(inEvent) {
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
@@ -117,7 +117,7 @@ MsSource.prototype.msPointerDown = function(inEvent) {
/**
* Handler for `msPointerMove`.
*
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
*/
MsSource.prototype.msPointerMove = function(inEvent) {
const e = this.prepareEvent_(inEvent);
@@ -128,7 +128,7 @@ MsSource.prototype.msPointerMove = function(inEvent) {
/**
* Handler for `msPointerUp`.
*
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
*/
MsSource.prototype.msPointerUp = function(inEvent) {
const e = this.prepareEvent_(inEvent);
@@ -140,7 +140,7 @@ MsSource.prototype.msPointerUp = function(inEvent) {
/**
* Handler for `msPointerOut`.
*
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
*/
MsSource.prototype.msPointerOut = function(inEvent) {
const e = this.prepareEvent_(inEvent);
@@ -151,7 +151,7 @@ MsSource.prototype.msPointerOut = function(inEvent) {
/**
* Handler for `msPointerOver`.
*
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
*/
MsSource.prototype.msPointerOver = function(inEvent) {
const e = this.prepareEvent_(inEvent);
@@ -162,7 +162,7 @@ MsSource.prototype.msPointerOver = function(inEvent) {
/**
* Handler for `msPointerCancel`.
*
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
*/
MsSource.prototype.msPointerCancel = function(inEvent) {
const e = this.prepareEvent_(inEvent);
@@ -174,7 +174,7 @@ MsSource.prototype.msPointerCancel = function(inEvent) {
/**
* Handler for `msLostPointerCapture`.
*
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
*/
MsSource.prototype.msLostPointerCapture = function(inEvent) {
const e = this.dispatcher.makeEvent('lostpointercapture',
@@ -186,7 +186,7 @@ MsSource.prototype.msLostPointerCapture = function(inEvent) {
/**
* Handler for `msGotPointerCapture`.
*
* @param {MSPointerEvent} inEvent The in event.
* @param {Event} inEvent The in event.
*/
MsSource.prototype.msGotPointerCapture = function(inEvent) {
const e = this.dispatcher.makeEvent('gotpointercapture',

View File

@@ -60,7 +60,7 @@ import CanvasImmediateRenderer from './render/canvas/Immediate.js';
*
* @param {CanvasRenderingContext2D} context Canvas context.
* @param {module:ol/render~ToContextOptions=} opt_options Options.
* @return {module:ol/render/canvas/Immediate} Canvas Immediate.
* @return {module:ol/render/canvas/Immediate~Immediate} Canvas Immediate.
* @api
*/
export function toContext(context, opt_options) {

View File

@@ -7,7 +7,8 @@ import Event from '../events/Event.js';
/**
* @constructor
* @extends {module:ol/events/Event}
* @param {module:ol/render/EventType} type Type.
* @implements {oli.render.Event}
* @param {module:ol/render/EventType~EventType} type Type.
* @param {module:ol/render/VectorContext=} opt_vectorContext Vector context.
* @param {module:ol/PluggableMap~FrameState=} opt_frameState Frame state.
* @param {?CanvasRenderingContext2D=} opt_context Context.

View File

@@ -12,7 +12,7 @@ const ReplayGroup = function() {};
/**
* @abstract
* @param {number|undefined} zIndex Z index.
* @param {module:ol/render/ReplayType} replayType Replay type.
* @param {module:ol/render/ReplayType~ReplayType} replayType Replay type.
* @return {module:ol/render/VectorContext} Replay.
*/
ReplayGroup.prototype.getReplay = function(zIndex, replayType) {};

View File

@@ -19,7 +19,7 @@ import {create as createTransform, compose as composeTransform} from '../../tran
/**
* @type {Object.<module:ol/render/ReplayType,
* @type {Object.<module:ol/render/ReplayType~ReplayType,
* function(new: module:ol/render/canvas/Replay, number, module:ol/extent~Extent,
* number, number, boolean, Array.<module:ol/render/canvas~DeclutterGroup>)>}
*/
@@ -100,7 +100,7 @@ const CanvasReplayGroup = function(
/**
* @private
* @type {!Object.<string, !Object.<module:ol/render/ReplayType, module:ol/render/canvas/Replay>>}
* @type {!Object.<string, !Object.<module:ol/render/ReplayType~ReplayType, module:ol/render/canvas/Replay>>}
*/
this.replaysByZIndex_ = {};
@@ -252,7 +252,7 @@ CanvasReplayGroup.prototype.clip = function(context, transform) {
/**
* @param {Array.<module:ol/render/ReplayType>} replays Replays.
* @param {Array.<module:ol/render/ReplayType~ReplayType>} replays Replays.
* @return {boolean} Has replays of the provided types.
*/
CanvasReplayGroup.prototype.hasReplays = function(replays) {
@@ -431,7 +431,7 @@ CanvasReplayGroup.prototype.getReplay = function(zIndex, replayType) {
/**
* @return {Object.<string, Object.<module:ol/render/ReplayType, module:ol/render/canvas/Replay>>} Replays.
* @return {Object.<string, Object.<module:ol/render/ReplayType~ReplayType, module:ol/render/canvas/Replay>>} Replays.
*/
CanvasReplayGroup.prototype.getReplays = function() {
return this.replaysByZIndex_;
@@ -451,7 +451,7 @@ CanvasReplayGroup.prototype.isEmpty = function() {
* @param {module:ol/transform~Transform} transform Transform.
* @param {number} viewRotation View rotation.
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features to skip.
* @param {Array.<module:ol/render/ReplayType>=} opt_replayTypes Ordered replay types to replay.
* @param {Array.<module:ol/render/ReplayType~ReplayType>=} opt_replayTypes Ordered replay types to replay.
* Default is {@link module:ol/render/replay~ORDER}
* @param {Object.<string, module:ol/render/canvas~DeclutterGroup>=} opt_declutterReplays Declutter replays.
*/

View File

@@ -6,7 +6,7 @@ import ReplayType from '../render/ReplayType.js';
/**
* @const
* @type {Array.<module:ol/render/ReplayType>}
* @type {Array.<module:ol/render/ReplayType~ReplayType>}
*/
export const ORDER = [
ReplayType.POLYGON,

View File

@@ -19,7 +19,7 @@ import WebGLTextReplay from '../webgl/TextReplay.js';
const HIT_DETECTION_SIZE = [1, 1];
/**
* @type {Object.<module:ol/render/ReplayType,
* @type {Object.<module:ol/render/ReplayType~ReplayType,
* function(new: module:ol/render/webgl/Replay, number,
* module:ol/extent~Extent)>}
*/
@@ -64,7 +64,7 @@ const WebGLReplayGroup = function(tolerance, maxExtent, opt_renderBuffer) {
/**
* @private
* @type {!Object.<string,
* Object.<module:ol/render/ReplayType, module:ol/render/webgl/Replay>>}
* Object.<module:ol/render/ReplayType~ReplayType, module:ol/render/webgl/Replay>>}
*/
this.replaysByZIndex_ = {};

View File

@@ -96,7 +96,7 @@ LayerRenderer.prototype.getLayer = function() {
* @private
*/
LayerRenderer.prototype.handleImageChange_ = function(event) {
const image = /** @type {module:ol/Image} */ (event.target);
const image = /** @type {module:ol/Image~Image} */ (event.target);
if (image.getState() === ImageState.LOADED) {
this.renderIfReadyAndVisible();
}

View File

@@ -72,7 +72,7 @@ CanvasLayerRenderer.prototype.clip = function(context, frameState, extent) {
/**
* @param {module:ol/render/EventType} type Event type.
* @param {module:ol/render/EventType~EventType} type Event type.
* @param {CanvasRenderingContext2D} context Context.
* @param {module:ol/PluggableMap~FrameState} frameState Frame state.
* @param {module:ol/transform~Transform=} opt_transform Transform.

View File

@@ -61,7 +61,7 @@ inherits(CanvasMapRenderer, MapRenderer);
/**
* @param {module:ol/render/EventType} type Event type.
* @param {module:ol/render/EventType~EventType} type Event type.
* @param {module:ol/PluggableMap~FrameState} frameState Frame state.
* @private
*/

View File

@@ -14,7 +14,7 @@ import {create as createTransform, compose as composeTransform} from '../../tran
/**
* @constructor
* @extends {module:ol/renderer/canvas/IntermediateCanvas}
* @param {module:ol/layer/Tile|module:ol/layer/VectorTile} tileLayer Tile layer.
* @param {module:ol/layer/Tile|module:ol/layer/VectorTile~VectorTile} tileLayer Tile layer.
* @api
*/
const CanvasTileLayerRenderer = function(tileLayer) {
@@ -346,7 +346,7 @@ CanvasTileLayerRenderer.prototype.getImage = function() {
/**
* @function
* @return {module:ol/layer/Tile|module:ol/layer/VectorTile}
* @return {module:ol/layer/Tile|module:ol/layer/VectorTile~VectorTile}
*/
CanvasTileLayerRenderer.prototype.getLayer;

View File

@@ -29,7 +29,7 @@ const CanvasVectorLayerRenderer = function(vectorLayer) {
* Declutter tree.
* @private
*/
this.declutterTree_ = vectorLayer.getDeclutter() ? rbush(9, undefined) : null;
this.declutterTree_ = vectorLayer.getDeclutter() ? rbush(9) : null;
/**
* @private

View File

@@ -28,7 +28,7 @@ import {
/**
* @type {!Object.<string, Array.<module:ol/render/ReplayType>>}
* @type {!Object.<string, Array.<module:ol/render/ReplayType~ReplayType>>}
*/
const IMAGE_REPLAYS = {
'image': [ReplayType.POLYGON, ReplayType.CIRCLE,
@@ -38,7 +38,7 @@ const IMAGE_REPLAYS = {
/**
* @type {!Object.<string, Array.<module:ol/render/ReplayType>>}
* @type {!Object.<string, Array.<module:ol/render/ReplayType~ReplayType>>}
*/
const VECTOR_REPLAYS = {
'image': [ReplayType.DEFAULT],
@@ -50,7 +50,7 @@ const VECTOR_REPLAYS = {
/**
* @constructor
* @extends {module:ol/renderer/canvas/TileLayer}
* @param {module:ol/layer/VectorTile} layer VectorTile layer.
* @param {module:ol/layer/VectorTile~VectorTile} layer VectorTile layer.
* @api
*/
const CanvasVectorTileLayerRenderer = function(layer) {
@@ -66,7 +66,7 @@ const CanvasVectorTileLayerRenderer = function(layer) {
* Declutter tree.
* @private
*/
this.declutterTree_ = layer.getDeclutter() ? rbush(9, undefined) : null;
this.declutterTree_ = layer.getDeclutter() ? rbush(9) : null;
/**
* @private
@@ -113,7 +113,7 @@ CanvasVectorTileLayerRenderer['handles'] = function(layer) {
* @return {module:ol/renderer/canvas/VectorTileLayer} The layer renderer.
*/
CanvasVectorTileLayerRenderer['create'] = function(mapRenderer, layer) {
return new CanvasVectorTileLayerRenderer(/** @type {module:ol/layer/VectorTile} */ (layer));
return new CanvasVectorTileLayerRenderer(/** @type {module:ol/layer/VectorTile~VectorTile} */ (layer));
};

View File

@@ -182,7 +182,7 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
/**
* @param {module:ol/render/EventType} type Event type.
* @param {module:ol/render/EventType~EventType} type Event type.
* @param {module:ol/webgl/Context} context WebGL context.
* @param {module:ol/PluggableMap~FrameState} frameState Frame state.
* @private

View File

@@ -248,7 +248,7 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
/**
* @param {module:ol/render/EventType} type Event type.
* @param {module:ol/render/EventType~EventType} type Event type.
* @param {module:ol/PluggableMap~FrameState} frameState Frame state.
* @private
*/

View File

@@ -48,8 +48,9 @@ const ImageSourceEventType = {
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.source.ImageEvent}
* @param {string} type Type.
* @param {module:ol/Image} image The image.
* @param {module:ol/Image~Image} image The image.
*/
const ImageSourceEvent = function(type, image) {
@@ -57,7 +58,7 @@ const ImageSourceEvent = function(type, image) {
/**
* The image related to the event.
* @type {module:ol/Image}
* @type {module:ol/Image~Image}
* @api
*/
this.image = image;
@@ -72,7 +73,7 @@ inherits(ImageSourceEvent, Event);
* @property {module:ol/extent~Extent} [extent]
* @property {module:ol/proj~ProjectionLike} projection
* @property {Array.<number>} [resolutions]
* @property {module:ol/source/State} [state]
* @property {module:ol/source/State~State} [state]
*/
@@ -205,7 +206,7 @@ ImageSource.prototype.getImageInternal = function(extent, resolution, pixelRatio
* @protected
*/
ImageSource.prototype.handleImageChange = function(event) {
const image = /** @type {module:ol/Image} */ (event.target);
const image = /** @type {module:ol/Image~Image} */ (event.target);
switch (image.getState()) {
case ImageState.LOADING:
this.dispatchEvent(
@@ -231,7 +232,7 @@ ImageSource.prototype.handleImageChange = function(event) {
/**
* Default image load function for image sources that use module:ol/Image~Image image
* instances.
* @param {module:ol/Image} image Image.
* @param {module:ol/Image~Image} image Image.
* @param {string} src Source.
*/
export function defaultImageLoadFunction(image, src) {

View File

@@ -99,7 +99,7 @@ const ImageArcGISRest = function(opt_options) {
/**
* @private
* @type {module:ol/Image}
* @type {module:ol/Image~Image}
*/
this.image_ = null;

View File

@@ -38,7 +38,7 @@ import ImageSource from '../source/Image.js';
* width and height of the map viewport, and so on. Must be `1` or higher.
* @property {Array.<number>} [resolutions] Resolutions.
* If specified, new canvases will be created for these resolutions
* @property {module:ol/source/State} [state] Source state.
* @property {module:ol/source/State~State} [state] Source state.
*/

View File

@@ -106,7 +106,7 @@ const ImageMapGuide = function(options) {
/**
* @private
* @type {module:ol/Image}
* @type {module:ol/Image~Image}
*/
this.image_ = null;

View File

@@ -54,7 +54,7 @@ const Static = function(options) {
/**
* @private
* @type {module:ol/Image}
* @type {module:ol/Image~Image}
*/
this.image_ = new ImageWrapper(imageExtent, undefined, 1, options.url, crossOrigin, imageLoadFunction);

View File

@@ -110,7 +110,7 @@ const ImageWMS = function(opt_options) {
/**
* @private
* @type {module:ol/Image}
* @type {module:ol/Image~Image}
*/
this.image_ = null;

View File

@@ -77,6 +77,7 @@ const RasterOperationType = {
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.source.RasterEvent}
* @param {string} type Type.
* @param {module:ol/PluggableMap~FrameState} frameState The frame state.
* @param {Object} data An object made available to operations.

View File

@@ -32,7 +32,7 @@ import SourceState from '../source/State.js';
* @typedef {Object} Options
* @property {module:ol/source/Source~AttributionLike} [attributions]
* @property {module:ol/proj~ProjectionLike} projection
* @property {module:ol/source/State} [state]
* @property {module:ol/source/State~State} [state]
* @property {boolean} [wrapX]
*/
@@ -69,7 +69,7 @@ const Source = function(options) {
/**
* @private
* @type {module:ol/source/State}
* @type {module:ol/source/State~State}
*/
this.state_ = options.state !== undefined ?
options.state : SourceState.READY;
@@ -149,7 +149,7 @@ Source.prototype.getResolutions = function() {};
/**
* Get the state of the source, see {@link module:ol/source/State~State} for possible states.
* @return {module:ol/source/State} State.
* @return {module:ol/source/State~State} State.
* @api
*/
Source.prototype.getState = function() {
@@ -189,7 +189,7 @@ Source.prototype.setAttributions = function(attributions) {
/**
* Set the state of the source.
* @param {module:ol/source/State} state State.
* @param {module:ol/source/State~State} state State.
* @protected
*/
Source.prototype.setState = function(state) {

View File

@@ -20,7 +20,7 @@ import {wrapX, getForProjection as getTileGridForProjection} from '../tilegrid.j
* @property {boolean} [opaque]
* @property {number} [tilePixelRatio]
* @property {module:ol/proj~ProjectionLike} [projection]
* @property {module:ol/source/State} [state]
* @property {module:ol/source/State~State} [state]
* @property {module:ol/tilegrid/TileGrid} [tileGrid]
* @property {boolean} [wrapX=true]
* @property {number} [transition]
@@ -107,7 +107,7 @@ TileSource.prototype.canExpireCache = function() {
/**
* @param {module:ol/proj/Projection} projection Projection.
* @param {!Object.<string, module:ol/TileRange>} usedTiles Used tiles.
* @param {Object.<string, module:ol/TileRange>} usedTiles Used tiles.
*/
TileSource.prototype.expireCache = function(projection, usedTiles) {
const tileCache = this.getTileCacheForProjection(projection);
@@ -329,6 +329,7 @@ TileSource.prototype.useTile = UNDEFINED;
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.source.Tile.Event}
* @param {string} type Type.
* @param {module:ol/Tile} tile The tile.
*/

View File

@@ -1,5 +1,5 @@
/**
* @module ol/source/TileImage
* @module module:ol/source/TileImage~TileImage
*/
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
import {getUid, inherits} from '../index.js';
@@ -26,7 +26,7 @@ import {getForProjection as getTileGridForProjection} from '../tilegrid.js';
* @property {module:ol/proj~ProjectionLike} projection Projection.
* @property {boolean} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
* Higher values can increase reprojection performance, but decrease precision.
* @property {module:ol/source/State} [state] Source state.
* @property {module:ol/source/State~State} [state] Source state.
* @property {module:ol/ImageTile~TileClass} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/ImageTile~ImageTile}.
* @property {module:ol/tilegrid/TileGrid} [tileGrid] Tile grid.

View File

@@ -15,7 +15,7 @@ import {getKeyZXY} from '../tilecoord.js';
* @property {module:ol/extent~Extent} [extent]
* @property {boolean} [opaque]
* @property {module:ol/proj~ProjectionLike} [projection]
* @property {module:ol/source/State} [state]
* @property {module:ol/source/State~State} [state]
* @property {module:ol/tilegrid/TileGrid} [tileGrid]
* @property {module:ol/Tile~LoadFunction} tileLoadFunction
* @property {number} [tilePixelRatio]

View File

@@ -38,6 +38,7 @@ import RBush from '../structs/RBush.js';
*
* @constructor
* @extends {module:ol/events/Event}
* @implements {oli.source.Vector.Event}
* @param {string} type Type.
* @param {module:ol/Feature=} opt_feature Feature.
*/

View File

@@ -20,7 +20,7 @@ import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid.
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
* stroke operations.
* @property {module:ol/proj~ProjectionLike} projection Projection.
* @property {module:ol/source/State} [state] Source state.
* @property {module:ol/source/State~State} [state] Source state.
* @property {module:ol/VectorTile~TileClass} [tileClass] Class used to instantiate image tiles.
* Default is {@link module:ol/VectorTile}.
* @property {module:ol/tilegrid/TileGrid} [tileGrid] Tile grid.
@@ -59,7 +59,7 @@ import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid.
* with vector features from the server, it is not meant for feature editing.
* Features are optimized for rendering, their geometries are clipped at or near
* tile boundaries and simplified for a view resolution. See
* {@link module:ol/source/Vector} for vector sources that are suitable for feature
* {@link module:ol/source/VectorSource} for vector sources that are suitable for feature
* editing.
*
* @constructor

View File

@@ -29,7 +29,7 @@ const RBush = function(opt_maxEntries) {
/**
* @private
*/
this.rbush_ = rbush(opt_maxEntries, undefined);
this.rbush_ = rbush(opt_maxEntries);
/**
* A mapping between the objects added to this rbush wrapper

Some files were not shown because too many files have changed in this diff Show More