Compare commits

..

77 Commits

Author SHA1 Message Date
Éric Lemoine
8959aaafd5 Merge pull request #2477 from fredj/2475
Add new olx.format.KMLOptions#extractStyles property
2014-08-08 08:57:15 +02:00
Éric Lemoine
253d64d6f0 Merge pull request #2506 from elemoine/naming
Rename debugtilesource.js to tiledebugsource.js
2014-08-08 08:47:59 +02:00
Éric Lemoine
9d6fced8b4 Merge pull request #2505 from elemoine/graticule-style
Make stroke style of the graticule configurable
2014-08-08 08:43:28 +02:00
Éric Lemoine
9d9f29e1a2 debugtilesource.js changed to tiledebugsource.js 2014-08-08 08:32:44 +02:00
Marc Jansen
b60609d93c Make stroke style of the graticule configurable 2014-08-08 08:28:34 +02:00
Frédéric Junod
54406f5b2f Merge pull request #2416 from fredj/newer-closure-library
Upgrade closure-library version
2014-08-08 07:37:49 +02:00
Frédéric Junod
b8dca21286 Merge pull request #2470 from fredj/2470
EPSG:4326 example broken
2014-08-07 17:38:06 +02:00
Frederic Junod
134a4e220d Change WMS server in examples 2014-08-07 17:25:08 +02:00
Frederic Junod
190db934ee Always use goog.json.parse and set goog.json.USE_NATIVE_JSON=true 2014-08-07 17:14:50 +02:00
Frederic Junod
cf85079d22 Mark 'es5Strict' checks as errors 2014-08-07 17:14:49 +02:00
Frederic Junod
66da8fc393 Upgrade closure-library version 2014-08-07 17:14:49 +02:00
Frederic Junod
9e37aa796a Add new olx.format.KMLOptions#extractStyles property 2014-08-07 17:08:19 +02:00
Frédéric Junod
18b3c3eee7 Merge pull request #2501 from fredj/2501
bug fix to play nice with sencha touch 2.3
2014-08-07 16:58:19 +02:00
Frédéric Junod
5e4cfe875b Merge pull request #2503 from fredj/geolocation-bind-proj
Don't bind to ol.View projection property
2014-08-07 14:04:03 +02:00
Andreas Hocevar
e06fe37607 Merge pull request #2502 from ahocevar/template-test
Add unit test for greedy template replacement
2014-08-07 13:36:24 +02:00
Frederic Junod
0d6cc22bf0 Don't bind to ol.View projection property 2014-08-07 12:59:15 +02:00
Frederic Junod
d3b5a14a9b Don't use TouchList#item function 2014-08-07 12:25:19 +02:00
Andreas Hocevar
410b274b6a Add unit test for greedy template replacement 2014-08-07 12:18:03 +02:00
Andreas Hocevar
0a963d4615 Merge pull request #2497 from ahocevar/greedy-template
TileUrlFunction only replaces first instance of placeholder variables
2014-08-07 12:09:24 +02:00
Andreas Hocevar
08039e9894 Replace multiple placeholder occurrences in templates 2014-08-07 10:51:41 +02:00
Andreas Hocevar
2230349b52 Merge pull request #2498 from ahocevar/custom-def
Unprecise transormation used in example
2014-08-07 09:01:34 +02:00
Andreas Hocevar
52ee406938 Use definition with 7-parameter transform for EPSG:21781 2014-08-06 23:26:26 +02:00
Frédéric Junod
a1e33eabc5 Merge pull request #2499 from fredj/2294
Properly clear features in ol.source.ServerVector#clear
2014-08-06 10:42:31 +02:00
Tim Schaub
1864e03873 Merge pull request #2496 from probins/linear
Correct wrong docs for LinearRing.

Closes #2495.
2014-08-05 11:22:59 -06:00
Frédéric Junod
063532d509 Merge pull request #2455 from fredj/2455
Opacity of last layer is used in postcompose drawing
2014-08-05 17:18:57 +02:00
Frederic Junod
ae98ee8b4a Restore context opacity after drawing layers
Closes #2455
2014-08-05 16:05:23 +02:00
Evgeny Ushkalov
af05b3d031 Properly clear features in ol.source.ServerVector#clear 2014-08-05 15:39:42 +02:00
Peter Robins
d3683fcab9 Correct wrong docs for LinearRing 2014-08-05 11:08:44 +00:00
Andreas Hocevar
1bd522d96f Merge pull request #2481 from probins/styledoc
Improve docs for style
2014-08-05 12:01:19 +02:00
Peter Robins
bf3770a9da Improve docs for style 2014-08-05 09:04:35 +00:00
Éric Lemoine
b6fa8908e5 Merge pull request #2494 from probins/geom
Document LinearRing as abstract class
2014-08-04 12:22:59 +02:00
Éric Lemoine
28c3993088 Merge pull request #2493 from elemoine/jquery-externs
Update jquery externs file
2014-08-04 12:06:04 +02:00
Peter Robins
652fcede22 Document LinearRing as abstract class 2014-08-04 10:05:01 +00:00
Éric Lemoine
41e5aa07bd Update jquery externs file 2014-08-04 11:07:17 +02:00
Andreas Hocevar
b88cb727c9 Merge pull request #2492 from probins/length
Document that geom.getArea/Length on projected plane
2014-08-04 10:40:38 +02:00
Peter Robins
c86569684e Document that geom.getArea/Length on projected plane 2014-08-04 08:02:01 +00:00
Frédéric Junod
7de98d8794 Merge pull request #2433 from fredj/collection
Templatize ol.Collection
2014-08-02 09:47:34 +02:00
Frédéric Junod
acf623f853 Merge pull request #2483 from fredj/view.projection
Remove projection from ol.View observable properties
2014-08-01 16:01:10 +02:00
Frédéric Junod
819fd83e06 Merge pull request #2473 from fredj/2472
Rename olx.FrameState#skippedFeatureUids_ skippedFeatureUids
2014-07-31 13:38:37 +02:00
Frederic Junod
8d9dbcbb2a Remove unneeded type cast 2014-07-31 12:11:27 +02:00
Frederic Junod
e69913900e Remove projection from ol.View observable properties 2014-07-31 12:10:35 +02:00
Frederic Junod
86268bcf58 Rename olx.FrameState#skippedFeatureUids_ skippedFeatureUids
To let the ol.Map#skippedFeatureUids_ property to be renamed by the compiler.
2014-07-31 11:30:39 +02:00
Frédéric Junod
80c6e019a7 Merge pull request #2471 from fredj/jsdoc
minor jsdoc and type annotation fixes
2014-07-31 11:14:08 +02:00
Frederic Junod
7a86bf58bf Improve type annotation 2014-07-31 09:44:52 +02:00
Frederic Junod
051da752f3 Improve type annotation in ol.format.GeoJSON 2014-07-31 09:43:06 +02:00
Frederic Junod
9b476e4ce3 Add the jsdoc ol.style namespace 2014-07-31 09:09:48 +02:00
Frederic Junod
0277026624 Stricter typing for ol.Collection 2014-07-30 09:38:16 +02:00
Frederic Junod
1048d59331 Remove unneeded type cast 2014-07-30 09:09:34 +02:00
Frederic Junod
93218e5db4 Templatize ol.Collection 2014-07-30 09:09:33 +02:00
Frédéric Junod
f99e9e40b7 Merge pull request #2467 from fredj/2460
Add workaround for mousewheel event name
2014-07-29 17:36:32 +02:00
Frédéric Junod
9e33ccad74 Merge pull request #2466 from fredj/unused-typedef
Remove unused ol.CoordinateArray typedef
2014-07-29 17:31:48 +02:00
Frederic Junod
3fce080d5a Add workaround for mousewheel event name
'DOMMouseScroll' for Gecko and 'mousewheel' otherwise.

See https://github.com/google/closure-library/pull/308
2014-07-29 17:10:26 +02:00
Frederic Junod
53be13a658 Remove unused ol.CoordinateArray typedef 2014-07-29 14:44:51 +02:00
Frédéric Junod
7b7070d723 Merge pull request #2458 from openlayers/cluster
Add clustering functionality
2014-07-29 14:10:49 +02:00
Andreas Hocevar
27d5a3cc4c Merge pull request #2463 from gingerik/externs-function-bodies
Remove function bodies from externs
2014-07-29 13:52:12 +02:00
Frédéric Junod
40e16557a9 Merge pull request #2464 from fredj/closure-library-issue-link
Update link to closure-library issue
2014-07-29 13:35:13 +02:00
Frederic Junod
4fa9083854 Update link to closure-library issue 2014-07-29 12:46:35 +02:00
Frederic Junod
06df648733 Add ol.source.Cluster
Initial code by @kenny806
2014-07-29 12:29:43 +02:00
Erik Timmers
077bcdd778 Remove function bodies from externs 2014-07-29 12:02:00 +02:00
Tim Schaub
77674c6728 Merge pull request #2448 from gingerik/wkt-docs
Fix WKT writers output type.
2014-07-28 17:47:10 -06:00
Frédéric Junod
ec8d3a45e4 Merge pull request #2423 from fredj/dispose
Dispose the tiles removed from the cache
2014-07-28 17:18:27 +02:00
Frédéric Junod
707648b828 Merge pull request #2457 from probins/patch-1
Remove reference to simple/whitespace in examples/readme
2014-07-28 12:22:11 +02:00
Peter Robins
8079590b49 Remove reference to simple/whitespace in examples/readme 2014-07-28 10:01:41 +01:00
Marc Jansen
495ad3de93 Merge pull request #2452 from marcjansen/test-typo
Fix typo in ol.Map test.
2014-07-28 09:36:28 +02:00
Marc Jansen
2e37a34459 Fix typo in ol.Map test. 2014-07-28 09:35:23 +02:00
Frédéric Junod
e729b3d423 Merge pull request #2449 from probins/patch-1
Improve wording of ol.Map description
2014-07-28 07:44:09 +02:00
Peter Robins
cff8d4c668 Improve wording of ol.Map description 2014-07-27 12:06:45 +01:00
Erik Timmers
76c883ea89 Fix WKT writers output type 2014-07-26 11:47:35 +02:00
Tim Schaub
4d0fbaedc1 Merge pull request #2446 from tschaub/version
Unconditionally add version info to the build header.
2014-07-25 15:33:30 -06:00
Tim Schaub
c3bddffecb Unconditionally add version info to the build header
This reworks the changes in #2442 so we always include the version info, regardless of whether the module is run as main or not.  This also addresses a few lint related issues.
2014-07-25 12:50:58 -06:00
Bart van den Eijnden
2814abc59d Merge pull request #2420 from gingerik/gpx-extensions
PR for GPX: read extensions tags
2014-07-25 20:15:43 +02:00
Tobias Sauerwein
05e9a47fd1 Merge pull request #2442 from tsauerwein/build-version
Write library version in build files
2014-07-25 16:37:12 +02:00
tsauerwein
9102647751 Write version in builds 2014-07-25 16:10:08 +02:00
Frederic Junod
02ede1eafa Dispose the tiles removed from the cache 2014-07-22 17:49:26 +02:00
Frederic Junod
312d5a87b8 Automatically dispose the ViewportSizeMonitor 2014-07-22 17:47:20 +02:00
Erik Timmers
2f9918f774 Add tests for GPX extensions 2014-07-22 13:20:09 +02:00
Erik Timmers
0309a620ea Add option to process GPX extensions nodes
Fixes #1791.
2014-07-22 13:02:53 +02:00
66 changed files with 867 additions and 207 deletions

View File

@@ -236,6 +236,7 @@ def examples_star_json(name, match):
],
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.json.USE_NATIVE_JSON=true",
"goog.DEBUG=false"
],
"jscomp_error": [
@@ -254,6 +255,7 @@ def examples_star_json(name, match):
"duplicate",
"duplicateMessage",
"es3",
"es5Strict",
"externsValidation",
"fileoverviewTags",
"globalThis",
@@ -276,9 +278,6 @@ def examples_star_json(name, match):
"extra_annotation_name": [
"api", "observable"
],
"jscomp_off": [
"es5Strict"
],
"compilation_level": "ADVANCED",
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
"use_types_for_optimization": True,

View File

@@ -18,6 +18,7 @@
],
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.json.USE_NATIVE_JSON=true",
"goog.DEBUG=false"
],
"jscomp_error": [
@@ -33,6 +34,7 @@
"deprecated",
"duplicateMessage",
"es3",
"es5Strict",
"externsValidation",
"fileoverviewTags",
"globalThis",
@@ -58,9 +60,6 @@
"extra_annotation_name": [
"api", "observable"
],
"jscomp_off": [
"es5Strict"
],
"compilation_level": "ADVANCED",
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
"use_types_for_optimization": true,

View File

@@ -14,6 +14,7 @@
],
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.json.USE_NATIVE_JSON=true",
"goog.DEBUG=false"
],
"jscomp_error": [
@@ -29,6 +30,7 @@
"deprecated",
"duplicateMessage",
"es3",
"es5Strict",
"externsValidation",
"fileoverviewTags",
"globalThis",
@@ -54,11 +56,8 @@
"extra_annotation_name": [
"api", "observable"
],
"jscomp_off": [
"es5Strict"
],
"compilation_level": "ADVANCED",
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
"output_wrapper": "(function(){%output%})();",
"use_types_for_optimization": true,
"manage_closure_dependencies": true
}

View File

@@ -1,3 +1,3 @@
{
"library_url": "https://github.com/google/closure-library/archive/ab89cf45c216615d73a2f5dea720afb9d3415d1f.zip"
"library_url": "https://github.com/google/closure-library/archive/946a7d39d4ffe08676c755b21d901e71d9904a3b.zip"
}

51
examples/cluster.html Normal file
View File

@@ -0,0 +1,51 @@
<!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="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Clustering example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Clustering example</h4>
<p id="shortdesc">Example of using <code>ol.Cluster</code>.</p>
<div id="docs">
<p>See the <a href="cluster.js" target="_blank">cluster.js source</a> to see how this is done.</p>
</div>
<div id="tags">cluster vector</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=cluster" type="text/javascript"></script>
</body>
</html>

80
examples/cluster.js Normal file
View File

@@ -0,0 +1,80 @@
goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.geom.Point');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.source.Cluster');
goog.require('ol.source.MapQuest');
goog.require('ol.source.Vector');
goog.require('ol.style.Circle');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.style.Text');
var count = 20000;
var features = new Array(count);
var e = 4500000;
for (var i = 0; i < count; ++i) {
var coordinates = [2 * e * Math.random() - e, 2 * e * Math.random() - e];
features[i] = new ol.Feature(new ol.geom.Point(coordinates));
}
var source = new ol.source.Vector({
features: features
});
var clusterSource = new ol.source.Cluster({
distance: 40,
source: source
});
var styleCache = {};
var clusters = new ol.layer.Vector({
source: clusterSource,
style: function(feature, resolution) {
var size = feature.get('features').length;
var style = styleCache[size];
if (!style) {
style = [new ol.style.Style({
image: new ol.style.Circle({
radius: 10,
stroke: new ol.style.Stroke({
color: '#fff'
}),
fill: new ol.style.Fill({
color: '#3399CC'
})
}),
text: new ol.style.Text({
text: size.toString(),
fill: new ol.style.Fill({
color: '#fff'
})
})
})];
styleCache[size] = style;
}
return style;
}
});
var raster = new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'sat'})
});
var raw = new ol.layer.Vector({
source: source
});
var map = new ol.Map({
layers: [raster, clusters],
renderer: 'canvas',
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});

View File

@@ -9,11 +9,9 @@ goog.require('ol.source.TileWMS');
var layers = [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://vmap0.tiles.osgeo.org/wms/vmap0',
url: 'http://demo.opengeo.org/geoserver/wms',
params: {
'VERSION': '1.1.1',
'LAYERS': 'basic',
'FORMAT': 'image/jpeg'
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}
})
})

View File

@@ -47,13 +47,13 @@ var positions = new ol.geom.LineString([],
// Geolocation Control
var geolocation = new ol.Geolocation(/** @type {olx.GeolocationOptions} */ ({
projection: view.getProjection(),
trackingOptions: {
maximumAge: 10000,
enableHighAccuracy: true,
timeout: 600000
}
}));
geolocation.bindTo('projection', view);
var deltaMean = 500; // the geolocation sampling period mean in ms

View File

@@ -30,8 +30,9 @@ var map = new ol.Map({
view: view
});
var geolocation = new ol.Geolocation();
geolocation.bindTo('projection', view);
var geolocation = new ol.Geolocation({
projection: view.getProjection()
});
var track = new ol.dom.Input(document.getElementById('track'));
track.bindTo('checked', geolocation, 'tracking');

View File

@@ -18,8 +18,7 @@ var view = new ol.View({
zoom: 1
});
var viewProjection = /** @type {ol.proj.Projection} */
(view.getProjection());
var viewProjection = view.getProjection();
var map = new ol.Map({
layers: [wmsLayer],

View File

@@ -4,6 +4,7 @@ goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
goog.require('ol.source.OSM');
goog.require('ol.style.Stroke');
var map = new ol.Map({
@@ -21,5 +22,12 @@ var map = new ol.Map({
});
// Create the graticule component
var graticule = new ol.Graticule();
var graticule = new ol.Graticule({
// the style to use for the lines, optional.
strokeStyle: new ol.style.Stroke({
color: 'rgba(255,120,0,0.9)',
width: 2,
lineDash: [0.5, 4]
})
});
graticule.setMap(map);

View File

@@ -8,6 +8,7 @@ goog.require('ol.source.Stamen');
var vector = new ol.layer.Heatmap({
source: new ol.source.KML({
extractStyles: false,
projection: 'EPSG:3857',
url: 'data/kml/2012_Earthquakes_Mag5.kml'
}),

View File

@@ -46,6 +46,7 @@ var styleFunction = function(feature, resolution) {
var vector = new ol.layer.Vector({
source: new ol.source.KML({
extractStyles: false,
projection: 'EPSG:3857',
url: 'data/kml/timezones.kml'
}),

View File

@@ -25,9 +25,9 @@ var map = new ol.Map({
});
var geolocation = new ol.Geolocation({
projection: view.getProjection(),
tracking: true
});
geolocation.bindTo('projection', view);
geolocation.once('change:position', function() {
view.setCenter(geolocation.getPosition());
view.setResolution(2.388657133911758);

View File

@@ -3,7 +3,7 @@
Although the main purpose of these examples is to demonstrate how to use the API, they also serve other purposes in the development cycle, and so are not exactly as they would be in normal application code:
* every time the library changes, they are compiled together with the library as a basic check that they remain in sync with the library
* they use a special loader script to enable defining at run time which build mode (debug/whitespace/simple/advanced) to use
* they use a special loader script to enable defining at run time which build mode (raw/debug/advanced) to use
To enable this, examples have the following, not needed in application code:

View File

@@ -14,11 +14,9 @@ var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://vmap0.tiles.osgeo.org/wms/vmap0',
url: 'http://demo.opengeo.org/geoserver/wms',
params: {
'VERSION': '1.1.1',
'LAYERS': 'basic',
'FORMAT': 'image/jpeg'
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}
})
}),

View File

@@ -46,7 +46,7 @@
<script src="jquery.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
<script src="http://epsg.io/21781.js" type="text/javascript"></script>
<script src="http://epsg.io/21781-1753.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=wms-image-custom-proj" type="text/javascript"></script>

12
externs/jquery-1.7.js vendored
View File

@@ -1017,17 +1017,21 @@ $.get = function(url, data, success, dataType) {};
/**
* @param {string} url
* @param {(Object.<string,*>|function(Object,string,jQuery.jqXHR))=} data
* @param {function(Object,string,jQuery.jqXHR)=} success
* @param {(Object.<string,*>|
* function(Object.<string,*>,string,jQuery.jqXHR))=} data
* @param {function(Object.<string,*>,string,jQuery.jqXHR)=} success
* @return {jQuery.jqXHR}
* @see http://api.jquery.com/jquery.getjson/#jQuery-getJSON-url-data-success
*/
jQuery.getJSON = function(url, data, success) {};
/**
* @param {string} url
* @param {(Object.<string,*>|function(Object,string,jQuery.jqXHR))=} data
* @param {function(Object,string,jQuery.jqXHR)=} success
* @param {(Object.<string,*>|
* function(Object.<string,*>,string,jQuery.jqXHR))=} data
* @param {function(Object.<string,*>,string,jQuery.jqXHR)=} success
* @return {jQuery.jqXHR}
* @see http://api.jquery.com/jquery.getjson/#jQuery-getJSON-url-data-success
*/
$.getJSON = function(url, data, success) {};

View File

@@ -109,6 +109,7 @@ olx.LogoOptions;
/**
* @typedef {{map: (ol.Map|undefined),
* maxLines: (number|undefined),
* strokeStyle: (ol.style.Stroke|undefined),
* targetSize: (number|undefined)}}
*/
olx.GraticuleOptions;
@@ -133,6 +134,15 @@ olx.GraticuleOptions.prototype.map;
olx.GraticuleOptions.prototype.maxLines;
/**
* The stroke style to use for drawing the graticule. If not provided, the
* lines will be drawn with `rgba(0,0,0,0.2)`, a not fully opaque black.
*
* @type {ol.style.Stroke|undefined}
*/
olx.GraticuleOptions.prototype.strokeStyle;
/**
* The target size of the graticule cells, in pixels. Default
* value is 100 pixels.
@@ -143,14 +153,14 @@ olx.GraticuleOptions.prototype.targetSize;
/**
* Object literal with config options for the map.
* @typedef {{controls: (ol.Collection|Array.<ol.control.Control>|undefined),
* @typedef {{controls: (ol.Collection.<ol.control.Control>|Array.<ol.control.Control>|undefined),
* deviceOptions: (olx.DeviceOptions|undefined),
* pixelRatio: (number|undefined),
* interactions: (ol.Collection|Array.<ol.interaction.Interaction>|undefined),
* interactions: (ol.Collection.<ol.interaction.Interaction>|Array.<ol.interaction.Interaction>|undefined),
* keyboardEventTarget: (Element|Document|string|undefined),
* layers: (Array.<ol.layer.Base>|ol.Collection|undefined),
* layers: (Array.<ol.layer.Base>|ol.Collection.<ol.layer.Base>|undefined),
* logo: (boolean|string|olx.LogoOptions|undefined),
* overlays: (ol.Collection|Array.<ol.Overlay>|undefined),
* overlays: (ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined),
* renderer: (ol.RendererType|Array.<ol.RendererType|string>|string|undefined),
* target: (Element|string|undefined),
* view: (ol.View|undefined)}}
@@ -162,7 +172,7 @@ olx.MapOptions;
/**
* Controls initially added to the map. If not specified,
* {@link ol.control.defaults ol.control.defaults()} is used.
* @type {ol.Collection|Array.<ol.control.Control>|undefined}
* @type {ol.Collection.<ol.control.Control>|Array.<ol.control.Control>|undefined}
*/
olx.MapOptions.prototype.controls;
@@ -185,7 +195,7 @@ olx.MapOptions.prototype.pixelRatio;
/**
* Interactions that are initially added to the map. If not specified,
* {@link ol.interaction.defaults ol.interaction.defaults()} is used.
* @type {ol.Collection|Array.<ol.interaction.Interaction>|undefined}
* @type {ol.Collection.<ol.interaction.Interaction>|Array.<ol.interaction.Interaction>|undefined}
*/
olx.MapOptions.prototype.interactions;
@@ -205,7 +215,7 @@ olx.MapOptions.prototype.keyboardEventTarget;
/**
* Layers. If this is not defined, a map with no layers will be rendered.
* @type {Array.<ol.layer.Base>|ol.Collection|undefined}
* @type {Array.<ol.layer.Base>|ol.Collection.<ol.layer.Base>|undefined}
*/
olx.MapOptions.prototype.layers;
@@ -223,7 +233,7 @@ olx.MapOptions.prototype.logo;
/**
* Overlays initially added to the map. By default, no overlays are added.
* @type {ol.Collection|Array.<ol.Overlay>|undefined}
* @type {ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined}
*/
olx.MapOptions.prototype.overlays;
@@ -1211,12 +1221,20 @@ olx.format.IGCOptions.prototype.altitudeMode;
/**
* @typedef {{defaultStyle: (Array.<ol.style.Style>|undefined)}}
* @typedef {{extractStyles: (boolean|undefined),
* defaultStyle: (Array.<ol.style.Style>|undefined)}}
* @api
*/
olx.format.KMLOptions;
/**
* Extract styles from the KML. Default is `true`.
* @type {boolean|undefined}
*/
olx.format.KMLOptions.prototype.extractStyles;
/**
* Default style. The default default style is the same as Google Earth.
* @type {Array.<ol.style.Style>|undefined}
@@ -1299,6 +1317,25 @@ olx.format.GMLOptions.prototype.multiSurface;
olx.format.GMLOptions.prototype.schemaLocation;
/**
* @typedef {{readExtensions: (function(ol.Feature, Node)|undefined)}}
* @api
*/
olx.format.GPXOptions;
/**
* Callback function to process `extensions` nodes.
* To prevent memory leaks, this callback function must
* not store any references to the node. Note that the `extensions`
* node is not allowed in GPX 1.0. Moreover, only `extensions`
* nodes from `wpt`, `rte` and `trk` can be processed, as those are
* directly mapped to a feature.
* @type {function(ol.Feature, Node)}
*/
olx.format.GPXOptions.prototype.readExtensions;
/**
* @typedef {{featureNS: string,
* featureType: string,
@@ -1713,7 +1750,7 @@ olx.interaction.DragZoomOptions.prototype.style;
/**
* @typedef {{features: (ol.Collection|undefined),
* @typedef {{features: (ol.Collection.<ol.Feature>|undefined),
* source: (ol.source.Vector|undefined),
* snapTolerance: (number|undefined),
* type: ol.geom.GeometryType,
@@ -1728,7 +1765,7 @@ olx.interaction.DrawOptions;
/**
* Destination collection for the drawn features.
* @type {ol.Collection|undefined}
* @type {ol.Collection.<ol.Feature>|undefined}
*/
olx.interaction.DrawOptions.prototype.features;
@@ -1847,7 +1884,7 @@ olx.interaction.KeyboardZoomOptions.prototype.delta;
* @typedef {{deleteCondition: (ol.events.ConditionType|undefined),
* pixelTolerance: (number|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined),
* features: ol.Collection}}
* features: ol.Collection.<ol.Feature>}}
* @api
*/
olx.interaction.ModifyOptions;
@@ -1880,7 +1917,7 @@ olx.interaction.ModifyOptions.prototype.style;
/**
* The features the interaction works on.
* @type {ol.Collection}
* @type {ol.Collection.<ol.Feature>}
*/
olx.interaction.ModifyOptions.prototype.features;
@@ -2181,7 +2218,7 @@ olx.layer.LayerOptions.prototype.maxResolution;
* extent: (ol.Extent|undefined),
* minResolution: (number|undefined),
* maxResolution: (number|undefined),
* layers: (Array.<ol.layer.Base>|ol.Collection|undefined)}}
* layers: (Array.<ol.layer.Base>|ol.Collection.<ol.layer.Base>|undefined)}}
* @api
*/
olx.layer.GroupOptions;
@@ -2253,7 +2290,7 @@ olx.layer.GroupOptions.prototype.maxResolution;
/**
* Child layers.
* @type {Array.<ol.layer.Base>|ol.Collection|undefined}
* @type {Array.<ol.layer.Base>|ol.Collection.<ol.layer.Base>|undefined}
*/
olx.layer.GroupOptions.prototype.layers;
@@ -2582,7 +2619,8 @@ olx.layer.VectorOptions.prototype.source;
/**
* Layer style.
* Layer style. See {@link ol.style} for default style which will be used if
* this is not defined.
* @type {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined}
*/
olx.layer.VectorOptions.prototype.style;
@@ -2596,7 +2634,7 @@ olx.layer.VectorOptions.prototype.visible;
/**
* @typedef {{features: (Array.<ol.Feature>|ol.Collection|undefined),
* @typedef {{features: (Array.<ol.Feature>|ol.Collection.<ol.Feature>|undefined),
* map: (ol.Map|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined)}}
* @api
@@ -2606,7 +2644,7 @@ olx.FeatureOverlayOptions;
/**
* Features.
* @type {Array.<ol.Feature>|ol.Collection|undefined}
* @type {Array.<ol.Feature>|ol.Collection.<ol.Feature>|undefined}
*/
olx.FeatureOverlayOptions.prototype.features;
@@ -2662,6 +2700,67 @@ olx.source.BingMapsOptions.prototype.imagerySet;
*/
olx.source.BingMapsOptions.prototype.tileLoadFunction;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* distance: (number|undefined),
* extent: (ol.Extent|undefined),
* format: (ol.format.Feature|undefined),
* logo: (string|undefined),
* projection: ol.proj.ProjectionLike,
* source: ol.source.Vector}}
* @api
*/
olx.source.ClusterOptions;
/**
* Attributions.
* @type {Array.<ol.Attribution>|undefined}
*/
olx.source.ClusterOptions.prototype.attributions;
/**
* Minimum distance in pixels between clusters. Default is `20`.
* @type {number|undefined}
*/
olx.source.ClusterOptions.prototype.distance;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ClusterOptions.prototype.extent;
/**
* Format.
* @type {ol.format.Feature|undefined}
*/
olx.source.ClusterOptions.prototype.format;
/**
* Logo.
* @type {string|undefined}
*/
olx.source.ClusterOptions.prototype.logo;
/**
* Projection.
* @type {ol.proj.ProjectionLike}
*/
olx.source.ClusterOptions.prototype.projection;
/**
* Source.
* @type {ol.source.Vector}
*/
olx.source.ClusterOptions.prototype.source;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
@@ -3219,6 +3318,7 @@ olx.source.MapGuideOptions.prototype.params;
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultStyle: (Array.<ol.style.Style>|undefined),
* doc: (Document|undefined),
* extractStyles: (boolean|undefined),
* logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined),
* projection: ol.proj.ProjectionLike,
@@ -3251,6 +3351,13 @@ olx.source.KMLOptions.prototype.defaultStyle;
olx.source.KMLOptions.prototype.doc;
/**
* Extract styles from the KML document. Default is `true`.
* @type {boolean|undefined}
*/
olx.source.KMLOptions.prototype.extractStyles;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -4522,7 +4629,8 @@ olx.style.FillOptions;
/**
* Color.
* Color. Default null; if null, the Canvas/renderer default black will be
* used.
* @type {ol.Color|string|undefined}
*/
olx.style.FillOptions.prototype.color;
@@ -4674,7 +4782,8 @@ olx.style.StrokeOptions;
/**
* Color.
* Color. Default null; if null, the Canvas/renderer default black will be
* used.
* @type {ol.Color|string|undefined}
*/
olx.style.StrokeOptions.prototype.color;
@@ -5051,7 +5160,7 @@ olx.View.fitGeometryOptions.prototype.maxZoom;
* pixelToCoordinateMatrix: goog.vec.Mat4.Number,
* postRenderFunctions: Array.<ol.PostRenderFunction>,
* size: ol.Size,
* skippedFeatureUids_: Object.<string, boolean>,
* skippedFeatureUids: Object.<string, boolean>,
* tileQueue: ol.TileQueue,
* time: number,
* usedTiles: Object.<string, Object.<string, ol.TileRange>>,

View File

@@ -16,7 +16,7 @@ var VBArray = function(safeArray) {};
/**
* @return {number}
*/
VBArray.prototype.dimensions = function() {return 0;};
VBArray.prototype.dimensions = function() {};
/**
@@ -36,7 +36,7 @@ VBArray.prototype.lbound = function(opt_dimension) {};
/**
* @return {Array.<number>}
*/
VBArray.prototype.toArray = function() {return null;};
VBArray.prototype.toArray = function() {};
/**

View File

@@ -25,8 +25,7 @@ var WebGLDebugLostContextSimulatingCanvas = function() {};
* @nosideeffects
* @return {number}
*/
WebGLDebugLostContextSimulatingCanvas.prototype.getNumCalls =
function() {return NaN;};
WebGLDebugLostContextSimulatingCanvas.prototype.getNumCalls = function() {};
/**
@@ -64,7 +63,7 @@ var WebGLDebugUtils = {};
* @param {number} value
* @return {string}
*/
WebGLDebugUtils.glEnumToString = function(value) {return '';};
WebGLDebugUtils.glEnumToString = function(value) {};
/**
@@ -73,9 +72,7 @@ WebGLDebugUtils.glEnumToString = function(value) {return '';};
* @param {Array} args Args.
* @return {string} String.
*/
WebGLDebugUtils.glFunctionArgsToString = function(functionName, args) {
return '';
};
WebGLDebugUtils.glFunctionArgsToString = function(functionName, args) {};
/**
@@ -88,9 +85,7 @@ WebGLDebugUtils.init = function(ctx) {};
* @param {HTMLCanvasElement} canvas
* @return {WebGLDebugLostContextSimulatingCanvas}
*/
WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {
return null;
};
WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {};
/**
@@ -100,4 +95,4 @@ WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {
* @return {WebGLDebugRenderingContext}
*/
WebGLDebugUtils.makeDebugContext =
function(context, opt_onErrorFunc, opt_onFunc) {return null;};
function(context, opt_onErrorFunc, opt_onFunc) {};

View File

@@ -89,14 +89,6 @@ ol.BrowserFeature.HAS_DOM = ol.ENABLE_DOM;
ol.BrowserFeature.HAS_GEOLOCATION = 'geolocation' in goog.global.navigator;
/**
* @const
* @type {boolean}
*/
ol.BrowserFeature.HAS_JSON_PARSE =
'JSON' in goog.global && 'parse' in goog.global.JSON;
/**
* True if browser supports touch events.
* @const

View File

@@ -79,7 +79,8 @@ ol.CollectionProperty = {
* @constructor
* @extends {ol.Object}
* @fires ol.CollectionEvent
* @param {Array=} opt_array Array.
* @param {Array.<T>=} opt_array Array.
* @template T
* @api stable
*/
ol.Collection = function(opt_array) {
@@ -88,7 +89,7 @@ ol.Collection = function(opt_array) {
/**
* @private
* @type {Array.<*>}
* @type {Array.<T>}
*/
this.array_ = opt_array || [];
@@ -110,8 +111,8 @@ ol.Collection.prototype.clear = function() {
/**
* @param {Array} arr Array.
* @return {ol.Collection} This collection.
* @param {Array.<T>} arr Array.
* @return {ol.Collection.<T>} This collection.
* @api stable
*/
ol.Collection.prototype.extend = function(arr) {
@@ -129,7 +130,7 @@ ol.Collection.prototype.extend = function(arr) {
* for every element. This function takes 3 arguments (the element, the
* index and the array). The return value is ignored.
* @param {S=} opt_this The object to use as `this` in `f`.
* @template T,S
* @template S
* @api stable
*/
ol.Collection.prototype.forEach = function(f, opt_this) {
@@ -142,7 +143,7 @@ ol.Collection.prototype.forEach = function(f, opt_this) {
* is mutated, no events will be dispatched by the collection, and the
* collection's "length" property won't be in sync with the actual length
* of the array.
* @return {Array} Array.
* @return {Array.<T>} Array.
* @api stable
*/
ol.Collection.prototype.getArray = function() {
@@ -153,7 +154,7 @@ ol.Collection.prototype.getArray = function() {
/**
* Get the element at the provided index.
* @param {number} index Index.
* @return {*} Element.
* @return {T} Element.
* @api stable
*/
ol.Collection.prototype.item = function(index) {
@@ -175,7 +176,7 @@ ol.Collection.prototype.getLength = function() {
/**
* Insert an element at the provided index.
* @param {number} index Index.
* @param {*} elem Element.
* @param {T} elem Element.
* @api stable
*/
ol.Collection.prototype.insertAt = function(index, elem) {
@@ -188,7 +189,7 @@ ol.Collection.prototype.insertAt = function(index, elem) {
/**
* Remove the last element of the collection.
* @return {*} Element.
* @return {T} Element.
* @api stable
*/
ol.Collection.prototype.pop = function() {
@@ -198,7 +199,7 @@ ol.Collection.prototype.pop = function() {
/**
* Insert the provided element at the end of the collection.
* @param {*} elem Element.
* @param {T} elem Element.
* @return {number} Length.
* @api stable
*/
@@ -211,8 +212,8 @@ ol.Collection.prototype.push = function(elem) {
/**
* Removes the first occurence of elem from the collection.
* @param {*} elem Element.
* @return {*} The removed element or undefined if elem was not found.
* @param {T} elem Element.
* @return {T|undefined} The removed element or undefined if elem was not found.
* @api stable
*/
ol.Collection.prototype.remove = function(elem) {
@@ -230,7 +231,7 @@ ol.Collection.prototype.remove = function(elem) {
/**
* Remove the element at the provided index.
* @param {number} index Index.
* @return {*} Value.
* @return {T} Value.
* @api stable
*/
ol.Collection.prototype.removeAt = function(index) {
@@ -246,7 +247,7 @@ ol.Collection.prototype.removeAt = function(index) {
/**
* Set the element at the provided index.
* @param {number} index Index.
* @param {*} elem Element.
* @param {T} elem Element.
* @api stable
*/
ol.Collection.prototype.setAt = function(index, elem) {

View File

@@ -15,7 +15,7 @@ goog.require('ol.control.Zoom');
* * {@link ol.control.Attribution}
*
* @param {olx.control.DefaultsOptions=} opt_options Defaults options.
* @return {ol.Collection} Controls.
* @return {ol.Collection.<ol.control.Control>} Controls.
* @api
*/
ol.control.defaults = function(opt_options) {

View File

@@ -1,5 +1,4 @@
goog.provide('ol.Coordinate');
goog.provide('ol.CoordinateArray');
goog.provide('ol.CoordinateFormatType');
goog.provide('ol.coordinate');
@@ -24,14 +23,6 @@ ol.CoordinateFormatType;
ol.Coordinate;
/**
* An array of coordinate arrays.
* @typedef {Array.<ol.Coordinate>}
* @api
*/
ol.CoordinateArray;
/**
* Add `delta` to `coordinate`. `coordinate` is modified in place and returned
* by the function.

View File

@@ -21,7 +21,9 @@ goog.require('ol.style.Style');
* attribute properties, similar to the features in vector file formats like
* GeoJSON.
*
* Features can be styled individually or use the style of their vector layer.
* Features can be styled individually with `setStyle`; otherwise they use the
* style of their vector layer or feature overlay.
*
* Note that attribute properties are set as {@link ol.Object} properties on
* the feature object, so they are observable, and have get/set accessors.
*
@@ -176,9 +178,9 @@ ol.Feature.prototype.getGeometryName = function() {
/**
* @return {ol.style.Style|Array.<ol.style.Style>|
* ol.feature.FeatureStyleFunction} Return the style provided in the
* constructor options or the last call to setStyle in the same format
* that it was provided in.
* ol.feature.FeatureStyleFunction} Return the style as set by setStyle in
* the same format that it was provided in. If setStyle has not been run,
* return `undefined`.
* @api
*/
ol.Feature.prototype.getStyle = function() {

View File

@@ -33,7 +33,7 @@ ol.FeatureOverlay = function(opt_options) {
/**
* @private
* @type {ol.Collection}
* @type {ol.Collection.<ol.Feature>}
*/
this.features_ = null;
@@ -104,7 +104,7 @@ ol.FeatureOverlay.prototype.addFeature = function(feature) {
/**
* @return {ol.Collection} Features collection.
* @return {ol.Collection.<ol.Feature>} Features collection.
* @api
*/
ol.FeatureOverlay.prototype.getFeatures = function() {
@@ -212,7 +212,7 @@ ol.FeatureOverlay.prototype.render_ = function() {
/**
* @param {ol.Collection} features Features collection.
* @param {ol.Collection.<ol.Feature>} features Features collection.
* @api
*/
ol.FeatureOverlay.prototype.setFeatures = function(features) {

View File

@@ -159,7 +159,7 @@ ol.format.GeoJSON.readPolygonGeometry_ = function(object) {
/**
* @param {ol.geom.Geometry} geometry Geometry.
* @private
* @return {GeoJSONObject} GeoJSON geometry.
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} GeoJSON geometry.
*/
ol.format.GeoJSON.writeGeometry_ = function(geometry) {
var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()];
@@ -302,7 +302,7 @@ ol.format.GeoJSON.GEOMETRY_READERS_ = {
/**
* @const
* @private
* @type {Object.<string, function(ol.geom.Geometry): GeoJSONObject>}
* @type {Object.<string, function(ol.geom.Geometry): (GeoJSONGeometry|GeoJSONGeometryCollection)>}
*/
ol.format.GeoJSON.GEOMETRY_WRITERS_ = {
'Point': ol.format.GeoJSON.writePointGeometry_,
@@ -456,7 +456,7 @@ ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) {
*
* @function
* @param {ol.Feature} feature Feature.
* @return {ArrayBuffer|Node|Object|string} GeoJSON.
* @return {GeoJSONFeature} GeoJSON.
* @api
*/
ol.format.GeoJSON.prototype.writeFeature;
@@ -492,7 +492,7 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(feature) {
*
* @function
* @param {Array.<ol.Feature>} features Features.
* @return {ArrayBuffer|Node|Object|string} GeoJSON.
* @return {GeoJSONObject} GeoJSON.
* @api
*/
ol.format.GeoJSON.prototype.writeFeatures;
@@ -519,7 +519,7 @@ ol.format.GeoJSON.prototype.writeFeaturesObject = function(features) {
*
* @function
* @param {ol.geom.Geometry} geometry Geometry.
* @return {ArrayBuffer|Node|Object|string} GeoJSON.
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} GeoJSON.
* @api
*/
ol.format.GeoJSON.prototype.writeGeometry;

View File

@@ -1689,7 +1689,7 @@ ol.format.GML.prototype.writeGeometryNode = function(geometry) {
*
* @function
* @param {Array.<ol.Feature>} features Features.
* @return {ArrayBuffer|Node|Object|string} Result.
* @return {Node} Result.
* @api
*/
ol.format.GML.prototype.writeFeatures;

View File

@@ -21,10 +21,20 @@ goog.require('ol.xml');
*
* @constructor
* @extends {ol.format.XMLFeature}
* @param {olx.format.GPXOptions=} opt_options Options.
* @api
*/
ol.format.GPX = function() {
ol.format.GPX = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
goog.base(this);
/**
* @type {function(ol.Feature, Node)|undefined}
* @private
*/
this.readExtensions_ = options.readExtensions;
};
goog.inherits(ol.format.GPX, ol.format.XMLFeature);
@@ -88,6 +98,19 @@ ol.format.GPX.parseLink_ = function(node, objectStack) {
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
*/
ol.format.GPX.parseExtensions_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'extensions');
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
goog.object.set(values, 'extensionsNode_', node);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
@@ -275,6 +298,7 @@ ol.format.GPX.RTE_PARSERS_ = ol.xml.makeParsersNS(
'link': ol.format.GPX.parseLink_,
'number':
ol.xml.makeObjectPropertySetter(ol.format.XSD.readNonNegativeInteger),
'extensions': ol.format.GPX.parseExtensions_,
'type': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'rtept': ol.format.GPX.parseRtePt_
});
@@ -307,6 +331,7 @@ ol.format.GPX.TRK_PARSERS_ = ol.xml.makeParsersNS(
'number':
ol.xml.makeObjectPropertySetter(ol.format.XSD.readNonNegativeInteger),
'type': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'extensions': ol.format.GPX.parseExtensions_,
'trkseg': ol.format.GPX.parseTrkSeg_
});
@@ -361,10 +386,30 @@ ol.format.GPX.WPT_PARSERS_ = ol.xml.makeParsersNS(
'ageofdgpsdata':
ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal),
'dgpsid':
ol.xml.makeObjectPropertySetter(ol.format.XSD.readNonNegativeInteger)
ol.xml.makeObjectPropertySetter(ol.format.XSD.readNonNegativeInteger),
'extensions': ol.format.GPX.parseExtensions_
});
/**
* @param {Array.<ol.Feature>} features
* @private
*/
ol.format.GPX.prototype.handleReadExtensions_ = function(features) {
if (goog.isNull(features)) {
features = [];
}
for (var i = 0, ii = features.length; i < ii; ++i) {
var feature = features[i];
if (goog.isDef(this.readExtensions_)) {
var extensionsNode = feature.get('extensionsNode_') || null;
this.readExtensions_(feature, extensionsNode);
}
feature.set('extensionsNode_', undefined);
}
};
/**
* Read the first feature from a GPX source.
*
@@ -392,6 +437,7 @@ ol.format.GPX.prototype.readFeatureFromNode = function(node) {
if (!goog.isDef(feature)) {
return null;
}
this.handleReadExtensions_([feature]);
return feature;
};
@@ -420,6 +466,7 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node) {
/** @type {Array.<ol.Feature>} */ ([]), ol.format.GPX.GPX_PARSERS_,
node, []);
if (goog.isDef(features)) {
this.handleReadExtensions_(features);
return features;
} else {
return [];
@@ -798,7 +845,7 @@ ol.format.GPX.GPX_SERIALIZERS_ = ol.xml.makeStructureNS(
*
* @function
* @param {Array.<ol.Feature>} features Features.
* @return {ArrayBuffer|Node|Object|string} Result.
* @return {Node} Result.
* @api
*/
ol.format.GPX.prototype.writeFeatures;

View File

@@ -2,7 +2,6 @@ goog.provide('ol.format.JSONFeature');
goog.require('goog.asserts');
goog.require('goog.json');
goog.require('ol.BrowserFeature');
goog.require('ol.format.Feature');
goog.require('ol.format.FormatType');
@@ -32,12 +31,7 @@ ol.format.JSONFeature.prototype.getObject_ = function(source) {
if (goog.isObject(source)) {
return source;
} else if (goog.isString(source)) {
var object;
if (ol.BrowserFeature.HAS_JSON_PARSE) {
object = /** @type {Object} */ (JSON.parse(source));
} else {
object = goog.json.parse(source);
}
var object = goog.json.parse(source);
return goog.isDef(object) ? object : null;
} else {
goog.asserts.fail();

View File

@@ -2,6 +2,7 @@
// FIXME why does node.getAttribute return an unknown type?
// FIXME text
// FIXME serialize arbitrary feature properties
// FIXME don't parse style if extractStyles is false
goog.provide('ol.format.KML');
@@ -98,6 +99,13 @@ ol.format.KML = function(opt_options) {
}
};
/**
* @private
* @type {boolean}
*/
this.extractStyles_ = goog.isDef(options.extractStyles) ?
options.extractStyles : true;
/**
* @private
* @type {Object.<string, (Array.<ol.style.Style>|string)>}
@@ -1427,7 +1435,9 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
feature.setId(id);
}
feature.setProperties(object);
feature.setStyle(this.featureStyleFunction_);
if (this.extractStyles_) {
feature.setStyle(this.featureStyleFunction_);
}
return feature;
};
@@ -2494,7 +2504,7 @@ ol.format.KML.OUTER_BOUNDARY_NODE_FACTORY_ =
*
* @function
* @param {Array.<ol.Feature>} features Features.
* @return {ArrayBuffer|Node|Object|string} Result.
* @return {Node} Result.
* @api
*/
ol.format.KML.prototype.writeFeatures;

View File

@@ -294,7 +294,7 @@ ol.format.WKT.prototype.readProjectionFromText = function(text) {
*
* @function
* @param {ol.Feature} feature Feature.
* @return {ArrayBuffer|Node|Object|string} Result.
* @return {string} WKT string.
* @api
*/
ol.format.WKT.prototype.writeFeature;
@@ -317,7 +317,7 @@ ol.format.WKT.prototype.writeFeatureText = function(feature) {
*
* @function
* @param {Array.<ol.Feature>} features Features.
* @return {ArrayBuffer|Node|Object|string} Result.
* @return {string} WKT string.
* @api
*/
ol.format.WKT.prototype.writeFeatures;
@@ -344,7 +344,7 @@ ol.format.WKT.prototype.writeFeaturesText = function(features) {
*
* @function
* @param {ol.geom.Geometry} geometry Geometry.
* @return {ArrayBuffer|Node|Object|string} Node.
* @return {string} WKT string.
* @api
*/
ol.format.WKT.prototype.writeGeometry;

View File

@@ -42,9 +42,10 @@ ol.GeolocationProperty = {
*
* Example:
*
* var geolocation = new ol.Geolocation();
* // take the projection to use from the map's view
* geolocation.bindTo('projection', map.getView());
* var geolocation = new ol.Geolocation({
* // take the projection to use from the map's view
* projection: view.getprojection()
* });
* // listen to changes in position
* geolocation.on('change', function(evt) {
* window.console.log(geolocation.getPosition());

View File

@@ -13,7 +13,8 @@ goog.require('ol.geom.flat.simplify');
/**
* @classdesc
* Linear ring geometry.
* Linear ring geometry. Only used as part of polygon; cannot be rendered
* on its own.
*
* @constructor
* @extends {ol.geom.SimpleGeometry}
@@ -76,7 +77,7 @@ ol.geom.LinearRing.prototype.closestPointXY =
/**
* @return {number} Area.
* @return {number} Area (on projected plane).
* @api
*/
ol.geom.LinearRing.prototype.getArea = function() {

View File

@@ -141,7 +141,7 @@ ol.geom.LineString.prototype.getCoordinates = function() {
/**
* @return {number} Length.
* @return {number} Length (on projected plane).
* @api
*/
ol.geom.LineString.prototype.getLength = function() {

View File

@@ -150,7 +150,7 @@ ol.geom.MultiPolygon.prototype.containsXY = function(x, y) {
/**
* @return {number} Area.
* @return {number} Area (on projected plane).
* @api
*/
ol.geom.MultiPolygon.prototype.getArea = function() {

View File

@@ -140,7 +140,7 @@ ol.geom.Polygon.prototype.containsXY = function(x, y) {
/**
* @return {number} Area.
* @return {number} Area (on projected plane).
* @api
*/
ol.geom.Polygon.prototype.getArea = function() {

View File

@@ -11,8 +11,8 @@ goog.require('ol.geom.flat.transform');
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Abstract base class; only used for creating subclasses; do not instantiate
* in apps, as cannot be rendered.
*
* @constructor
* @extends {ol.geom.Geometry}

View File

@@ -83,13 +83,11 @@ ol.Graticule = function(opt_options) {
this.parallels_ = [];
/**
* TODO can be configurable
* @type {ol.style.Stroke}
* @private
*/
this.strokeStyle_ = new ol.style.Stroke({
color: 'rgba(0,0,0,0.2)'
});
this.strokeStyle_ = goog.isDef(options.strokeStyle) ?
options.strokeStyle : ol.Graticule.DEFAULT_STROKE_STYLE_;
/**
* @type {ol.TransformFunction|undefined}
@@ -113,6 +111,16 @@ ol.Graticule = function(opt_options) {
};
/**
* @type {ol.style.Stroke}
* @private
* @const
*/
ol.Graticule.DEFAULT_STROKE_STYLE_ = new ol.style.Stroke({
color: 'rgba(0,0,0,0.2)'
});
/**
* TODO can be configurable
* @type {Array.<number>}

View File

@@ -95,7 +95,7 @@ ol.interaction.Draw = function(options) {
/**
* Target collection for drawn features.
* @type {ol.Collection}
* @type {ol.Collection.<ol.Feature>}
* @private
*/
this.features_ = goog.isDef(options.features) ? options.features : null;

View File

@@ -35,8 +35,8 @@ goog.require('ol.interaction.PinchZoom');
* should be excluded if you want a build with no vector support.
*
* @param {olx.interaction.DefaultsOptions=} opt_options Defaults options.
* @return {ol.Collection} A collection of interactions to be used with
* the ol.Map constructor's interactions option.
* @return {ol.Collection.<ol.interaction.Interaction>} A collection of
* interactions to be used with the ol.Map constructor's interactions option.
* @api stable
*/
ol.interaction.defaults = function(opt_options) {

View File

@@ -133,7 +133,7 @@ ol.interaction.Modify = function(options) {
};
/**
* @type {ol.Collection}
* @type {ol.Collection.<ol.Feature>}
* @private
*/
this.features_ = options.features;

View File

@@ -106,7 +106,7 @@ goog.inherits(ol.interaction.Select, ol.interaction.Interaction);
/**
* Get the selected features.
* @return {ol.Collection} Features collection.
* @return {ol.Collection.<ol.Feature>} Features collection.
* @api stable
*/
ol.interaction.Select.prototype.getFeatures = function() {

View File

@@ -145,12 +145,12 @@ ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
/**
* @return {ol.Collection|undefined} Collection of {@link ol.layer.Layer layers}
* that are part of this group.
* @return {ol.Collection.<ol.layer.Base>|undefined} Collection of
* {@link ol.layer.Layer layers} that are part of this group.
* @observable
*/
ol.layer.Group.prototype.getLayers = function() {
return /** @type {ol.Collection|undefined} */ (this.get(
return /** @type {ol.Collection.<ol.layer.Base>|undefined} */ (this.get(
ol.layer.GroupProperty.LAYERS));
};
goog.exportProperty(
@@ -160,7 +160,7 @@ goog.exportProperty(
/**
* @param {ol.Collection|undefined} layers Collection of
* @param {ol.Collection.<ol.layer.Base>|undefined} layers Collection of
* {@link ol.layer.Layer layers} that are part of this group.
* @observable
*/

View File

@@ -120,8 +120,8 @@ ol.MapProperty = {
/**
* @classdesc
* The map is the core component of OpenLayers. In its minimal configuration it
* needs a view, one or more layers, and a target container:
* The map is the core component of OpenLayers. For a map to render, a view,
* one or more layers, and a target container are needed:
*
* var map = new ol.Map({
* view: new ol.View({
@@ -263,7 +263,8 @@ ol.Map = function(options) {
goog.events.EventType.TOUCHSTART,
goog.events.EventType.MSPOINTERDOWN,
ol.MapBrowserEvent.EventType.POINTERDOWN,
goog.events.MouseWheelHandler.EventType.MOUSEWHEEL
// see https://github.com/google/closure-library/pull/308
goog.userAgent.GECKO ? 'DOMMouseScroll' : 'mousewheel'
], goog.events.Event.stopPropagation);
goog.dom.appendChild(this.viewport_, this.overlayContainerStopEvent_);
@@ -295,7 +296,7 @@ ol.Map = function(options) {
this.registerDisposable(mouseWheelHandler);
/**
* @type {ol.Collection}
* @type {ol.Collection.<ol.control.Control>}
* @private
*/
this.controls_ = optionsInternal.controls;
@@ -307,13 +308,13 @@ ol.Map = function(options) {
this.deviceOptions_ = optionsInternal.deviceOptions;
/**
* @type {ol.Collection}
* @type {ol.Collection.<ol.interaction.Interaction>}
* @private
*/
this.interactions_ = optionsInternal.interactions;
/**
* @type {ol.Collection}
* @type {ol.Collection.<ol.Overlay>}
* @private
*/
this.overlays_ = optionsInternal.overlays;
@@ -330,6 +331,7 @@ ol.Map = function(options) {
* @private
*/
this.viewportSizeMonitor_ = new goog.dom.ViewportSizeMonitor();
this.registerDisposable(this.viewportSizeMonitor_);
goog.events.listen(this.viewportSizeMonitor_, goog.events.EventType.RESIZE,
this.updateSize, false, this);
@@ -600,9 +602,9 @@ ol.Map.prototype.getEventPixel = function(event) {
// but touchend and touchcancel events have no targetTouches when
// the last finger is removed from the screen.
// So we ourselves compute the position of touch events.
// See https://code.google.com/p/closure-library/issues/detail?id=588
// See https://github.com/google/closure-library/pull/323
if (goog.isDef(event.changedTouches)) {
var touch = event.changedTouches.item(0);
var touch = event.changedTouches[0];
var viewportPosition = goog.style.getClientPosition(this.viewport_);
return [
touch.clientX - viewportPosition.x,
@@ -651,7 +653,7 @@ ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
/**
* @return {ol.Collection} Controls.
* @return {ol.Collection.<ol.control.Control>} Controls.
* @api stable
*/
ol.Map.prototype.getControls = function() {
@@ -660,7 +662,7 @@ ol.Map.prototype.getControls = function() {
/**
* @return {ol.Collection} Overlays.
* @return {ol.Collection.<ol.Overlay>} Overlays.
* @api stable
*/
ol.Map.prototype.getOverlays = function() {
@@ -674,7 +676,7 @@ ol.Map.prototype.getOverlays = function() {
* associated with the map.
*
* Interactions are used for e.g. pan, zoom and rotate.
* @return {ol.Collection} {@link ol.interaction.Interaction Interactions}.
* @return {ol.Collection.<ol.interaction.Interaction>} Interactions.
* @api stable
*/
ol.Map.prototype.getInteractions = function() {
@@ -699,7 +701,7 @@ goog.exportProperty(
/**
* Get the collection of layers associated with this map.
* @return {ol.Collection|undefined} Layers.
* @return {ol.Collection.<ol.layer.Base>|undefined} Layers.
* @api stable
*/
ol.Map.prototype.getLayers = function() {
@@ -854,8 +856,8 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
this.focus_ = mapBrowserEvent.coordinate;
mapBrowserEvent.frameState = this.frameState_;
var interactions = this.getInteractions();
var interactionsArray = /** @type {Array.<ol.interaction.Interaction>} */
(interactions.getArray());
goog.asserts.assert(goog.isDef(interactions));
var interactionsArray = interactions.getArray();
var i;
if (this.dispatchEvent(mapBrowserEvent) !== false) {
for (i = interactionsArray.length - 1; i >= 0; i--) {
@@ -1144,7 +1146,7 @@ ol.Map.prototype.removeInteraction = function(interaction) {
ol.Map.prototype.removeLayer = function(layer) {
var layers = this.getLayerGroup().getLayers();
goog.asserts.assert(goog.isDef(layers));
return /** @type {ol.layer.Base|undefined} */ (layers.remove(layer));
return layers.remove(layer);
};
@@ -1214,7 +1216,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
pixelToCoordinateMatrix: this.pixelToCoordinateMatrix_,
postRenderFunctions: [],
size: size,
skippedFeatureUids_: this.skippedFeatureUids_,
skippedFeatureUids: this.skippedFeatureUids_,
tileQueue: this.tileQueue_,
time: time,
usedTiles: {},
@@ -1375,12 +1377,12 @@ ol.Map.prototype.unskipFeature = function(feature) {
/**
* @typedef {{controls: ol.Collection,
* @typedef {{controls: ol.Collection.<ol.control.Control>,
* deviceOptions: olx.DeviceOptions,
* interactions: ol.Collection,
* interactions: ol.Collection.<ol.interaction.Interaction>,
* keyboardEventTarget: (Element|Document),
* logos: Object,
* overlays: ol.Collection,
* overlays: ol.Collection.<ol.Overlay>,
* rendererConstructor:
* function(new: ol.renderer.Map, Element, ol.Map),
* values: Object.<string, *>}}

View File

@@ -53,7 +53,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtPixel =
var extent = frameState.extent;
var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids_;
var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel(
extent, resolution, rotation, coordinate, skippedFeatureUids,
/**

View File

@@ -45,6 +45,10 @@ ol.renderer.canvas.Layer.prototype.composeFrame =
var image = this.getImage();
if (!goog.isNull(image)) {
var imageTransform = this.getImageTransform();
// for performance reasons, context.save / context.restore is not used
// to save and restore the transformation matrix and the opacity.
// see http://jsperf.com/context-save-restore-versus-variable
var alpha = context.globalAlpha;
context.globalAlpha = layerState.opacity;
// for performance reasons, context.setTransform is only used
@@ -67,6 +71,7 @@ ol.renderer.canvas.Layer.prototype.composeFrame =
context.drawImage(image, 0, 0);
context.setTransform(1, 0, 0, 1, 0, 0);
}
context.globalAlpha = alpha;
}
this.dispatchPostComposeEvent(context, frameState);

View File

@@ -96,7 +96,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame =
replayContext.globalAlpha = layerState.opacity;
replayGroup.replay(
replayContext, frameState.extent, frameState.pixelRatio, transform,
frameState.viewState.rotation, frameState.skippedFeatureUids_);
frameState.viewState.rotation, frameState.skippedFeatureUids);
if (replayContext != context) {
this.dispatchRenderEvent(replayContext, frameState, transform);
@@ -122,7 +122,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
var rotation = frameState.viewState.rotation;
var layer = this.getLayer();
return this.replayGroup_.forEachGeometryAtPixel(extent, resolution,
rotation, coordinate, frameState.skippedFeatureUids_,
rotation, coordinate, frameState.skippedFeatureUids,
/**
* @param {ol.geom.Geometry} geometry Geometry.
* @param {Object} data Data.

View File

@@ -58,7 +58,7 @@ ol.renderer.dom.ImageLayer.prototype.forEachFeatureAtPixel =
var extent = frameState.extent;
var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids_;
var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel(
extent, resolution, rotation, coordinate, skippedFeatureUids,
/**

View File

@@ -84,7 +84,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtPixel =
var extent = frameState.extent;
var resolution = frameState.viewState.resolution;
var rotation = frameState.viewState.rotation;
var skippedFeatureUids = frameState.skippedFeatureUids_;
var skippedFeatureUids = frameState.skippedFeatureUids;
return source.forEachFeatureAtPixel(
extent, resolution, rotation, coordinate, skippedFeatureUids,

View File

@@ -0,0 +1,150 @@
// FIXME keep cluster cache by resolution ?
// FIXME distance not respected because of the centroid
goog.provide('ol.source.Cluster');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.Feature');
goog.require('ol.coordinate');
goog.require('ol.extent');
goog.require('ol.geom.Point');
goog.require('ol.source.Vector');
/**
* @constructor
* @param {olx.source.ClusterOptions} options
* @extends {ol.source.Vector}
* @api
*/
ol.source.Cluster = function(options) {
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
logo: options.logo,
projection: options.projection
});
/**
* @type {number|undefined}
* @private
*/
this.resolution_ = undefined;
/**
* @type {number}
* @private
*/
this.distance_ = goog.isDef(options.distance) ? options.distance : 20;
/**
* @type {Array.<ol.Feature>}
* @private
*/
this.features_ = [];
/**
* @type {ol.source.Vector}
* @private
*/
this.source_ = options.source;
this.source_.on(goog.events.EventType.CHANGE,
ol.source.Cluster.prototype.onSourceChange_, this);
};
goog.inherits(ol.source.Cluster, ol.source.Vector);
/**
* @param {ol.Extent} extent
* @param {number} resolution
*/
ol.source.Cluster.prototype.loadFeatures = function(extent, resolution) {
if (resolution !== this.resolution_) {
this.clear();
this.resolution_ = resolution;
this.cluster_();
this.addFeatures(this.features_);
}
};
/**
* handle the source changing
* @private
*/
ol.source.Cluster.prototype.onSourceChange_ = function() {
this.clear();
this.cluster_();
this.addFeatures(this.features_);
this.dispatchChangeEvent();
};
/**
* @private
*/
ol.source.Cluster.prototype.cluster_ = function() {
goog.array.clear(this.features_);
var extent = ol.extent.createEmpty();
goog.asserts.assert(goog.isDef(this.resolution_));
var mapDistance = this.distance_ * this.resolution_;
var features = this.source_.getFeatures();
/**
* @type {Object.<string, boolean>}
*/
var clustered = {};
for (var i = 0, ii = features.length; i < ii; i++) {
var feature = features[i];
if (!goog.object.containsKey(clustered, goog.getUid(feature).toString())) {
var geometry = feature.getGeometry();
goog.asserts.assert(geometry instanceof ol.geom.Point);
var coordinates = geometry.getCoordinates();
ol.extent.createOrUpdateFromCoordinate(coordinates, extent);
ol.extent.buffer(extent, mapDistance, extent);
var neighbors = this.source_.getFeaturesInExtent(extent);
goog.asserts.assert(neighbors.length >= 1);
neighbors = goog.array.filter(neighbors, function(neighbor) {
var uid = goog.getUid(neighbor).toString();
if (!goog.object.containsKey(clustered, uid)) {
goog.object.set(clustered, uid, true);
return true;
} else {
return false;
}
});
this.features_.push(this.createCluster_(neighbors));
}
}
goog.asserts.assert(
goog.object.getCount(clustered) == this.source_.getFeatures().length);
};
/**
* @param {Array.<ol.Feature>} features Features
* @return {ol.Feature}
* @private
*/
ol.source.Cluster.prototype.createCluster_ = function(features) {
var length = features.length;
var centroid = [0, 0];
for (var i = 0; i < length; i++) {
var geometry = features[i].getGeometry();
goog.asserts.assert(geometry instanceof ol.geom.Point);
var coordinates = geometry.getCoordinates();
ol.coordinate.add(centroid, coordinates);
}
ol.coordinate.scale(centroid, 1 / length);
var cluster = new ol.Feature(new ol.geom.Point(centroid));
cluster.set('features', features);
return cluster;
};

View File

@@ -23,6 +23,7 @@ ol.source.KML = function(opt_options) {
attributions: options.attributions,
doc: options.doc,
format: new ol.format.KML({
extractStyles: options.extractStyles,
defaultStyle: options.defaultStyle
}),
logo: options.logo,

View File

@@ -2,6 +2,7 @@
goog.provide('ol.source.ServerVector');
goog.require('goog.object');
goog.require('ol.extent');
goog.require('ol.loadingstrategy');
goog.require('ol.source.FormatVector');
@@ -79,6 +80,16 @@ ol.source.ServerVector.prototype.addFeaturesInternal = function(features) {
};
/**
* @inheritDoc
*/
ol.source.ServerVector.prototype.clear = function() {
goog.object.clear(this.loadedFeatures_);
this.loadedExtents_.clear();
goog.base(this, 'clear');
};
/**
* @inheritDoc
*/

80
src/ol/style.jsdoc Normal file
View File

@@ -0,0 +1,80 @@
/**
* Feature styles.
*
* If no style is defined, the following default style is used:
* ```js
* var fill = new ol.style.Fill({
* color: 'rgba(255,255,255,0.4)'
* });
* var stroke = new ol.style.Stroke({
* color: '#3399CC',
* width: 1.25
* });
* var styles = [
* new ol.style.Style({
* image: new ol.style.Circle({
* fill: fill,
* stroke: stroke,
* radius: 5
* }),
* fill: fill,
* stroke: stroke
* })
* ];
* ```
*
* A separate editing style has the following defaults:
* ```js
* var white = [255, 255, 255, 1];
* var blue = [0, 153, 255, 1];
* var width = 3;
* styles[ol.geom.GeometryType.POLYGON] = [
* new ol.style.Style({
* fill: new ol.style.Fill({
* color: [255, 255, 255, 0.5]
* })
* })
* ];
* styles[ol.geom.GeometryType.MULTI_POLYGON] =
* styles[ol.geom.GeometryType.POLYGON];
* styles[ol.geom.GeometryType.LINE_STRING] = [
* new ol.style.Style({
* stroke: new ol.style.Stroke({
* color: white,
* width: width + 2
* })
* }),
* new ol.style.Style({
* stroke: new ol.style.Stroke({
* color: blue,
* width: width
* })
* })
* ];
* styles[ol.geom.GeometryType.MULTI_LINE_STRING] =
* styles[ol.geom.GeometryType.LINE_STRING];
* styles[ol.geom.GeometryType.POINT] = [
* new ol.style.Style({
* image: new ol.style.Circle({
* radius: width * 2,
* fill: new ol.style.Fill({
* color: blue
* }),
* stroke: new ol.style.Stroke({
* color: white,
* width: width / 2
* })
* }),
* zIndex: Infinity
* })
* ];
* styles[ol.geom.GeometryType.MULTI_POINT] =
* styles[ol.geom.GeometryType.POINT];
* styles[ol.geom.GeometryType.GEOMETRY_COLLECTION] =
* styles[ol.geom.GeometryType.POLYGON].concat(
* styles[ol.geom.GeometryType.POINT]
* );
*```
*
* @namespace ol.style
*/

View File

@@ -7,6 +7,9 @@ goog.require('ol.color');
/**
* @classdesc
* Set stroke style for vector features.
* Note that the defaults given are the Canvas defaults, which will be used if
* option is not defined. The `get` functions return whatever was entered in
* the options; they will not return the default.
*
* @constructor
* @param {olx.style.StrokeOptions=} opt_options Options.

View File

@@ -48,7 +48,7 @@ ol.TileCache.prototype.expireCache = function(usedTiles) {
if (zKey in usedTiles && usedTiles[zKey].contains(tile.tileCoord)) {
break;
} else {
this.pop();
this.pop().dispose();
}
}
};
@@ -64,7 +64,7 @@ ol.TileCache.prototype.pruneTileRange = function(tileRange) {
while (i--) {
key = this.peekLastKey();
if (tileRange.contains(ol.TileCoord.createFromString(key))) {
this.pop();
this.pop().dispose();
} else {
this.get(key);
}

View File

@@ -31,6 +31,10 @@ ol.TileCoordTransformType;
* @return {ol.TileUrlFunctionType} Tile URL function.
*/
ol.TileUrlFunction.createFromTemplate = function(template) {
var zRegEx = /\{z\}/g;
var xRegEx = /\{x\}/g;
var yRegEx = /\{y\}/g;
var dashYRegEx = /\{-y\}/g;
return (
/**
* @param {ol.TileCoord} tileCoord Tile Coordinate.
@@ -42,10 +46,10 @@ ol.TileUrlFunction.createFromTemplate = function(template) {
if (goog.isNull(tileCoord)) {
return undefined;
} else {
return template.replace('{z}', tileCoord.z.toString())
.replace('{x}', tileCoord.x.toString())
.replace('{y}', tileCoord.y.toString())
.replace('{-y}', function() {
return template.replace(zRegEx, tileCoord.z.toString())
.replace(xRegEx, tileCoord.x.toString())
.replace(yRegEx, tileCoord.y.toString())
.replace(dashYRegEx, function() {
var y = (1 << tileCoord.z) - tileCoord.y - 1;
return y.toString();
});

View File

@@ -24,7 +24,6 @@ goog.require('ol.proj.Units');
*/
ol.ViewProperty = {
CENTER: 'center',
PROJECTION: 'projection',
RESOLUTION: 'resolution',
ROTATION: 'rotation'
};
@@ -107,8 +106,12 @@ ol.View = function(opt_options) {
var properties = {};
properties[ol.ViewProperty.CENTER] = goog.isDef(options.center) ?
options.center : null;
properties[ol.ViewProperty.PROJECTION] = ol.proj.createProjection(
options.projection, 'EPSG:3857');
/**
* @private
* @type {ol.proj.Projection}
*/
this.projection_ = ol.proj.createProjection(options.projection, 'EPSG:3857');
var resolutionConstraintInfo = ol.View.createResolutionConstraint_(
options);
@@ -275,18 +278,12 @@ ol.View.prototype.calculateExtent = function(size) {
/**
* @return {ol.proj.Projection|undefined} The projection of the view.
* @observable
* @return {ol.proj.Projection} The projection of the view.
* @api
*/
ol.View.prototype.getProjection = function() {
return /** @type {ol.proj.Projection|undefined} */ (
this.get(ol.ViewProperty.PROJECTION));
return this.projection_;
};
goog.exportProperty(
ol.View.prototype,
'getProjection',
ol.View.prototype.getProjection);
/**
@@ -601,22 +598,6 @@ ol.View.prototype.setHint = function(hint, delta) {
};
/**
* Set the projection of this view.
* Warning! This code is not yet implemented. Function should not be used.
* @param {ol.proj.Projection|undefined} projection The projection of the view.
* @observable
* @api
*/
ol.View.prototype.setProjection = function(projection) {
this.set(ol.ViewProperty.PROJECTION, projection);
};
goog.exportProperty(
ol.View.prototype,
'setProjection',
ol.View.prototype.setProjection);
/**
* Set the resolution for this view.
* @param {number|undefined} resolution The resolution of the view.

View File

@@ -9,6 +9,7 @@ var fse = require('fs-extra');
var fs = require('graceful-fs');
var nomnom = require('nomnom');
var temp = require('temp').track();
var exec = require('child_process').exec;
var generateExports = require('./generate-exports');
@@ -186,6 +187,23 @@ function build(config, paths, callback) {
}
/**
* Adds a file header with the most recent Git tag.
* @param {string} compiledSource The compiled library.
* @param {function(Error, string)} callback Called with the output
* ready to be written into a file, or any error.
*/
function addHeader(compiledSource, callback) {
exec('git describe --tags', function(error, stdout, stderr) {
var header = '// OpenLayers 3. See http://ol3.js.org/\n';
if (stdout !== '') {
header += '// Version: ' + stdout + '\n';
}
callback(null, header + compiledSource);
});
}
/**
* Generate a build of the library.
* @param {Object} config Build configuration object. Must have an "exports"
@@ -198,7 +216,8 @@ function main(config, callback) {
assertValidConfig.bind(null, config),
generateExports.bind(null, config),
getDependencies.bind(null, config),
build.bind(null, config)
build.bind(null, config),
addHeader
], callback);
}

View File

@@ -394,6 +394,73 @@ describe('ol.format.GPX', function() {
});
describe('extensions support', function() {
beforeEach(function() {
format = new ol.format.GPX({
readExtensions: function(feature, extensionsNode) {
var nodes = extensionsNode.getElementsByTagName('id');
var id = nodes.item(0).textContent;
feature.setId(id);
}
});
});
it('can process extensions from wpt', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <wpt>' +
' <extensions>' +
' <id>feature-id</id>' +
' </extensions>' +
' </wpt>' +
'</gpx>';
var fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var feature = fs[0];
expect(feature.getId()).to.be('feature-id');
});
it('can process extensions from rte', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <rte>' +
' <extensions>' +
' <foo>bar</foo>' +
' <id>feature-id</id>' +
' </extensions>' +
' </rte>' +
'</gpx>';
var fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var feature = fs[0];
expect(feature.getId()).to.be('feature-id');
});
it('can process extensions from trk, not trkpt', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <trk>' +
' <extensions>' +
' <id>feature-id</id>' +
' </extensions>' +
' <trkseg>' +
' <trkpt>' +
' <extensions>' +
' <id>another-feature-id</id>' +
' </extensions>' +
' </trkpt>' +
' </trkseg>' +
' </trk>' +
'</gpx>';
var fs = format.readFeatures(text);
expect(fs).to.have.length(1);
var feature = fs[0];
expect(feature.getId()).to.be('feature-id');
});
});
});
});

View File

@@ -21,6 +21,28 @@ describe('ol.Graticule', function() {
expect(graticule.getMeridians().length).to.be(13);
expect(graticule.getParallels().length).to.be(3);
});
it('has a default stroke style', function() {
var actualStyle = graticule.strokeStyle_;
expect(actualStyle).not.to.be(undefined);
expect(actualStyle instanceof ol.style.Stroke).to.be(true);
});
it('can be configured with a stroke style', function() {
var customStrokeStyle = new ol.style.Stroke({
color: 'rebeccapurple'
});
var styledGraticule = new ol.Graticule({
map: new ol.Map({}),
strokeStyle: customStrokeStyle
});
var actualStyle = styledGraticule.strokeStyle_;
expect(actualStyle).not.to.be(undefined);
expect(actualStyle).to.be(customStrokeStyle);
});
});
});
@@ -28,3 +50,4 @@ describe('ol.Graticule', function() {
goog.require('ol.Graticule');
goog.require('ol.Map');
goog.require('ol.proj');
goog.require('ol.style.Stroke');

View File

@@ -2,7 +2,7 @@ goog.provide('ol.test.Map');
describe('ol.Map', function() {
describe('contstructor', function() {
describe('constructor', function() {
it('creates a new map', function() {
var map = new ol.Map({});
expect(map).to.be.a(ol.Map);

View File

@@ -0,0 +1,21 @@
goog.provide('ol.test.source.ClusterSource');
goog.require('ol.source.Vector');
describe('ol.source.Cluster', function() {
describe('constructor', function() {
it('returns a cluster source', function() {
var source = new ol.source.Cluster({
projection: ol.proj.get('EPSG:4326'),
source: new ol.source.Vector()
});
expect(source).to.be.a(ol.source.Source);
expect(source).to.be.a(ol.source.Cluster);
});
});
});
goog.require('ol.proj');
goog.require('ol.source.Cluster');
goog.require('ol.source.Source');

View File

@@ -37,6 +37,10 @@ describe('ol.TileUrlFunction', function() {
var tileUrl = ol.TileUrlFunction.createFromTemplate('{z}/{x}/{-y}');
expect(tileUrl(new ol.TileCoord(3, 2, 2))).to.eql('3/2/5');
});
it('replaces multiple placeholder occurrences', function() {
var tileUrl = ol.TileUrlFunction.createFromTemplate('{z}/{z}{x}{y}');
expect(tileUrl(new ol.TileCoord(3, 2, 1))).to.eql('3/321');
});
});
describe('createFromTemplates', function() {