Compare commits

...

208 Commits

Author SHA1 Message Date
Éric Lemoine
e97f017dda Merge pull request #3213 from openlayers/release-v3.2.0
Release v3.2.0
2015-02-06 11:14:26 +01:00
Éric Lemoine
22b27cdb02 Update package version to 3.2.0 2015-02-06 11:12:59 +01:00
Éric Lemoine
480c276d93 Changelog for v3.2.0 2015-02-06 11:12:59 +01:00
Éric Lemoine
480f352cc6 Merge pull request #3171 from oterral/kml_link
KML: Parsing of NetworkLink tag
2015-02-05 16:41:36 +01:00
oterral
c1fd95305c Add tests for parsing of NetworkLink tags 2015-02-05 16:21:51 +01:00
oterral
0a6a3f5d65 Add parsing of NetworkLink tag 2015-02-05 16:21:45 +01:00
Frédéric Junod
456def67de Merge pull request #3209 from fredj/coding-style
Coding style fixes
2015-02-05 14:53:59 +01:00
Bart van den Eijnden
f9a8239443 Merge pull request #3208 from bartvde/setImageLoadFunction
Add setters and getters for imageLoadFunction
2015-02-05 12:37:02 +01:00
Frederic Junod
a0a4369c24 Fix ol.format.GPX.TRKSEG_NODE_FACTORY_ type definition 2015-02-05 10:56:44 +01:00
Frederic Junod
078d3fb007 Add missing goog.require 2015-02-05 10:56:44 +01:00
Frederic Junod
65c2f7de5f Remove unused goog.require 2015-02-05 10:56:44 +01:00
Frederic Junod
8ec90a2045 Remove unnecessary newlines 2015-02-05 10:56:44 +01:00
Frédéric Junod
0906bf09ed Merge pull request #3019 from bjornharrtell/selectmulti
Add option to allow Select interaction logic to select overlapping features
2015-02-05 10:55:04 +01:00
Bart van den Eijnden
ce8d57b534 Add setters and getters for imageLoadFunction 2015-02-05 10:53:21 +01:00
Pierre GIRAUD
b8a0d6b702 Merge pull request #3206 from pgiraud/measure_tooltip
Add tooltip to show measure + help message while drawing
2015-02-05 09:48:32 +01:00
Pierre GIRAUD
4ba500925f Changing draw interaction styling 2015-02-05 09:39:17 +01:00
Pierre GIRAUD
c63c358d08 Add tooltip to show measure + help message while drawing 2015-02-04 17:48:28 +01:00
Björn Harrtell
162c47eb3e Option to enable selection of overlapping features 2015-02-04 16:15:41 +01:00
Frédéric Junod
f117cddb34 Merge pull request #3205 from fredj/use-ol.extent.createOrUpdateFromCoordinate
Use ol.extent.createOrUpdateFromCoordinate
2015-02-04 14:55:49 +01:00
Frederic Junod
f6b47f086b Use ol.extent.createOrUpdateFromCoordinate
Instead of ol.extent.boundingExtent
2015-02-04 14:14:50 +01:00
Éric Lemoine
2d3e5d2bac Merge pull request #3026 from htulipe/wmts-getcap
Add support of reading WMTS Get Cap document
2015-02-04 13:32:32 +01:00
Bart van den Eijnden
8f6cb00ea6 Merge pull request #3201 from bartvde/fast_clear
Pass on opt_fast to parent clear function in ol.source.ServerVector (r=@elemoine,@gberaudo)
2015-02-04 08:53:51 +01:00
Bart van den Eijnden
80f7b726f9 Pass on opt_fast to parent clear function in ol.source.ServerVector 2015-02-04 08:45:09 +01:00
Frédéric Junod
f75cec5c8e Merge pull request #3199 from fredj/jsdoc-fixes
Minor jsdoc fixes
2015-02-03 16:14:39 +01:00
Frederic Junod
89f21f5d50 Remove square brackets from type 2015-02-03 15:52:19 +01:00
Frederic Junod
f9723aa310 Add missing goog.require 2015-02-03 15:52:19 +01:00
Hadrien Tulipe
87644a1a46 Add support of WMTS Get Cap read
This commit fixe #2721. It still lacks the possibility to create layer from the GetCap document. It also lacks the reading of TMS limits.
2015-02-03 14:46:29 +01:00
Frédéric Junod
38c80e7f9b Merge pull request #3059 from fredj/memory
Cache the buffered extent value
2015-02-03 13:39:39 +01:00
Frederic Junod
0d3eb8642f Cache the buffered extent value
Assuming that the maxExtent and resolution property are immutable
2015-02-03 10:37:38 +01:00
Frédéric Junod
a7fcf05a4b Merge pull request #3196 from fredj/coding-style
Remove unnecessary newlines
2015-02-02 16:47:53 +01:00
Frederic Junod
31f61121d9 Remove unnecessary newlines 2015-02-02 14:38:39 +01:00
Bart van den Eijnden
b8d44e7f91 Merge pull request #3099 from bartvde/ogr-gml2
Fix up parsing of OGR GML with ol.format.GML
2015-02-02 13:16:12 +01:00
Bart van den Eijnden
423c8761aa Use ol.format.GMLBase.GMLNS and get rid of unneeded Object 2015-02-02 12:46:49 +01:00
Frédéric Junod
ef871f54f8 Merge pull request #3195 from fredj/coding-style
Coding style
2015-02-02 09:59:00 +01:00
Éric Lemoine
898c8fa9a2 Merge pull request #3192 from elemoine/mapquest-url
Add "url" option to ol.source.MapQuest
2015-02-02 09:26:08 +01:00
Tobias Sauerwein
350ce735f1 Merge pull request #3172 from tsauerwein/forEachLayerAtPixel
Introduce forEachLayerAtPixel
2015-02-02 09:24:43 +01:00
Frederic Junod
0f65d7778a Remove unnecessary newlines 2015-02-02 09:11:35 +01:00
Frederic Junod
12925a35b9 Use goog.isDef to check the opt_array param 2015-02-02 09:11:35 +01:00
Frédéric Junod
df32d04fdb Merge pull request #3178 from fredj/geojson-externs
GeoJSON externs fixes
2015-02-02 09:11:08 +01:00
Frédéric Junod
987b032d9d Merge pull request #3179 from fredj/disallow-undefined
Disallow undefined values for ol.layer.Base
2015-02-02 09:10:36 +01:00
Bart van den Eijnden
5d70e61753 Make FEATURE_COLLECTION_PARSERS an instance property 2015-01-30 21:00:04 +01:00
Éric Lemoine
130535c83e Merge pull request #3161 from 3x0dv5/master
Doc fix. writeFeaturesNode receives an array of Feature
2015-01-30 17:46:23 +01:00
Éric Lemoine
fcbdc6bd26 Merge pull request #3169 from oterral/kml_example
Fix default icon style in kml format
2015-01-30 17:45:31 +01:00
Éric Lemoine
df2d71ef83 Add "url" option to ol.source.MapQuest 2015-01-30 17:08:50 +01:00
tsauerwein
b390c1bdf8 Use dragging flag in examples 2015-01-30 13:53:32 +01:00
tsauerwein
f4500c8f89 Rename *AtPixel to *AtCoordinate if coordinate 2015-01-30 10:00:37 +01:00
tsauerwein
4d4bed454a Avoid pixel->coord->pixel conversion 2015-01-30 10:00:37 +01:00
tsauerwein
054227fd26 Make signature for *AtPixel methods more consistent
pixel/coordinate is the first argument.
2015-01-30 10:00:36 +01:00
tsauerwein
b7415219a6 Use forEachLayerAtPx in example 2015-01-30 10:00:36 +01:00
tsauerwein
dce4210a5b Implement forEachLayerAtPixel for webgl 2015-01-30 10:00:36 +01:00
tsauerwein
6cc5bd466d Add hasFeatureAtPixel for ImageLayer 2015-01-30 10:00:36 +01:00
tsauerwein
b4cb786f29 Implement forEachLayerAtPixel for canvas 2015-01-30 10:00:36 +01:00
tsauerwein
225f0739ec Add forEachLayerAtPixel 2015-01-30 10:00:36 +01:00
tsauerwein
7feb8b22f6 Rename forEachGeometryAtPixel 2015-01-30 10:00:36 +01:00
Tobias Sauerwein
9e7e5efd27 Merge pull request #3190 from tsauerwein/event-dragging
Introduce `dragging` flag for MapBrowserEvent
2015-01-30 09:54:52 +01:00
tsauerwein
9a841583db Remove getter for down_ 2015-01-30 09:38:47 +01:00
tsauerwein
9cc8390dfd Use dragging in examples 2015-01-30 09:16:19 +01:00
tsauerwein
f2518e4c08 Add dragging flag to MapBrowserEvent 2015-01-30 09:15:35 +01:00
Tobias Sauerwein
aa67078d74 Merge pull request #3135 from tsauerwein/control-label
Make changing the label of ZoomToExtent/FullScreen control consistent
2015-01-29 15:03:53 +01:00
Bart van den Eijnden
0243ce6612 Fix up parsing of OGR GML with ol.format.GML 2015-01-29 11:40:30 +01:00
Frédéric Junod
3abcbcf377 Merge pull request #3186 from fredj/clip-pixel-ratio
Take the pixel ratio into account when clipping the layer
2015-01-28 21:29:48 +01:00
Éric Lemoine
5c9e099628 Merge pull request #3183 from htulipe/switch-mode-fix
Allow other params than 'mode' in example page query string.
2015-01-28 16:03:25 +01:00
Frederic Junod
cb69cecf03 Take the pixel ratio into account when clipping the layer 2015-01-28 14:21:50 +01:00
Frédéric Junod
2ad93b9e86 Merge pull request #2791 from fredj/rotate-css-transition
Re enable rotation button transition
2015-01-28 09:18:50 +01:00
Frederic Junod
aa23a7bce5 Re enable rotation button transition
The opacity transition was broken with #2782
2015-01-28 09:09:01 +01:00
htulipe
f0608f6fed Allow other params than 'mode' in example query string.
Currently, if other params are present at the beginning of the query string,
the mode switcher will not work.

This situation can occur when a search criteria was entered in the examples
index page. That criteria will be passed along to the example page via a query
param.
2015-01-27 21:52:38 +01:00
Bart van den Eijnden
798399101f Merge pull request #3180 from bartvde/featureoverlay-getmap
Add a getMap function to ol.FeatureOverlay (r=@ahocevar)
2015-01-27 20:07:25 +01:00
Bart van den Eijnden
bc5f81cfa0 Add a getMap function to ol.FeatureOverlay 2015-01-27 19:54:34 +01:00
Frederic Junod
fc3c808209 Disallowed undefined 'minResolution' value 2015-01-27 18:07:42 +01:00
Frederic Junod
1d6f7e9504 Disallowed undefined 'maxResolution' value 2015-01-27 18:07:42 +01:00
Frederic Junod
60ea87fdfb Disallowed undefined 'saturation' value 2015-01-27 18:07:42 +01:00
Frederic Junod
caa8428990 Disallowed undefined 'contrast' value 2015-01-27 18:07:42 +01:00
Frederic Junod
007ad2c58f Disallowed undefined 'brightness' value 2015-01-27 18:07:42 +01:00
Frederic Junod
663f18cd29 Disallowed undefined 'opacity' value 2015-01-27 18:07:42 +01:00
Frederic Junod
e25cb30e5f Disallowed undefined 'hue' value 2015-01-27 18:07:42 +01:00
Frederic Junod
c7dbd4a303 Disallowed undefined 'visible' value 2015-01-27 18:07:42 +01:00
Frédéric Junod
43f84e798f Merge pull request #3176 from fredj/undefined-rotation
Disallowed undefined rotation value
2015-01-27 17:11:26 +01:00
Frederic Junod
d640accdc8 More precise ol.format.GeoJSON.readGeometry_ param type 2015-01-27 12:21:11 +01:00
Frederic Junod
f1c0072bd0 More precise olx.source.GeoJSONOptions#object type 2015-01-27 12:06:03 +01:00
Frederic Junod
d219a8ef22 Remove GeoJSONObject extends from GeoJSONLink
Otherwise CRS object may have a `boox` or a `crs` property
2015-01-27 11:30:24 +01:00
Frederic Junod
3fbe9265da Remove GeoJSONObject extends from GeoJSONCRS
Otherwise CRS object may have a `boox` or a `crs` property
2015-01-27 11:26:06 +01:00
Frederic Junod
ad65989d28 Move bbox property to GeoJSONObject
See http://geojson.org/geojson-spec.html#geojson-objects:
"A GeoJSON object may have a "bbox" member [...]"
2015-01-27 11:18:13 +01:00
Tobias Sauerwein
9d5f7c1eb4 Merge pull request #3177 from tsauerwein/style-polygons
Add example showing how to style polygon vertices
2015-01-27 10:18:55 +01:00
tsauerwein
48cf51a7ca Add example for polygon vertices styling 2015-01-27 10:02:28 +01:00
Frederic Junod
829a0ca224 Disallowed undefined rotation value 2015-01-27 09:26:51 +01:00
Frédéric Junod
5c9b17a3b2 Merge pull request #3174 from fredj/view-getState
Use view.getRotation or view.getResolution instead of view.getState
2015-01-26 17:14:38 +01:00
Frederic Junod
915df000ab Use view.getRotation instead of view.getState 2015-01-26 13:39:49 +01:00
Frederic Junod
247d8668d1 Use view.getResolution instead of view.getState 2015-01-26 13:39:49 +01:00
Frederic Junod
7c7a4c2b7a Use view.getRotation instead of view.getState 2015-01-26 13:39:49 +01:00
Frédéric Junod
8e161a077f Merge pull request #3170 from fredj/coding-style
Coding style
2015-01-26 13:39:02 +01:00
Frederic Junod
7885ad6ae7 Remove unnecessary newlines 2015-01-26 10:33:00 +01:00
Frederic Junod
98f7b5f186 Mark projection property as constant 2015-01-26 10:20:21 +01:00
Frederic Junod
72b2182219 Add missing projection property in olx.ViewState 2015-01-26 09:51:53 +01:00
Frederic Junod
eb7041c71d Simplify ternary operator condition 2015-01-26 09:51:53 +01:00
oterral
65fe82d188 Fix default icon style in kml format 2015-01-26 09:46:48 +01:00
Tobias Sauerwein
90a5997c22 Merge pull request #3108 from tsauerwein/webgl-point-skipFeatures
Support skipping features in the WebGL renderer
2015-01-23 08:56:39 +01:00
Frédéric Junod
fd5a3ce7b4 Merge pull request #3163 from fredj/webglmaprenderer-layerStatesArray
Use the layerStatesArray property from the frameState
2015-01-23 07:27:38 +01:00
Frederic Junod
948a1f1321 Use the layerStatesArray property from the frameState 2015-01-22 17:36:26 +01:00
Frédéric Junod
edc6746545 Merge pull request #3159 from fredj/heatmap-constr
Don't pass specific options to the parent constructor
2015-01-22 14:55:55 +01:00
3x0dv5
6ceef2b0cc Doc fix. writeFeaturesNode receives an array of Feature 2015-01-22 11:21:02 +00:00
Frederic Junod
f3bafab1e6 Don't pass specific options to the parent constructor 2015-01-22 11:30:20 +01:00
tsauerwein
316480dcda Rename argument 2015-01-22 10:24:59 +01:00
tsauerwein
a39544cce0 Implement skipping features for hasFeatureAtPixel 2015-01-22 10:24:59 +01:00
tsauerwein
cf9619f378 Implement skipping features for 1by1 hit detection 2015-01-22 10:24:59 +01:00
tsauerwein
c4ee074274 Implement skipping features for drawReplay 2015-01-22 10:24:59 +01:00
Tobias Sauerwein
1702a4ed36 Merge pull request #3066 from tsauerwein/webgl-point-hasFeatureAtPixel
Introduce hasFeatureAtPixel
2015-01-22 10:20:00 +01:00
Tobias Sauerwein
53f98dcf4e Merge pull request #3065 from tsauerwein/webgl-point-hit-detection
Add hit-detection support for WebGL
2015-01-22 10:19:37 +01:00
Éric Lemoine
f625a29978 Merge pull request #3128 from oterral/kml_default_style
Allow rendering of feature when download of icon failed
2015-01-21 15:08:02 +01:00
Éric Lemoine
21144f161a Add more tests fr ol.renderer.vector 2015-01-21 14:50:48 +01:00
Frédéric Junod
b6a550f354 Merge pull request #3156 from fredj/format-getprojection
Move readProjectionFrom* functions to the base classes
2015-01-21 13:30:47 +01:00
Éric Lemoine
b27c1c82d4 Merge pull request #3107 from elemoine/imagestate
Also listen on loading images
2015-01-21 12:50:31 +01:00
Frederic Junod
077a827197 Move readProjectionFrom* functions to the base classes 2015-01-21 09:15:04 +01:00
Frédéric Junod
2970da3461 Merge pull request #3153 from fredj/geojson-externs
Add missing GeoJSONFeature#bbox property
2015-01-21 07:34:10 +01:00
Frédéric Junod
165e3fe1ff Merge pull request #3154 from fredj/coding-style
Remove unnecessary newlines
2015-01-20 17:43:51 +01:00
Frederic Junod
b53a5e28d5 Remove unnecessary newlines 2015-01-20 16:48:52 +01:00
Frederic Junod
d8984ca1aa Add missing GeoJSONFeature#bbox property
See http://geojson.org/geojson-spec.html#bounding-boxes
2015-01-20 15:17:29 +01:00
Éric Lemoine
c185bf8f30 Merge pull request #3146 from icholy/enable-reversflatgeom-tests
Enable tests for ol.geom.flat.reverse
2015-01-19 21:01:13 +01:00
Frédéric Junod
8bc72c62f6 Merge pull request #3152 from fredj/update
Update closure-library and closure-util version
2015-01-19 17:36:27 +01:00
Frederic Junod
a17bc916b1 Update closure-library version 2015-01-19 10:42:34 +01:00
Frederic Junod
c732538433 Update closure-util version 2015-01-19 10:42:33 +01:00
Ilia Choly
ee9cfef35a Enable reverseflatgeom tests 2015-01-16 13:40:47 -05:00
Éric Lemoine
970beb1741 Merge pull request #3145 from elemoine/wrapx
Add wrapX option to source.OSM and source.BingMaps
2015-01-16 17:40:13 +01:00
Éric Lemoine
11eeb6617c Add wrapX option to olx.source.BingMapsOptions 2015-01-16 17:15:59 +01:00
Éric Lemoine
d13a5dfb9f Add wrapX option to olx.source.OSMOptions 2015-01-16 17:12:00 +01:00
Éric Lemoine
4b3726fe71 Merge pull request #3139 from elemoine/control-setmap
Add ol.control.Control#setTarget
2015-01-16 11:16:30 +01:00
Bart van den Eijnden
12f3a9d454 Merge pull request #3144 from bartvde/code-guidelines
Update CONTRIBUTING style guide with recent guidelines
2015-01-16 10:57:35 +01:00
Bart van den Eijnden
4f4d12024b Update CONTRIBUTING style guide with recent guidelines 2015-01-16 10:49:44 +01:00
tsauerwein
fbb2883f6e Add Node to control label type 2015-01-16 10:14:39 +01:00
Éric Lemoine
79312c2083 Add ol.control.Control#setTarget
This commit adds a setTarget method to ol.control.Control. This function can be used in cases where the target cannot be set at control construction time. For example, with Angular, it makes sense to create the control instance in an Angular controller, and have a "control" directive insert the control into the DOM.
2015-01-16 09:27:30 +01:00
tsauerwein
7679069520 Add label option to FullScreen control 2015-01-16 09:05:51 +01:00
Frédéric Junod
1033171ff0 Merge pull request #3136 from fredj/coding-style
Use array.length = 0 instead of goog.array.clear
2015-01-16 08:08:27 +01:00
Tim Schaub
10c715ad9a Merge pull request #3140 from tschaub/array
Avoid use of goog.array.clone with arrays.
2015-01-15 13:00:02 -07:00
Tim Schaub
06dc0902c6 Avoid use of goog.array.clone with arrays 2015-01-15 12:43:12 -07:00
Frederic Junod
845957a27f Use array.length = 0 instead of goog.array.clear 2015-01-15 16:11:29 +01:00
Frédéric Junod
c23ae78978 Merge pull request #3122 from fredj/revert-2975
Revert "Use offsetX and offsetY if available"
2015-01-15 10:52:03 +01:00
tsauerwein
0d26a9aa87 Add label option to ZoomToExtent 2015-01-15 09:58:05 +01:00
Frederic Junod
0bae04331d Revert "Use offsetX and offsetY if available"
This reverts commit fabf05977a.
2015-01-15 08:56:55 +01:00
Andreas Hocevar
c726cbfcd9 Merge pull request #2385 from ahocevar/update-vectors-while-animating
Option to update vector layers while animating
2015-01-14 17:34:39 +01:00
Andreas Hocevar
b1a73da9dd Add updateWhileAnimating option
With this option, vector batches will be recreated with every frame.
For animations, this means that vector data won't be clipped to the
extent at which the animation started.
2015-01-14 16:33:05 +01:00
Frédéric Junod
dafcdfa494 Merge pull request #3129 from fredj/rbush-update
Only update the rbush item if the extent has changed
2015-01-14 13:53:41 +01:00
Frederic Junod
baf424f99c Only update the rbush item if the extent has changed 2015-01-14 13:29:28 +01:00
Andreas Hocevar
017ff47bf8 Merge pull request #3117 from ahocevar/domvector-pixelratio
Add pixelRatio support for DOM vector renderer
2015-01-14 12:55:05 +01:00
Tobias Sauerwein
110ed04a84 Merge pull request #3124 from sirtet/master
Add a space between scale -value and -unit
2015-01-14 12:41:01 +01:00
Frédéric Junod
2f5bbb37ed Merge pull request #3130 from fredj/doc
Document default value
2015-01-14 12:39:15 +01:00
Frédéric Junod
68f5ff0045 Merge pull request #3105 from fredj/geom-getextent
ol.geom.Geometry#getExtent re-factoring
2015-01-14 12:20:37 +01:00
Frederic Junod
5f55e01849 Document default value 2015-01-14 12:12:38 +01:00
Frederic Junod
f7943b9401 Set extent and extentRevision variables to private 2015-01-14 11:01:18 +01:00
Frederic Junod
8bd0a1232a Add geom.ol.geom.Geometry#computeExtent function 2015-01-14 11:01:18 +01:00
oterral
c97a29d13b Allow rendering of feature when download of icon failed 2015-01-14 09:34:03 +01:00
sirtet
66fea4dec9 Add a space between scale -value and -unit
For improved readability. Issue #3116
2015-01-13 16:16:20 +01:00
Bart van den Eijnden
35468e2bbb Merge pull request #3118 from naturalatlas/wfs-firstelementchild-bugfix
Bugfix: "Cannot read property 'firstElementChild' of null" (WFS)
2015-01-13 10:13:56 +01:00
Brian Reavis
37dac8e0cf Fixed "Cannot read property 'firstElementChild' of null" on WFS readProjectionFromNode.
Occurs when a FeatureCollection is empty.

Code style changes @bartvde

Added test case for #3118.

Attempt to make jshint happy.

Fixed tab character.

Another code style change (jshint)....
2015-01-13 01:42:03 -07:00
Andreas Hocevar
bbf074b70a Add pixelRatio support for DOM vector renderer
Adds the scaling and transforms to support pixelRatio values other than
1.
2015-01-12 22:14:52 +01:00
Éric Lemoine
5dca3e9b20 Merge pull request #3114 from elemoine/contributing
Specify node version in CONTRIBUTING.md
2015-01-12 21:13:16 +01:00
Éric Lemoine
789ddad536 Specify node version 2015-01-12 20:49:23 +01:00
Frédéric Junod
409969fa2a Merge pull request #3106 from fredj/tilelayer-constr
Don't pass specific options to the parent constructor
2015-01-12 15:31:36 +01:00
Éric Lemoine
76418bdbe5 Merge pull request #3110 from PeterDaveHello/patch-1
Use svg instead of png to get better image quality
2015-01-11 11:22:56 +01:00
Peter Dave Hello
3e2574bf49 Use svg instead of png to get better image quality 2015-01-11 14:33:36 +08:00
Éric Lemoine
12863cf3fd Merge pull request #2707 from gberaudo/source_map
Generate source map of minified ol.js
2015-01-09 13:16:18 +01:00
Éric Lemoine
2ef8302122 Add a build/ol.js.map target 2015-01-09 12:33:38 +01:00
Guillaume Beraudo
132686b4a7 Generate source map of minified ol.js
Allows automatic unminification by the browser.

A postprocessing is required to:
- fix the paths to the sources;
- add the link from the minified script to its map.

If someone knows how to do the first item in Python or nodejs, please provide a
patch. A simple shell script is:
```
\#!/bin/sh
pwd=`pwd`
sed -i "s!$pwd/build!olsource!g" 'build/ol.js.map'
sed -i "s!$pwd!olsource!g" 'build/ol.js.map'
```

The second item should always be manually handled to avoid 404 errors
in debuggers
`echo '//# sourceMappingURL=ol.js.map' >> build/ol.js`

Finally, create an alias / copy ol3 directory to /olsource in your
deployed environment.
2015-01-09 12:17:35 +01:00
Éric Lemoine
0f486e86f7 Add tests for ol.renderer.Layer#loadImage 2015-01-09 09:45:25 +01:00
tsauerwein
c85982bbe5 Remove unused variables 2015-01-09 09:21:40 +01:00
Éric Lemoine
4814983306 Also listen on loading images
This fixes a bug that occured when an image source was used by multiple maps. In that case the map that didn't load the image wouldn't register a load listener on that image and would therefore not call render to request a re-render of the map.
2015-01-09 09:07:31 +01:00
tsauerwein
d39904b66b Add @const annotation 2015-01-08 16:12:52 +01:00
tsauerwein
25612f1af2 Unify return statement
Only return the callback result if it is truthy,
otherwise return undefined.
2015-01-08 16:12:52 +01:00
tsauerwein
35c58b3b0e Use hasFeatureAtPixel in icon example 2015-01-08 16:12:52 +01:00
tsauerwein
3e5c4d0bf6 Show hasFeatureAtPixel in example 2015-01-08 16:12:52 +01:00
tsauerwein
bc71a36292 Implement hasFeatureAtPixel for webgl 2015-01-08 16:12:52 +01:00
tsauerwein
d62e910239 Implement hasFeatureAtPixel for canvas 2015-01-08 16:12:52 +01:00
tsauerwein
d0691ecc4d Add hasFeatureAtPixel function to map 2015-01-08 16:12:52 +01:00
tsauerwein
974823dbd4 Refactor createTexture 2015-01-08 15:40:03 +01:00
tsauerwein
38322d615b Use renderBuffer for hit-detection 2015-01-08 15:38:00 +01:00
tsauerwein
060c9f3bc6 Reduce number of arrays created 2015-01-08 15:38:00 +01:00
tsauerwein
6c48b2067b Make icon example work with webgl 2015-01-08 15:38:00 +01:00
tsauerwein
da7f38635b Remove hitDetectionOrigin 2015-01-08 15:38:00 +01:00
tsauerwein
461ec1d3bc Make sure hit-detection atlas is in sync
... with the atlas for the original images, so that
the offsets are the same.
2015-01-08 15:38:00 +01:00
tsauerwein
cf6dd38866 Use hit-detection images 2015-01-08 15:38:00 +01:00
tsauerwein
3ef61fa1c5 Add hit-detection support for webgl 2015-01-08 15:38:00 +01:00
tsauerwein
740420468e Add hit-detection framebuffer to context 2015-01-08 15:38:00 +01:00
Frederic Junod
b827bc126c Don't pass specific options to the parent constructor 2015-01-08 14:07:33 +01:00
Frédéric Junod
1f90aad4ad Merge pull request #3104 from fredj/vector-constr
Don't pass renderBuffer option to the parent constructor
2015-01-08 11:58:39 +01:00
Frederic Junod
91d2b3b87f Don't pass renderBuffer option to the parent constructor 2015-01-08 10:59:42 +01:00
Frédéric Junod
904fac082c Merge pull request #3096 from fredj/example-cleanup
popup example cleanup / simplification
2015-01-08 09:07:25 +01:00
Tim Schaub
b952f118ba Merge pull request #3072 from tschaub/hit-extent
Optimize canvas hit detection by rendering features in a limited extent.
2015-01-07 23:54:21 -07:00
Tim Schaub
1ee03625e9 Optimize hit detection by rendering features in a limited extent 2015-01-07 23:04:42 -07:00
Tim Schaub
3be6a84de6 Merge pull request #3101 from tschaub/object
Use bracket notation instead of goog.object functions.
2015-01-07 22:57:28 -07:00
Tim Schaub
1ff43686f5 Use bracket notation instead of goog.object.get 2015-01-07 22:31:01 -07:00
Tim Schaub
a09a76c766 Merge pull request #3079 from tschaub/sourceless-docs
Exclude source files from docs.
2015-01-07 22:20:57 -07:00
Tim Schaub
f9a92c422c Use bracket notation instead of goog.object.set 2015-01-07 21:08:24 -07:00
Tim Schaub
0a784bfc3b Allow bracket notation
We use bracket notation with string literals instead of dot notation where we don't want the compiler to do any renaming.
2015-01-07 21:06:04 -07:00
Frédéric Junod
d35ea9e4f4 Merge pull request #3100 from fredj/tilelayer-attr
Assert that ol.layer.Tile#getPreload is always set
2015-01-07 17:54:10 +01:00
Frederic Junod
55dda99cfe Assert that ol.layer.Tile#getUseInterimTilesOnError is always set 2015-01-07 16:59:44 +01:00
Frederic Junod
df51e55781 Assert that ol.layer.Tile#getPreload is always set 2015-01-07 16:48:15 +01:00
Frederic Junod
a753135e84 Remove moz-box-shadow CSS rule
Gecko 13 (Firefox 13) removed support for -moz-box-shadow. Since then,
only the unprefixed version is supported.
2015-01-06 09:26:00 +01:00
Frederic Junod
d4ff5527c9 Set the position to undefined to hide the overlay 2015-01-06 09:26:00 +01:00
Tim Schaub
06fe8288ce Merge pull request #3084 from openlayers/v3.1.x
Changes from the v3.1.x branch.
2015-01-05 10:22:14 -07:00
Tim Schaub
8e982b0763 Merge pull request #3094 from tschaub/authorless
Remove AUTHORS.md.
2015-01-04 13:00:14 -07:00
Tim Schaub
38b890a69a Removing AUTHORS.md
This was a partial, unmaintained list of the project contributors.  For a complete list of contributors, see the Git log.  E.g.

    git shortlog -s | cut -c8-
2015-01-03 22:58:06 -07:00
Bart van den Eijnden
8eb6814e4b Merge pull request #3089 from mike-mcgann/fix_test_readme_url
Fixed URL link for test README
2014-12-29 17:13:02 +01:00
Mike McGann
6b162f813f Fixed URL link for test README 2014-12-29 10:15:34 -05:00
Frédéric Junod
9a4c56d216 Merge pull request #2894 from fredj/simplify-custom-controls
Simplify CSS code in custom-controls example
2014-12-27 11:46:35 +01:00
Tim Schaub
5d2f4630f5 Merge pull request #3085 from mike-mcgann/doc-typo
Fixed documentation typo for return value of ol.proj.Projection.isGlobal().
2014-12-23 16:08:24 -05:00
Mike McGann
cc4a690676 Fixed documentation typo for return value of ol.proj.Projection.isGlobal() 2014-12-23 15:38:49 -05:00
Andreas Hocevar
97afb31a65 Merge pull request #3073 from ahocevar/load-tile-options
Make map's deviceOptions map options
2014-12-23 16:11:22 +01:00
Tim Schaub
4b423fca16 Exclude source files from docs 2014-12-22 17:01:01 -05:00
Andreas Hocevar
38b12d3149 Make map's deviceOptions map options
This removes the map's deviceOptions config option, and instead
introduces loadTilesWhileAnimating and loadTilesWhileInteracting map
options. By default, both are false now, to make zooming and panning
smoother on most devices.
2014-12-21 12:03:28 +01:00
Frederic Junod
a715a38d75 Simplify CSS code in custom-controls example
By using the ol-control css class and a button instead of a link.
2014-10-30 12:37:44 +01:00
173 changed files with 6758 additions and 1634 deletions

View File

@@ -1,4 +1,5 @@
{ {
"-W030": true, "-W030": true,
"-W083": true "-W083": true,
"-W069": true
} }

View File

@@ -1,58 +0,0 @@
OpenLayers contributors:
* Antoine Abt
* Mike Adair
* Jeff Adams
* Seb Benthall
* Bruno Binet
* Stéphane Brunner
* Howard Butler
* Bertil Chaupis
* John Cole
* Tim Coulter
* Robert Coup
* Jeff Dege
* Roald de Wit
* Schuyler Erle
* Christian López Espínola
* John Frank
* Sean Gilles
* Pierre Giraud
* Ivan Grcic
* Andreas Hocevar
* Marc Jansen
* Ian Johnson
* Frédéric Junod
* Eric Lemoine
* Philip Lindsay
* Martijn van Oosterhout
* David Overstrom
* Tom Payne
* Corey Puffault
* Peter William Robins
* Gregers Rygg
* Tim Schaub
* Christopher Schmidt
* Tobias Schwinger
* Cameron Shorter
* Pedro Simonetti
* Paul Spencer
* Paul Smith
* Glen Stampoultzis
* James Stembridge
* Erik Uzureau
* Bart van den Eijnden
* Ivan Willig
* Thomas Wood
* Bill Woodall
* Steve Woodbridge
* David Zwarg
Some portions of OpenLayers are used under the Apache 2.0 license, available
in doc/licenses/APACHE-2.0.txt.
Some portions of OpenLayers are used under the MIT license, availabie in
doc/licenses/MIT-LICENSE.txt.
Some portions of OpenLayers are Copyright 2001 Robert Penner, and are used
under the BSD license, available in doc/licenses/BSD-LICENSE.txt

View File

@@ -42,7 +42,7 @@ as described below.
The minimum requirements are: The minimum requirements are:
* Git * Git
* [Node.js](http://nodejs.org/) * [Node.js](http://nodejs.org/) (0.10.x or higher)
* Python 2.6 or 2.7 with a couple of extra modules (see below) * Python 2.6 or 2.7 with a couple of extra modules (see below)
* Java 7 (JRE and JDK) * Java 7 (JRE and JDK)
@@ -132,7 +132,7 @@ To run the tests on the console (headless testing with PhantomJS) use the `test`
$ ./build.py test $ ./build.py test
See also the test-specific [README](../blob/master/test/README.md). See also the test-specific [README](../master/test/README.md).
## Running the integration tests ## Running the integration tests
@@ -239,6 +239,14 @@ style of the existing OpenLayers 3 code, which includes:
* Do not use assignments inside expressions. * Do not use assignments inside expressions.
* Avoid the use of `goog.array.clone` with arrays (use slice instead).
* Use `array.length = 0` instead of `goog.array.clear`.
* Use bracket notation instead of `goog.object.set` and `goog.object.get` (with
two arguments).
* Use uppercase for `@const` variables.
### Pass the integration tests run automatically by the Travis CI system ### Pass the integration tests run automatically by the Travis CI system

View File

@@ -1,5 +1,4 @@
Copyright 2005-2014 OpenLayers Contributors. All rights reserved. See Copyright 2005-2014 OpenLayers Contributors. All rights reserved.
AUTHORS.md for full list.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
# OpenLayers 3 # OpenLayers 3
[![Travis CI Status](https://secure.travis-ci.org/openlayers/ol3.png)](http://travis-ci.org/#!/openlayers/ol3) [![Travis CI Status](https://secure.travis-ci.org/openlayers/ol3.svg)](http://travis-ci.org/#!/openlayers/ol3)
Welcome to [OpenLayers 3](http://openlayers.org/)! Welcome to [OpenLayers 3](http://openlayers.org/)!

View File

@@ -172,7 +172,8 @@ virtual('ci', 'lint', 'build', 'test',
'build/examples/all.combined.js', 'check-examples', 'apidoc') 'build/examples/all.combined.js', 'check-examples', 'apidoc')
virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-debug.js') virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-debug.js',
'build/ol.js.map')
virtual('check', 'lint', 'build/ol.js', 'test') virtual('check', 'lint', 'build/ol.js', 'test')
@@ -192,12 +193,21 @@ def build_ol_css(t):
t.output('%(CLEANCSS)s', 'css/ol.css') t.output('%(CLEANCSS)s', 'css/ol.css')
@target('build/ol.js', SRC, SHADER_SRC, 'config/ol.json', NPM_INSTALL) def _build_js(t):
def build_ol_new_js(t):
t.run('node', 'tasks/build.js', 'config/ol.json', 'build/ol.js') t.run('node', 'tasks/build.js', 'config/ol.json', 'build/ol.js')
@target('build/ol.js', SRC, SHADER_SRC, 'config/ol.json', NPM_INSTALL)
def build_ol_js(t):
_build_js(t)
report_sizes(t) report_sizes(t)
@target('build/ol.js.map', SRC, SHADER_SRC, 'config/ol.json', NPM_INSTALL)
def build_ol_js_map(t):
_build_js(t)
@target('build/ol-debug.js', SRC, SHADER_SRC, 'config/ol-debug.json', @target('build/ol-debug.js', SRC, SHADER_SRC, 'config/ol-debug.json',
NPM_INSTALL) NPM_INSTALL)
def build_ol_debug_js(t): def build_ol_debug_js(t):

86
changelog/v3.2.0.md Normal file
View File

@@ -0,0 +1,86 @@
# 3.2.0
## Summary
The 3.1.0 release includes 70 merged pull requests since 3.1.0. Of note, the KML format [now parses `NetworkingLink` tags](https://github.com/openlayers/ol3/pull/3171). The [measure example](http://openlayers.org/en/v3.2.0/examples/measure.html) was [reworked](https://github.com/openlayers/ol3/pull/3206) to display measurements and help messages while drawing. A WMTS GetCapabilities format was [added](https://github.com/openlayers/ol3/pull/3026). The WebGL renderer [now supports feature hit detection](https://github.com/openlayers/ol3/pull/3065) (on point features). And you can now [detect](https://github.com/openlayers/ol3/pull/3172) features/colored pixels on image and tile layers! See the full list of [changes](#changes) below.
## Upgrade notes
The 3.2.0 release maintains a backwards-compatible API with the 3.1.0 release, so upgrades should be painless. Some special considerations below.
* You should not call `view.setRotation` with `undefined`, to reset the view rotation to `0` then use `view.setRotation(0)` (see [#3176](https://github.com/openlayers/ol3/pull/3176)).
* If you use `$(map.getViewport()).on('mousemove')` to detect features when the mouse is hovered on the map, you should now rely on the `pointermove` map event type and check in the `pointermove` listener that the `dragging` event property is `false` (see [#3190](https://github.com/openlayers/ol3/pull/3190)).
## Changes
* [#3171](https://github.com/openlayers/ol3/pull/3171) - KML: Parsing of NetworkLink tag ([@oterral](https://github.com/oterral))
* [#3209](https://github.com/openlayers/ol3/pull/3209) - Coding style fixes ([@fredj](https://github.com/fredj))
* [#3208](https://github.com/openlayers/ol3/pull/3208) - Add setters and getters for imageLoadFunction ([@bartvde](https://github.com/bartvde))
* [#3019](https://github.com/openlayers/ol3/pull/3019) - Add option to allow Select interaction logic to select overlapping features ([@bjornharrtell](https://github.com/bjornharrtell))
* [#3206](https://github.com/openlayers/ol3/pull/3206) - Add tooltip to show measure + help message while drawing ([@pgiraud](https://github.com/pgiraud))
* [#3205](https://github.com/openlayers/ol3/pull/3205) - Use ol.extent.createOrUpdateFromCoordinate ([@fredj](https://github.com/fredj))
* [#3026](https://github.com/openlayers/ol3/pull/3026) - Add support of reading WMTS Get Cap document ([@htulipe](https://github.com/htulipe))
* [#3201](https://github.com/openlayers/ol3/pull/3201) - Pass on opt_fast to parent clear function in ol.source.ServerVector (r=@elemoine,@gberaudo) ([@bartvde](https://github.com/bartvde))
* [#3199](https://github.com/openlayers/ol3/pull/3199) - Minor jsdoc fixes ([@fredj](https://github.com/fredj))
* [#3059](https://github.com/openlayers/ol3/pull/3059) - Cache the buffered extent value ([@fredj](https://github.com/fredj))
* [#3196](https://github.com/openlayers/ol3/pull/3196) - Remove unnecessary newlines ([@fredj](https://github.com/fredj))
* [#3099](https://github.com/openlayers/ol3/pull/3099) - Fix up parsing of OGR GML with ol.format.GML ([@bartvde](https://github.com/bartvde))
* [#3195](https://github.com/openlayers/ol3/pull/3195) - Coding style ([@fredj](https://github.com/fredj))
* [#3192](https://github.com/openlayers/ol3/pull/3192) - Add "url" option to ol.source.MapQuest ([@elemoine](https://github.com/elemoine))
* [#3172](https://github.com/openlayers/ol3/pull/3172) - Introduce forEachLayerAtPixel ([@tsauerwein](https://github.com/tsauerwein))
* [#3178](https://github.com/openlayers/ol3/pull/3178) - GeoJSON externs fixes ([@fredj](https://github.com/fredj))
* [#3179](https://github.com/openlayers/ol3/pull/3179) - Disallow undefined values for ol.layer.Base ([@fredj](https://github.com/fredj))
* [#3161](https://github.com/openlayers/ol3/pull/3161) - Doc fix. writeFeaturesNode receives an array of Feature ([@3x0dv5](https://github.com/3x0dv5))
* [#3169](https://github.com/openlayers/ol3/pull/3169) - Fix default icon style in kml format ([@oterral](https://github.com/oterral))
* [#3190](https://github.com/openlayers/ol3/pull/3190) - Introduce `dragging` flag for MapBrowserEvent ([@tsauerwein](https://github.com/tsauerwein))
* [#3135](https://github.com/openlayers/ol3/pull/3135) - Make changing the label of ZoomToExtent/FullScreen control consistent ([@tsauerwein](https://github.com/tsauerwein))
* [#3186](https://github.com/openlayers/ol3/pull/3186) - Take the pixel ratio into account when clipping the layer ([@fredj](https://github.com/fredj))
* [#3183](https://github.com/openlayers/ol3/pull/3183) - Allow other params than 'mode' in example page query string. ([@htulipe](https://github.com/htulipe))
* [#2791](https://github.com/openlayers/ol3/pull/2791) - Re enable rotation button transition ([@fredj](https://github.com/fredj))
* [#3180](https://github.com/openlayers/ol3/pull/3180) - Add a getMap function to ol.FeatureOverlay (r=@ahocevar) ([@bartvde](https://github.com/bartvde))
* [#3176](https://github.com/openlayers/ol3/pull/3176) - Disallowed undefined rotation value ([@fredj](https://github.com/fredj))
* [#3177](https://github.com/openlayers/ol3/pull/3177) - Add example showing how to style polygon vertices ([@tsauerwein](https://github.com/tsauerwein))
* [#3174](https://github.com/openlayers/ol3/pull/3174) - Use view.getRotation or view.getResolution instead of view.getState ([@fredj](https://github.com/fredj))
* [#3170](https://github.com/openlayers/ol3/pull/3170) - Coding style ([@fredj](https://github.com/fredj))
* [#3108](https://github.com/openlayers/ol3/pull/3108) - Support skipping features in the WebGL renderer ([@tsauerwein](https://github.com/tsauerwein))
* [#3163](https://github.com/openlayers/ol3/pull/3163) - Use the layerStatesArray property from the frameState ([@fredj](https://github.com/fredj))
* [#3159](https://github.com/openlayers/ol3/pull/3159) - Don't pass specific options to the parent constructor ([@fredj](https://github.com/fredj))
* [#3066](https://github.com/openlayers/ol3/pull/3066) - Introduce hasFeatureAtPixel ([@tsauerwein](https://github.com/tsauerwein))
* [#3065](https://github.com/openlayers/ol3/pull/3065) - Add hit-detection support for WebGL ([@tsauerwein](https://github.com/tsauerwein))
* [#3128](https://github.com/openlayers/ol3/pull/3128) - Allow rendering of feature when download of icon failed ([@oterral](https://github.com/oterral))
* [#3156](https://github.com/openlayers/ol3/pull/3156) - Move readProjectionFrom* functions to the base classes ([@fredj](https://github.com/fredj))
* [#3107](https://github.com/openlayers/ol3/pull/3107) - Also listen on loading images ([@elemoine](https://github.com/elemoine))
* [#3153](https://github.com/openlayers/ol3/pull/3153) - Add missing GeoJSONFeature#bbox property ([@fredj](https://github.com/fredj))
* [#3154](https://github.com/openlayers/ol3/pull/3154) - Remove unnecessary newlines ([@fredj](https://github.com/fredj))
* [#3146](https://github.com/openlayers/ol3/pull/3146) - Enable tests for ol.geom.flat.reverse ([@icholy](https://github.com/icholy))
* [#3152](https://github.com/openlayers/ol3/pull/3152) - Update closure-library and closure-util version ([@fredj](https://github.com/fredj))
* [#3145](https://github.com/openlayers/ol3/pull/3145) - Add wrapX option to source.OSM and source.BingMaps ([@elemoine](https://github.com/elemoine))
* [#3139](https://github.com/openlayers/ol3/pull/3139) - Add ol.control.Control#setTarget ([@elemoine](https://github.com/elemoine))
* [#3144](https://github.com/openlayers/ol3/pull/3144) - Update CONTRIBUTING style guide with recent guidelines ([@bartvde](https://github.com/bartvde))
* [#3136](https://github.com/openlayers/ol3/pull/3136) - Use array.length = 0 instead of goog.array.clear ([@fredj](https://github.com/fredj))
* [#3140](https://github.com/openlayers/ol3/pull/3140) - Avoid use of goog.array.clone with arrays. ([@tschaub](https://github.com/tschaub))
* [#3122](https://github.com/openlayers/ol3/pull/3122) - Revert "Use offsetX and offsetY if available" ([@fredj](https://github.com/fredj))
* [#2385](https://github.com/openlayers/ol3/pull/2385) - Option to update vector layers while animating ([@ahocevar](https://github.com/ahocevar))
* [#3129](https://github.com/openlayers/ol3/pull/3129) - Only update the rbush item if the extent has changed ([@fredj](https://github.com/fredj))
* [#3117](https://github.com/openlayers/ol3/pull/3117) - Add pixelRatio support for DOM vector renderer ([@ahocevar](https://github.com/ahocevar))
* [#3124](https://github.com/openlayers/ol3/pull/3124) - Add a space between scale -value and -unit ([@sirtet](https://github.com/sirtet))
* [#3130](https://github.com/openlayers/ol3/pull/3130) - Document default value ([@fredj](https://github.com/fredj))
* [#3105](https://github.com/openlayers/ol3/pull/3105) - ol.geom.Geometry#getExtent re-factoring ([@fredj](https://github.com/fredj))
* [#3118](https://github.com/openlayers/ol3/pull/3118) - Bugfix: "Cannot read property 'firstElementChild' of null" (WFS) ([@naturalatlas](https://github.com/naturalatlas))
* [#3114](https://github.com/openlayers/ol3/pull/3114) - Specify node version in CONTRIBUTING.md ([@elemoine](https://github.com/elemoine))
* [#3106](https://github.com/openlayers/ol3/pull/3106) - Don't pass specific options to the parent constructor ([@fredj](https://github.com/fredj))
* [#3110](https://github.com/openlayers/ol3/pull/3110) - Use svg instead of png to get better image quality ([@PeterDaveHello](https://github.com/PeterDaveHello))
* [#2707](https://github.com/openlayers/ol3/pull/2707) - Generate source map of minified ol.js ([@gberaudo](https://github.com/gberaudo))
* [#3104](https://github.com/openlayers/ol3/pull/3104) - Don't pass renderBuffer option to the parent constructor ([@fredj](https://github.com/fredj))
* [#3096](https://github.com/openlayers/ol3/pull/3096) - popup example cleanup / simplification ([@fredj](https://github.com/fredj))
* [#3072](https://github.com/openlayers/ol3/pull/3072) - Optimize canvas hit detection by rendering features in a limited extent. ([@tschaub](https://github.com/tschaub))
* [#3101](https://github.com/openlayers/ol3/pull/3101) - Use bracket notation instead of goog.object functions. ([@tschaub](https://github.com/tschaub))
* [#3079](https://github.com/openlayers/ol3/pull/3079) - Exclude source files from docs. ([@tschaub](https://github.com/tschaub))
* [#3100](https://github.com/openlayers/ol3/pull/3100) - Assert that ol.layer.Tile#getPreload is always set ([@fredj](https://github.com/fredj))
* [#3084](https://github.com/openlayers/ol3/pull/3084) - Changes from the v3.1.x branch. ([@openlayers](https://github.com/openlayers))
* [#3094](https://github.com/openlayers/ol3/pull/3094) - Remove AUTHORS.md. ([@tschaub](https://github.com/tschaub))
* [#3089](https://github.com/openlayers/ol3/pull/3089) - Fixed URL link for test README ([@mike-mcgann](https://github.com/mike-mcgann))
* [#2894](https://github.com/openlayers/ol3/pull/2894) - Simplify CSS code in custom-controls example ([@fredj](https://github.com/fredj))
* [#3085](https://github.com/openlayers/ol3/pull/3085) - Fixed documentation typo for return value of ol.proj.Projection.isGlobal(). ([@mike-mcgann](https://github.com/mike-mcgann))
* [#3073](https://github.com/openlayers/ol3/pull/3073) - Make map's deviceOptions map options ([@ahocevar](https://github.com/ahocevar))

View File

@@ -1,3 +1,3 @@
{ {
"library_url": "https://github.com/google/closure-library/archive/ad5e66c1e7d7829b0d77feae49aaf5f011265715.zip" "library_url": "https://github.com/google/closure-library/archive/0011afd534469ba111786fe68300a634e08a4d80.zip"
} }

View File

@@ -34,7 +34,7 @@
"cleverLinks": true, "cleverLinks": true,
"monospaceLinks": true, "monospaceLinks": true,
"default": { "default": {
"outputSourceFiles": true "outputSourceFiles": false
}, },
"applicationName": "OpenLayers 3" "applicationName": "OpenLayers 3"
}, },

View File

@@ -61,6 +61,8 @@
"compilation_level": "ADVANCED", "compilation_level": "ADVANCED",
"warning_level": "VERBOSE", "warning_level": "VERBOSE",
"use_types_for_optimization": true, "use_types_for_optimization": true,
"manage_closure_dependencies": true "manage_closure_dependencies": true,
"create_source_map": "build/ol.js.map",
"source_map_format": "V3"
} }
} }

View File

@@ -53,11 +53,12 @@
.ol-rotate { .ol-rotate {
top: .5em; top: .5em;
right: .5em; right: .5em;
transition: opacity .25s; transition: opacity .25s linear, visibility 0s linear;
} }
.ol-rotate.ol-hidden { .ol-rotate.ol-hidden {
opacity: 0; opacity: 0;
display: none; visibility: hidden;
transition: opacity .25s linear, visibility 0s linear .25s;
} }
.ol-zoom-extent { .ol-zoom-extent {
top: 4.643em; top: 4.643em;
@@ -114,21 +115,12 @@
background-color: #4c6079; background-color: #4c6079;
background-color: rgba(0,60,136,0.7); background-color: rgba(0,60,136,0.7);
} }
.ol-zoom-extent button:after {
content: "E";
}
.ol-zoom .ol-zoom-in { .ol-zoom .ol-zoom-in {
border-radius: 2px 2px 0 0; border-radius: 2px 2px 0 0;
} }
.ol-zoom .ol-zoom-out { .ol-zoom .ol-zoom-out {
border-radius: 0 0 2px 2px; border-radius: 0 0 2px 2px;
} }
button.ol-full-screen-false:after {
content: "\2194";
}
button.ol-full-screen-true:after {
content: "\00d7";
}
.ol-attribution { .ol-attribution {

View File

@@ -55,6 +55,9 @@ var map = new ol.Map({
}) })
], ],
renderer: exampleNS.getRendererFromQueryString(), renderer: exampleNS.getRendererFromQueryString(),
// Improve user experience by loading tiles while animating. Will make
// animations stutter on mobile or slow devices.
loadTilesWhileAnimating: true,
target: 'map', target: 'map',
controls: ol.control.defaults({ controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({ attributionOptions: /** @type {olx.control.AttributionOptions} */ ({

View File

@@ -29,6 +29,9 @@ for (i = 0, ii = styles.length; i < ii; ++i) {
var map = new ol.Map({ var map = new ol.Map({
layers: layers, layers: layers,
renderer: exampleNS.getRendererFromQueryString(), renderer: exampleNS.getRendererFromQueryString(),
// Improve user experience by loading tiles while dragging/zooming. Will make
// zooming choppy on mobile or slow devices.
loadTilesWhileInteracting: true,
target: 'map', target: 'map',
view: new ol.View({ view: new ol.View({
center: [-6655.5402445057125, 6709968.258934638], center: [-6655.5402445057125, 6709968.258934638],

View File

@@ -10,39 +10,12 @@
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css"> <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<style type="text/css"> <style type="text/css">
.rotate-north { .rotate-north {
position: absolute;
top: 65px; top: 65px;
left: 8px; left: .5em;
background: rgba(255,255,255,0.4);
border-radius: 4px;
padding: 2px;
} }
.ol-touch .rotate-north { .ol-touch .rotate-north {
top: 80px; top: 80px;
} }
.rotate-north a {
display: block;
color: white;
font-size: 16px;
font-family: 'Lucida Grande',Verdana,Geneva,Lucida,Arial,Helvetica,sans-serif;
font-weight: bold;
margin: 1px;
text-decoration: none;
text-align: center;
border-radius: 2px;
height: 22px;
width: 22px;
background: rgba(0,60,136,0.5);
}
.ol-touch .rotate-north a {
font-size: 20px;
height: 30px;
width: 30px;
line-height: 26px;
}
.rotate-north a:hover {
background: rgba(0,60,136,0.7);
}
</style> </style>
<title>ol3 custom controls example</title> <title>ol3 custom controls example</title>
</head> </head>

View File

@@ -29,23 +29,20 @@ app.RotateNorthControl = function(opt_options) {
var options = opt_options || {}; var options = opt_options || {};
var anchor = document.createElement('a'); var button = document.createElement('button');
anchor.href = '#rotate-north'; button.innerHTML = 'N';
anchor.innerHTML = 'N';
var this_ = this; var this_ = this;
var handleRotateNorth = function(e) { var handleRotateNorth = function(e) {
// prevent #rotate-north anchor from getting appended to the url
e.preventDefault();
this_.getMap().getView().setRotation(0); this_.getMap().getView().setRotation(0);
}; };
anchor.addEventListener('click', handleRotateNorth, false); button.addEventListener('click', handleRotateNorth, false);
anchor.addEventListener('touchstart', handleRotateNorth, false); button.addEventListener('touchstart', handleRotateNorth, false);
var element = document.createElement('div'); var element = document.createElement('div');
element.className = 'rotate-north ol-unselectable'; element.className = 'rotate-north ol-unselectable ol-control';
element.appendChild(anchor); element.appendChild(button);
ol.control.Control.call(this, { ol.control.Control.call(this, {
element: element, element: element,

File diff suppressed because it is too large Load Diff

View File

@@ -145,7 +145,10 @@ var displayFeatureInfo = function(pixel) {
} }
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent); var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel); displayFeatureInfo(pixel);
}); });

View File

@@ -141,7 +141,10 @@ var displayFeatureInfo = function(pixel) {
} }
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent); var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel); displayFeatureInfo(pixel);
}); });

View File

@@ -35,9 +35,11 @@
<h4 id="title">GetFeatureInfo example (image layer)</h4> <h4 id="title">GetFeatureInfo example (image layer)</h4>
<p id="shortdesc">This example shows how to trigger WMS GetFeatureInfo requests on click for a WMS image layer.</p> <p id="shortdesc">This example shows how to trigger WMS GetFeatureInfo requests on click for a WMS image layer.</p>
<div id="docs"> <div id="docs">
<p>Additionally <code>map.forEachLayerAtPixel</code> is used to change the mouse
pointer when hovering a non-transparent pixel on the map.</p>
<p>See the <a href="getfeatureinfo-image.js" target="_blank">getfeatureinfo-image.js source</a> to see how this is done.</p> <p>See the <a href="getfeatureinfo-image.js" target="_blank">getfeatureinfo-image.js source</a> to see how this is done.</p>
</div> </div>
<div id="tags">getfeatureinfo</div> <div id="tags">getfeatureinfo, forEachLayerAtPixel</div>
</div> </div>
<div class="span4 offset4"> <div class="span4 offset4">
<div id="info" class="alert alert-success"> <div id="info" class="alert alert-success">

View File

@@ -7,7 +7,8 @@ goog.require('ol.source.ImageWMS');
var wmsSource = new ol.source.ImageWMS({ var wmsSource = new ol.source.ImageWMS({
url: 'http://demo.boundlessgeo.com/geoserver/wms', url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {'LAYERS': 'ne:ne'}, params: {'LAYERS': 'ne:ne'},
serverType: 'geoserver' serverType: 'geoserver',
crossOrigin: ''
}); });
var wmsLayer = new ol.layer.Image({ var wmsLayer = new ol.layer.Image({
@@ -20,6 +21,7 @@ var view = new ol.View({
}); });
var map = new ol.Map({ var map = new ol.Map({
renderer: exampleNS.getRendererFromQueryString(),
layers: [wmsLayer], layers: [wmsLayer],
target: 'map', target: 'map',
view: view view: view
@@ -36,3 +38,14 @@ map.on('singleclick', function(evt) {
'<iframe seamless src="' + url + '"></iframe>'; '<iframe seamless src="' + url + '"></iframe>';
} }
}); });
map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent);
var hit = map.forEachLayerAtPixel(pixel, function(layer) {
return true;
});
map.getTargetElement().style.cursor = hit ? 'pointer' : '';
});

View File

@@ -35,9 +35,11 @@
<h4 id="title">WMS GetFeatureInfo example (tile layer)</h4> <h4 id="title">WMS GetFeatureInfo example (tile layer)</h4>
<p id="shortdesc">This example shows how to trigger WMS GetFeatureInfo requests on click for a WMS tile layer.</p> <p id="shortdesc">This example shows how to trigger WMS GetFeatureInfo requests on click for a WMS tile layer.</p>
<div id="docs"> <div id="docs">
<p>Additionally <code>map.forEachLayerAtPixel</code> is used to change the mouse
pointer when hovering a non-transparent pixel on the map.</p>
<p>See the <a href="getfeatureinfo-tile.js" target="_blank">getfeatureinfo-tile.js source</a> to see how this is done.</p> <p>See the <a href="getfeatureinfo-tile.js" target="_blank">getfeatureinfo-tile.js source</a> to see how this is done.</p>
</div> </div>
<div id="tags">getfeatureinfo</div> <div id="tags">getfeatureinfo, forEachLayerAtPixel</div>
</div> </div>
<div class="span4 offset4"> <div class="span4 offset4">
<div id="info" class="alert alert-success"> <div id="info" class="alert alert-success">

View File

@@ -7,7 +7,8 @@ goog.require('ol.source.TileWMS');
var wmsSource = new ol.source.TileWMS({ var wmsSource = new ol.source.TileWMS({
url: 'http://demo.boundlessgeo.com/geoserver/wms', url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {'LAYERS': 'ne:ne'}, params: {'LAYERS': 'ne:ne'},
serverType: 'geoserver' serverType: 'geoserver',
crossOrigin: ''
}); });
var wmsLayer = new ol.layer.Tile({ var wmsLayer = new ol.layer.Tile({
@@ -20,6 +21,7 @@ var view = new ol.View({
}); });
var map = new ol.Map({ var map = new ol.Map({
renderer: exampleNS.getRendererFromQueryString(),
layers: [wmsLayer], layers: [wmsLayer],
target: 'map', target: 'map',
view: view view: view
@@ -36,3 +38,14 @@ map.on('singleclick', function(evt) {
'<iframe seamless src="' + url + '"></iframe>'; '<iframe seamless src="' + url + '"></iframe>';
} }
}); });
map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent);
var hit = map.forEachLayerAtPixel(pixel, function(layer) {
return true;
});
map.getTargetElement().style.cursor = hit ? 'pointer' : '';
});

View File

@@ -85,7 +85,10 @@ var displayFeatureInfo = function(pixel) {
} }
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent); var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel); displayFeatureInfo(pixel);
}); });

View File

@@ -30,7 +30,7 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span8">
<h4 id="title">Icon sprite with WebGL example</h4> <h4 id="title">Icon sprite with WebGL example</h4>
<p id="shortdesc">Icon sprite with WebGL.</p> <p id="shortdesc">Icon sprite with WebGL.</p>
<div id="docs"> <div id="docs">
@@ -39,6 +39,11 @@
</div> </div>
<div id="tags">webgl, icon, sprite, vector, point</div> <div id="tags">webgl, icon, sprite, vector, point</div>
</div> </div>
<div class="span2 offset2">
<div id="info" class="alert alert-success">
&nbsp;
</div>
</div>
</div> </div>

View File

@@ -109,3 +109,34 @@ var featureOverlay = new ol.FeatureOverlay({
}), }),
features: overlayFeatures features: overlayFeatures
}); });
map.on('click', function(evt) {
var info = document.getElementById('info');
info.innerHTML =
'Hold on a second, while I catch those butterflies for you ...';
window.setTimeout(function() {
var features = [];
map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
features.push(features);
return false;
});
if (features.length === 1) {
info.innerHTML = 'Got one butterfly';
} else if (features.length > 1) {
info.innerHTML = 'Got ' + features.length + ' butterflies';
} else {
info.innerHTML = 'Couldn\'t catch a single butterfly';
}
}, 1);
});
map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent);
var hit = map.hasFeatureAtPixel(pixel);
map.getTarget().style.cursor = hit ? 'pointer' : '';
});

View File

@@ -40,11 +40,13 @@ var vectorLayer = new ol.layer.Vector({
var rasterLayer = new ol.layer.Tile({ var rasterLayer = new ol.layer.Tile({
source: new ol.source.TileJSON({ source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/mapbox.geography-class.jsonp' url: 'http://api.tiles.mapbox.com/v3/mapbox.geography-class.jsonp',
crossOrigin: ''
}) })
}); });
var map = new ol.Map({ var map = new ol.Map({
renderer: exampleNS.getRendererFromQueryString(),
layers: [rasterLayer, vectorLayer], layers: [rasterLayer, vectorLayer],
target: document.getElementById('map'), target: document.getElementById('map'),
view: new ol.View({ view: new ol.View({
@@ -84,14 +86,12 @@ map.on('click', function(evt) {
}); });
// change mouse cursor when over marker // change mouse cursor when over marker
$(map.getViewport()).on('mousemove', function(e) { map.on('pointermove', function(e) {
var pixel = map.getEventPixel(e.originalEvent); if (e.dragging) {
var hit = map.forEachFeatureAtPixel(pixel, function(feature, layer) { $(element).popover('destroy');
return true; return;
});
if (hit) {
map.getTarget().style.cursor = 'pointer';
} else {
map.getTarget().style.cursor = '';
} }
var pixel = map.getEventPixel(e.originalEvent);
var hit = map.hasFeatureAtPixel(pixel);
map.getTarget().style.cursor = hit ? 'pointer' : '';
}); });

View File

@@ -126,7 +126,10 @@ var displaySnap = function(coordinate) {
map.render(); map.render();
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var coordinate = map.getEventCoordinate(evt.originalEvent); var coordinate = map.getEventCoordinate(evt.originalEvent);
displaySnap(coordinate); displaySnap(coordinate);
}); });

View File

@@ -80,7 +80,10 @@ var displayFeatureInfo = function(pixel) {
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent); var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel); displayFeatureInfo(pixel);
}); });

View File

@@ -85,7 +85,11 @@ var displayFeatureInfo = function(pixel) {
} }
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
info.tooltip('hide');
return;
}
displayFeatureInfo(map.getEventPixel(evt.originalEvent)); displayFeatureInfo(map.getEventPixel(evt.originalEvent));
}); });

View File

@@ -92,7 +92,11 @@ var displayFeatureInfo = function(pixel) {
} }
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
info.tooltip('hide');
return;
}
displayFeatureInfo(map.getEventPixel(evt.originalEvent)); displayFeatureInfo(map.getEventPixel(evt.originalEvent));
}); });

View File

@@ -52,7 +52,10 @@ var displayFeatureInfo = function(pixel) {
} }
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent); var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel); displayFeatureInfo(pixel);
}); });

View File

@@ -9,6 +9,40 @@
<link rel="stylesheet" href="../resources/layout.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"> <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Measure example</title> <title>Measure example</title>
<style>
.tooltip {
position: relative;
background: rgba(0, 0, 0, 0.5);
border-radius: 4px;
color: white;
padding: 4px 8px;
opacity: 0.7;
white-space: nowrap;
}
.tooltip-measure {
opacity: 1;
font-weight: bold;
}
.tooltip-static {
background-color: #ffcc33;
color: black;
border: 1px solid white;
}
.tooltip-measure:before,
.tooltip-static:before {
border-top: 6px solid rgba(0, 0, 0, 0.5);
border-right: 6px solid transparent;
border-left: 6px solid transparent;
content: "";
position: absolute;
bottom: -6px;
margin-left: -7px;
left: 50%;
}
.tooltip-static:before {
border-top-color: #ffcc33;
}
</style>
</head> </head>
<body> <body>
@@ -43,8 +77,6 @@
</select> </select>
</form> </form>
<ol id="measureOutput" reversed></ol>
<div id="docs"> <div id="docs">
<p><i>NOTE: Measure is done in simple way on projected plane. Earth <p><i>NOTE: Measure is done in simple way on projected plane. Earth
curvature is not taken into account</i></p> curvature is not taken into account</i></p>

View File

@@ -1,4 +1,5 @@
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.View'); goog.require('ol.View');
goog.require('ol.geom.LineString'); goog.require('ol.geom.LineString');
goog.require('ol.geom.Polygon'); goog.require('ol.geom.Polygon');
@@ -40,35 +41,85 @@ var vector = new ol.layer.Vector({
/** /**
* Currently drawed feature * Currently drawn feature.
* @type {ol.Feature} * @type {ol.Feature}
*/ */
var sketch; var sketch;
/** /**
* Element for currently drawed feature * The help tooltip element.
* @type {Element} * @type {Element}
*/ */
var sketchElement; var helpTooltipElement;
/** /**
* handle pointer move * Overlay to show the help messages.
* @param {Event} evt * @type {ol.Overlay}
*/ */
var mouseMoveHandler = function(evt) { var helpTooltip;
/**
* The measure tooltip element.
* @type {Element}
*/
var measureTooltipElement;
/**
* Overlay to show the measurement.
* @type {ol.Overlay}
*/
var measureTooltip;
/**
* Message to show when the user is drawing a polygon.
* @type {string}
*/
var continuePolygonMsg = 'Click to continue drawing the polygon';
/**
* Message to show when the user is drawing a line.
* @type {string}
*/
var continueLineMsg = 'Click to continue drawing the line';
/**
* Handle pointer move.
* @param {ol.MapBrowserEvent} evt
*/
var pointerMoveHandler = function(evt) {
if (evt.dragging) {
return;
}
/** @type {string} */
var helpMsg = 'Click to start drawing';
/** @type {ol.Coordinate|undefined} */
var tooltipCoord = evt.coordinate;
if (sketch) { if (sketch) {
var output; var output;
var geom = (sketch.getGeometry()); var geom = (sketch.getGeometry());
if (geom instanceof ol.geom.Polygon) { if (geom instanceof ol.geom.Polygon) {
output = formatArea(/** @type {ol.geom.Polygon} */ (geom)); output = formatArea(/** @type {ol.geom.Polygon} */ (geom));
helpMsg = continuePolygonMsg;
tooltipCoord = geom.getInteriorPoint().getCoordinates();
} else if (geom instanceof ol.geom.LineString) { } else if (geom instanceof ol.geom.LineString) {
output = formatLength( /** @type {ol.geom.LineString} */ (geom)); output = formatLength( /** @type {ol.geom.LineString} */ (geom));
helpMsg = continueLineMsg;
tooltipCoord = geom.getLastCoordinate();
} }
sketchElement.innerHTML = output; measureTooltipElement.innerHTML = output;
measureTooltip.setPosition(tooltipCoord);
} }
helpTooltipElement.innerHTML = helpMsg;
helpTooltip.setPosition(evt.coordinate);
}; };
@@ -81,7 +132,7 @@ var map = new ol.Map({
}) })
}); });
$(map.getViewport()).on('mousemove', mouseMoveHandler); map.on('pointermove', pointerMoveHandler);
var typeSelect = document.getElementById('type'); var typeSelect = document.getElementById('type');
@@ -90,33 +141,87 @@ function addInteraction() {
var type = (typeSelect.value == 'area' ? 'Polygon' : 'LineString'); var type = (typeSelect.value == 'area' ? 'Polygon' : 'LineString');
draw = new ol.interaction.Draw({ draw = new ol.interaction.Draw({
source: source, source: source,
type: /** @type {ol.geom.GeometryType} */ (type) type: /** @type {ol.geom.GeometryType} */ (type),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)'
}),
stroke: new ol.style.Stroke({
color: 'rgba(0, 0, 0, 0.5)',
lineDash: [10, 10],
width: 2
}),
image: new ol.style.Circle({
radius: 5,
stroke: new ol.style.Stroke({
color: 'rgba(0, 0, 0, 0.7)'
}),
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)'
})
})
})
}); });
map.addInteraction(draw); map.addInteraction(draw);
createMeasureTooltip();
createHelpTooltip();
draw.on('drawstart', draw.on('drawstart',
function(evt) { function(evt) {
// set sketch // set sketch
sketch = evt.feature; sketch = evt.feature;
sketchElement = document.createElement('li');
var outputList = document.getElementById('measureOutput');
if (outputList.childNodes) {
outputList.insertBefore(sketchElement, outputList.firstChild);
} else {
outputList.appendChild(sketchElement);
}
}, this); }, this);
draw.on('drawend', draw.on('drawend',
function(evt) { function(evt) {
measureTooltipElement.className = 'tooltip tooltip-static';
measureTooltip.setOffset([0, -7]);
// unset sketch // unset sketch
sketch = null; sketch = null;
sketchElement = null; // unset tooltip so that a new one can be created
measureTooltipElement = null;
createMeasureTooltip();
}, this); }, this);
} }
/**
* Creates a new help tooltip
*/
function createHelpTooltip() {
if (helpTooltipElement) {
helpTooltipElement.parentNode.removeChild(helpTooltipElement);
}
helpTooltipElement = document.createElement('div');
helpTooltipElement.className = 'tooltip';
helpTooltip = new ol.Overlay({
element: helpTooltipElement,
offset: [15, 0],
positioning: 'center-left'
});
map.addOverlay(helpTooltip);
}
/**
* Creates a new measure tooltip
*/
function createMeasureTooltip() {
if (measureTooltipElement) {
measureTooltipElement.parentNode.removeChild(measureTooltipElement);
}
measureTooltipElement = document.createElement('div');
measureTooltipElement.className = 'tooltip tooltip-measure';
measureTooltip = new ol.Overlay({
element: measureTooltipElement,
offset: [0, -15],
positioning: 'bottom-center'
});
map.addOverlay(measureTooltip);
}
/** /**
* Let user change the geometry type. * Let user change the geometry type.
* @param {Event} e Change event. * @param {Event} e Change event.

View File

@@ -0,0 +1,57 @@
<!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="../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>Custom styles for polygons</title>
<style>
.map {
background: grey;
}
</style>
</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">Custom styles for polygons</h4>
<p id="shortdesc">Showing the vertices of a polygon with a custom style geometry.</p>
<div id="docs">
<p>See the <a href="polygon-styles.js" target="_blank">polygon-styles.js source</a> to see how this is done.</p>
</div>
<div id="tags">polygon, vector, style, GeometryFunction</div>
</div>
</div>
</div>
<script src="../resources/jquery.min.js" type="text/javascript"></script>
<script src="loader.js?id=polygon-styles" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

101
examples/polygon-styles.js Normal file
View File

@@ -0,0 +1,101 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.geom.MultiPoint');
goog.require('ol.layer.Vector');
goog.require('ol.source.GeoJSON');
goog.require('ol.style.Circle');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var styles = [
/* We are using two different styles for the polygons:
* - The first style is for the polygons themselves.
* - The second style is to draw the vertices of the polygons.
* In a custom `geometry` function the vertices of a polygon are
* returned as `MultiPoint` geometry, which will be used to render
* the style.
*/
new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 3
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
}),
new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'orange'
})
}),
geometry: function(feature) {
// return the coordinates of the first ring of the polygon
var coordinates = feature.getGeometry().getCoordinates()[0];
return new ol.geom.MultiPoint(coordinates);
}
})
];
var source = new ol.source.GeoJSON(/** @type {olx.source.GeoJSONOptions} */ ({
object: {
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {
'name': 'EPSG:3857'
}
},
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
[-3e6, 6e6], [-5e6, 6e6]]]
}
},
{
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6],
[0, 6e6], [-2e6, 6e6]]]
}
},
{
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
[3e6, 6e6], [1e6, 6e6]]]
}
},
{
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [[[-2e6, -1e6], [-1e6, 1e6],
[0, -1e6], [-2e6, -1e6]]]
}
}
]
}
}));
var layer = new ol.layer.Vector({
source: source,
style: styles
});
var map = new ol.Map({
layers: [layer],
target: 'map',
view: new ol.View({
center: [0, 1000000],
zoom: 2
})
});

View File

@@ -10,10 +10,8 @@
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css"> <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<style type="text/css"> <style type="text/css">
.ol-popup { .ol-popup {
display: none;
position: absolute; position: absolute;
background-color: white; background-color: white;
-moz-box-shadow: 0 1px 4px rgba(0,0,0,0.2);
-webkit-filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2)); -webkit-filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2));
filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2)); filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2));
padding: 15px; padding: 15px;

View File

@@ -20,7 +20,7 @@ var closer = document.getElementById('popup-closer');
* @return {boolean} Don't follow the href. * @return {boolean} Don't follow the href.
*/ */
closer.onclick = function() { closer.onclick = function() {
container.style.display = 'none'; overlay.setPosition(undefined);
closer.blur(); closer.blur();
return false; return false;
}; };
@@ -65,9 +65,7 @@ map.on('click', function(evt) {
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform( var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
coordinate, 'EPSG:3857', 'EPSG:4326')); coordinate, 'EPSG:3857', 'EPSG:4326'));
overlay.setPosition(coordinate);
content.innerHTML = '<p>You clicked here:</p><code>' + hdms + content.innerHTML = '<p>You clicked here:</p><code>' + hdms +
'</code>'; '</code>';
container.style.display = 'block'; overlay.setPosition(coordinate);
}); });

View File

@@ -83,7 +83,10 @@ var displaySnap = function(coordinate) {
map.render(); map.render();
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var coordinate = map.getEventCoordinate(evt.originalEvent); var coordinate = map.getEventCoordinate(evt.originalEvent);
displaySnap(coordinate); displaySnap(coordinate);
}); });
@@ -116,13 +119,12 @@ map.on('postcompose', function(evt) {
} }
}); });
$(map.getViewport()).on('mousemove', function(e) { map.on('pointermove', function(evt) {
var pixel = map.getEventPixel(e.originalEvent); if (evt.dragging) {
return;
var hit = map.forEachFeatureAtPixel(pixel, function(feature, layer) { }
return true; var pixel = map.getEventPixel(evt.originalEvent);
}); var hit = map.hasFeatureAtPixel(pixel);
if (hit) { if (hit) {
map.getTarget().style.cursor = 'pointer'; map.getTarget().style.cursor = 'pointer';
} else { } else {

View File

@@ -58,7 +58,10 @@ var displayCountryInfo = function(coordinate) {
}); });
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var coordinate = map.getEventCoordinate(evt.originalEvent); var coordinate = map.getEventCoordinate(evt.originalEvent);
displayCountryInfo(coordinate); displayCountryInfo(coordinate);
}); });

View File

@@ -114,7 +114,10 @@ var displayFeatureInfo = function(pixel) {
}; };
$(map.getViewport()).on('mousemove', function(evt) { map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent); var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel); displayFeatureInfo(pixel);
}); });

View File

@@ -0,0 +1,49 @@
<!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>WMTS GetCapabilities parsing 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="span4">
<h4 id="title">WMTS GetCapabilities parsing example</h4>
<p id="shortdesc">Example of parsing a WMTS GetCapabilities response.</p>
<div id="docs">
<p>See the <a href="wmts-capabilities.js" target="_blank">wmts-capabilities.js source</a> to see how this is done.</p>
</div>
<div id="tags">wmts, capabilities, getcapabilities</div>
</div>
<div class="span8">
<pre id="log"></pre>
</div>
</div>
</div>
<script src="../resources/jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=wmts-capabilities" type="text/javascript"></script>
</body>
</html>

View File

@@ -0,0 +1,8 @@
goog.require('ol.format.WMTSCapabilities');
var parser = new ol.format.WMTSCapabilities();
$.ajax('data/WMTSCapabilities.xml').then(function(response) {
var result = parser.read(response);
$('#log').html(window.JSON.stringify(result, null, 2));
});

View File

@@ -13,6 +13,12 @@
var GeoJSONObject = function() {}; var GeoJSONObject = function() {};
/**
* @type {!Array.<number>|undefined}
*/
GeoJSONObject.prototype.bbox;
/** /**
* @type {string} * @type {string}
*/ */
@@ -28,11 +34,17 @@ GeoJSONObject.prototype.crs;
/** /**
* @constructor * @constructor
* @extends {GeoJSONObject}
*/ */
var GeoJSONCRS = function() {}; var GeoJSONCRS = function() {};
/**
* CRS type. One of `link` or `name`.
* @type {string}
*/
GeoJSONCRS.prototype.type;
/** /**
* TODO: remove GeoJSONCRSCode when http://jira.codehaus.org/browse/GEOS-5996 * TODO: remove GeoJSONCRSCode when http://jira.codehaus.org/browse/GEOS-5996
* is fixed and widely deployed. * is fixed and widely deployed.
@@ -142,16 +154,9 @@ var GeoJSONFeatureCollection = function() {};
GeoJSONFeatureCollection.prototype.features; GeoJSONFeatureCollection.prototype.features;
/**
* @type {!Array.<number>|undefined}
*/
GeoJSONFeatureCollection.prototype.bbox;
/** /**
* @constructor * @constructor
* @extends {GeoJSONObject}
*/ */
var GeoJSONLink = function() {}; var GeoJSONLink = function() {};
@@ -160,3 +165,8 @@ var GeoJSONLink = function() {};
* @type {string} * @type {string}
*/ */
GeoJSONLink.prototype.href; GeoJSONLink.prototype.href;
/**
* @type {string}
*/
GeoJSONLink.prototype.type;

View File

@@ -92,6 +92,12 @@ oli.MapBrowserEvent.prototype.originalEvent;
oli.MapBrowserEvent.prototype.pixel; oli.MapBrowserEvent.prototype.pixel;
/**
* @type {boolean}
*/
oli.MapBrowserEvent.prototype.dragging;
/** /**
* @interface * @interface

View File

@@ -23,32 +23,6 @@ olx.AttributionOptions;
olx.AttributionOptions.prototype.html; olx.AttributionOptions.prototype.html;
/**
* @typedef {{loadTilesWhileAnimating: (boolean|undefined),
* loadTilesWhileInteracting: (boolean|undefined)}}
* @api
*/
olx.DeviceOptions;
/**
* When set to false, no tiles will be loaded while animating, which improves
* responsiveness on devices with slow memory. Default is `true`.
* @type {boolean|undefined}
* @api
*/
olx.DeviceOptions.prototype.loadTilesWhileAnimating;
/**
* When set to false, no tiles will be loaded while interacting, which improves
* responsiveness on devices with slow memory. Default is `true`.
* @type {boolean|undefined}
* @api
*/
olx.DeviceOptions.prototype.loadTilesWhileInteracting;
/** /**
* @typedef {{tracking: (boolean|undefined)}} * @typedef {{tracking: (boolean|undefined)}}
* @api * @api
@@ -194,11 +168,12 @@ olx.interaction.InteractionOptions.prototype.handleEvent;
/** /**
* Object literal with config options for the map. * Object literal with config options for the map.
* @typedef {{controls: (ol.Collection.<ol.control.Control>|Array.<ol.control.Control>|undefined), * @typedef {{controls: (ol.Collection.<ol.control.Control>|Array.<ol.control.Control>|undefined),
* deviceOptions: (olx.DeviceOptions|undefined),
* pixelRatio: (number|undefined), * pixelRatio: (number|undefined),
* interactions: (ol.Collection.<ol.interaction.Interaction>|Array.<ol.interaction.Interaction>|undefined), * interactions: (ol.Collection.<ol.interaction.Interaction>|Array.<ol.interaction.Interaction>|undefined),
* keyboardEventTarget: (Element|Document|string|undefined), * keyboardEventTarget: (Element|Document|string|undefined),
* layers: (Array.<ol.layer.Base>|ol.Collection.<ol.layer.Base>|undefined), * layers: (Array.<ol.layer.Base>|ol.Collection.<ol.layer.Base>|undefined),
* loadTilesWhileAnimating: (boolean|undefined),
* loadTilesWhileInteracting: (boolean|undefined),
* logo: (boolean|string|olx.LogoOptions|undefined), * logo: (boolean|string|olx.LogoOptions|undefined),
* overlays: (ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined), * overlays: (ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined),
* renderer: (ol.RendererType|Array.<ol.RendererType|string>|string|undefined), * renderer: (ol.RendererType|Array.<ol.RendererType|string>|string|undefined),
@@ -218,14 +193,6 @@ olx.MapOptions;
olx.MapOptions.prototype.controls; olx.MapOptions.prototype.controls;
/**
* Device options for the map.
* @type {olx.DeviceOptions|undefined}
* @api
*/
olx.MapOptions.prototype.deviceOptions;
/** /**
* The ratio between physical pixels and device-independent pixels (dips) on the * The ratio between physical pixels and device-independent pixels (dips) on the
* device. If `undefined` then it gets set by using `window.devicePixelRatio`. * device. If `undefined` then it gets set by using `window.devicePixelRatio`.
@@ -266,6 +233,26 @@ olx.MapOptions.prototype.keyboardEventTarget;
olx.MapOptions.prototype.layers; olx.MapOptions.prototype.layers;
/**
* When set to true, tiles will be loaded during animations. This may improve
* the user experience, but can also make animations stutter on devices with
* slow memory. Default is `false`.
* @type {boolean|undefined}
* @api
*/
olx.MapOptions.prototype.loadTilesWhileAnimating;
/**
* When set to true, tiles will be loaded while interacting with the map. This
* may improve the user experience, but can also make map panning and zooming
* choppy on devices with slow memory. Default is `false`.
* @type {boolean|undefined}
* @api
*/
olx.MapOptions.prototype.loadTilesWhileInteracting;
/** /**
* The map logo. A logo to be displayed on the map at all times. If a string is * The map logo. A logo to be displayed on the map at all times. If a string is
* provided, it will be set as the image source of the logo. If an object is * provided, it will be set as the image source of the logo. If an object is
@@ -819,8 +806,8 @@ olx.control;
* collapsible: (boolean|undefined), * collapsible: (boolean|undefined),
* collapsed: (boolean|undefined), * collapsed: (boolean|undefined),
* tipLabel: (string|undefined), * tipLabel: (string|undefined),
* label: (string|undefined), * label: (string|Node|undefined),
* collapseLabel: (string|undefined), * collapseLabel: (string|Node|undefined),
* render: (function(ol.MapEvent)|undefined), * render: (function(ol.MapEvent)|undefined),
* target: (Element|undefined)}} * target: (Element|undefined)}}
* @api * @api
@@ -872,15 +859,17 @@ olx.control.AttributionOptions.prototype.tipLabel;
/** /**
* Text label to use for the collapsed attributions button. Default is `i` * Text label to use for the collapsed attributions button. Default is `i`.
* @type {string|undefined} * Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api * @api
*/ */
olx.control.AttributionOptions.prototype.label; olx.control.AttributionOptions.prototype.label;
/** /**
* Text label to use for the expanded attributions button. Default is `»` * Text label to use for the expanded attributions button. Default is `»`.
* @type {string|undefined} * Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api * @api
*/ */
olx.control.AttributionOptions.prototype.collapseLabel; olx.control.AttributionOptions.prototype.collapseLabel;
@@ -993,6 +982,8 @@ olx.control.DefaultsOptions.prototype.zoomOptions;
/** /**
* @typedef {{className: (string|undefined), * @typedef {{className: (string|undefined),
* label: (string|Node|undefined),
* labelActive: (string|Node|undefined),
* tipLabel: (string|undefined), * tipLabel: (string|undefined),
* keys: (boolean|undefined), * keys: (boolean|undefined),
* target: (Element|undefined)}} * target: (Element|undefined)}}
@@ -1009,6 +1000,25 @@ olx.control.FullScreenOptions;
olx.control.FullScreenOptions.prototype.className; olx.control.FullScreenOptions.prototype.className;
/**
* Text label to use for the button. Default is `\u2194` (an arrow).
* Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api
*/
olx.control.FullScreenOptions.prototype.label;
/**
* Text label to use for the button when full-screen is active.
* Default is `\u00d7` (a cross).
* Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api
*/
olx.control.FullScreenOptions.prototype.labelActive;
/** /**
* Text label to use for the button tip. Default is `Toggle full-screen` * Text label to use for the button tip. Default is `Toggle full-screen`
* @type {string|undefined} * @type {string|undefined}
@@ -1096,9 +1106,9 @@ olx.control.MousePositionOptions.prototype.undefinedHTML;
/** /**
* @typedef {{collapsed: (boolean|undefined), * @typedef {{collapsed: (boolean|undefined),
* collapseLabel: (string|undefined), * collapseLabel: (string|Node|undefined),
* collapsible: (boolean|undefined), * collapsible: (boolean|undefined),
* label: (string|undefined), * label: (string|Node|undefined),
* layers: (Array.<ol.layer.Layer>|ol.Collection|undefined), * layers: (Array.<ol.layer.Layer>|ol.Collection|undefined),
* render: (function(ol.MapEvent)|undefined), * render: (function(ol.MapEvent)|undefined),
* target: (Element|undefined), * target: (Element|undefined),
@@ -1118,8 +1128,9 @@ olx.control.OverviewMapOptions.prototype.collapsed;
/** /**
* Text label to use for the expanded overviewmap button. Default is `«` * Text label to use for the expanded overviewmap button. Default is `«`.
* @type {string|undefined} * Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api * @api
*/ */
olx.control.OverviewMapOptions.prototype.collapseLabel; olx.control.OverviewMapOptions.prototype.collapseLabel;
@@ -1134,8 +1145,9 @@ olx.control.OverviewMapOptions.prototype.collapsible;
/** /**
* Text label to use for the collapsed overviewmap button. Default is `»` * Text label to use for the collapsed overviewmap button. Default is `»`.
* @type {string|undefined} * Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api * @api
*/ */
olx.control.OverviewMapOptions.prototype.label; olx.control.OverviewMapOptions.prototype.label;
@@ -1231,7 +1243,7 @@ olx.control.ScaleLineOptions.prototype.units;
/** /**
* @typedef {{duration: (number|undefined), * @typedef {{duration: (number|undefined),
* className: (string|undefined), * className: (string|undefined),
* label: (string|undefined), * label: (string|Node|undefined),
* tipLabel: (string|undefined), * tipLabel: (string|undefined),
* target: (Element|undefined), * target: (Element|undefined),
* render: (function(ol.MapEvent)|undefined), * render: (function(ol.MapEvent)|undefined),
@@ -1250,8 +1262,9 @@ olx.control.RotateOptions.prototype.className;
/** /**
* Text label to use for the rotate button. Default is `⇧` * Text label to use for the rotate button. Default is `⇧`.
* @type {string|undefined} * Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api stable * @api stable
*/ */
olx.control.RotateOptions.prototype.label; olx.control.RotateOptions.prototype.label;
@@ -1301,8 +1314,8 @@ olx.control.RotateOptions.prototype.target;
/** /**
* @typedef {{duration: (number|undefined), * @typedef {{duration: (number|undefined),
* className: (string|undefined), * className: (string|undefined),
* zoomInLabel: (string|undefined), * zoomInLabel: (string|Node|undefined),
* zoomOutLabel: (string|undefined), * zoomOutLabel: (string|Node|undefined),
* zoomInTipLabel: (string|undefined), * zoomInTipLabel: (string|undefined),
* zoomOutTipLabel: (string|undefined), * zoomOutTipLabel: (string|undefined),
* delta: (number|undefined), * delta: (number|undefined),
@@ -1329,16 +1342,18 @@ olx.control.ZoomOptions.prototype.className;
/** /**
* Text label to use for the zoom-in button. Default is `+` * Text label to use for the zoom-in button. Default is `+`.
* @type {string|undefined} * Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api stable * @api stable
*/ */
olx.control.ZoomOptions.prototype.zoomInLabel; olx.control.ZoomOptions.prototype.zoomInLabel;
/** /**
* Text label to use for the zoom-out button. Default is `-` * Text label to use for the zoom-out button. Default is `-`.
* @type {string|undefined} * Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api stable * @api stable
*/ */
olx.control.ZoomOptions.prototype.zoomOutLabel; olx.control.ZoomOptions.prototype.zoomOutLabel;
@@ -1422,6 +1437,7 @@ olx.control.ZoomSliderOptions.prototype.render;
/** /**
* @typedef {{className: (string|undefined), * @typedef {{className: (string|undefined),
* target: (Element|undefined), * target: (Element|undefined),
* label: (string|Node|undefined),
* tipLabel: (string|undefined), * tipLabel: (string|undefined),
* extent: (ol.Extent|undefined)}} * extent: (ol.Extent|undefined)}}
* @api stable * @api stable
@@ -1445,6 +1461,15 @@ olx.control.ZoomToExtentOptions.prototype.className;
olx.control.ZoomToExtentOptions.prototype.target; olx.control.ZoomToExtentOptions.prototype.target;
/**
* Text label to use for the button. Default is `E`.
* Instead of text, also a Node (e.g. a `span` element) can be used.
* @type {string|Node|undefined}
* @api stable
*/
olx.control.ZoomToExtentOptions.prototype.label;
/** /**
* Text label to use for the button tip. Default is `Zoom to extent` * Text label to use for the button tip. Default is `Zoom to extent`
* @type {string|undefined} * @type {string|undefined}
@@ -2494,7 +2519,8 @@ olx.interaction.PointerOptions.prototype.handleUpEvent;
* layers: (Array.<ol.layer.Layer>|function(ol.layer.Layer): boolean|undefined), * layers: (Array.<ol.layer.Layer>|function(ol.layer.Layer): boolean|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined), * style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined),
* removeCondition: (ol.events.ConditionType|undefined), * removeCondition: (ol.events.ConditionType|undefined),
* toggleCondition: (ol.events.ConditionType|undefined)}} * toggleCondition: (ol.events.ConditionType|undefined),
* multi: (boolean|undefined)}}
* @api * @api
*/ */
olx.interaction.SelectOptions; olx.interaction.SelectOptions;
@@ -2571,6 +2597,15 @@ olx.interaction.SelectOptions.prototype.removeCondition;
*/ */
olx.interaction.SelectOptions.prototype.toggleCondition; olx.interaction.SelectOptions.prototype.toggleCondition;
/**
* A boolean that determines if the default behaviour should select only
* single features or all (overlapping) features at the clicked map
* position. Default is false i.e single select
* @type {boolean|undefined}
* @api
*/
olx.interaction.SelectOptions.prototype.multi;
/** /**
* Namespace. * Namespace.
@@ -3233,6 +3268,7 @@ olx.layer.TileOptions.prototype.useInterimTilesOnError;
* saturation: (number|undefined), * saturation: (number|undefined),
* source: (ol.source.Vector|undefined), * source: (ol.source.Vector|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined), * style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined),
* updateWhileAnimating: (boolean|undefined),
* visible: (boolean|undefined)}} * visible: (boolean|undefined)}}
* @api * @api
*/ */
@@ -3341,6 +3377,17 @@ olx.layer.VectorOptions.prototype.source;
olx.layer.VectorOptions.prototype.style; olx.layer.VectorOptions.prototype.style;
/**
* When set to `true`, feature batches will be recreated during animations.
* This means that no vectors will be shown clipped, but the setting will have a
* performance impact for large amounts of vector data. When set to `false`,
* batches will be recreated when no animation is active. Default is `false`.
* @type {boolean|undefined}
* @api
*/
olx.layer.VectorOptions.prototype.updateWhileAnimating;
/** /**
* Visibility. Default is `true` (visible). * Visibility. Default is `true` (visible).
* @type {boolean|undefined} * @type {boolean|undefined}
@@ -3394,7 +3441,8 @@ olx.source;
* key: string, * key: string,
* imagerySet: string, * imagerySet: string,
* maxZoom: (number|undefined), * maxZoom: (number|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined)}} * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* wrapX: (boolean|undefined)}}
* @api * @api
*/ */
olx.source.BingMapsOptions; olx.source.BingMapsOptions;
@@ -3440,6 +3488,15 @@ olx.source.BingMapsOptions.prototype.maxZoom;
*/ */
olx.source.BingMapsOptions.prototype.tileLoadFunction; olx.source.BingMapsOptions.prototype.tileLoadFunction;
/**
* Whether to wrap the world horizontally. Default is `true`.
* @type {boolean|undefined}
* @api
*/
olx.source.BingMapsOptions.prototype.wrapX;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* distance: (number|undefined), * distance: (number|undefined),
@@ -3555,7 +3612,7 @@ olx.source.FormatVectorOptions.prototype.projection;
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultProjection: ol.proj.ProjectionLike, * defaultProjection: ol.proj.ProjectionLike,
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* object: (GeoJSONObject|undefined), * object: (GeoJSONFeature|GeoJSONFeatureCollection|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
* text: (string|undefined), * text: (string|undefined),
* url: (string|undefined), * url: (string|undefined),
@@ -3590,8 +3647,8 @@ olx.source.GeoJSONOptions.prototype.logo;
/** /**
* Object. * GeoJSON feature or feature collection.
* @type {GeoJSONObject|undefined} * @type {GeoJSONFeature|GeoJSONFeatureCollection|undefined}
* @api * @api
*/ */
olx.source.GeoJSONOptions.prototype.object; olx.source.GeoJSONOptions.prototype.object;
@@ -4254,7 +4311,8 @@ olx.source.KMLOptions.prototype.urls;
/** /**
* @typedef {{layer: string, * @typedef {{layer: string,
* tileLoadFunction: (ol.TileLoadFunctionType|undefined)}} * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* url: (string|undefined)}}
* @api * @api
*/ */
olx.source.MapQuestOptions; olx.source.MapQuestOptions;
@@ -4276,6 +4334,14 @@ olx.source.MapQuestOptions.prototype.layer;
olx.source.MapQuestOptions.prototype.tileLoadFunction; olx.source.MapQuestOptions.prototype.tileLoadFunction;
/**
* URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders.
* @type {string|undefined}
* @api
*/
olx.source.MapQuestOptions.prototype.url;
/** /**
* @typedef {{projection: ol.proj.ProjectionLike, * @typedef {{projection: ol.proj.ProjectionLike,
* tileGrid: (ol.tilegrid.TileGrid|undefined)}} * tileGrid: (ol.tilegrid.TileGrid|undefined)}}
@@ -4305,7 +4371,8 @@ olx.source.TileDebugOptions.prototype.tileGrid;
* crossOrigin: (null|string|undefined), * crossOrigin: (null|string|undefined),
* maxZoom: (number|undefined), * maxZoom: (number|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined), * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* url: (string|undefined)}} * url: (string|undefined),
* wrapX: (boolean|undefined)}}
* @api * @api
*/ */
olx.source.OSMOptions; olx.source.OSMOptions;
@@ -4358,6 +4425,14 @@ olx.source.OSMOptions.prototype.tileLoadFunction;
olx.source.OSMOptions.prototype.url; olx.source.OSMOptions.prototype.url;
/**
* Whether to wrap the world horizontally. Default is `true`.
* @type {boolean|undefined}
* @api
*/
olx.source.OSMOptions.prototype.wrapX;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* doc: (Document|undefined), * doc: (Document|undefined),
@@ -6505,6 +6580,13 @@ olx.ViewState;
olx.ViewState.prototype.center; olx.ViewState.prototype.center;
/**
* @type {ol.proj.Projection}
* @api
*/
olx.ViewState.prototype.projection;
/** /**
* @type {number} * @type {number}
* @api * @api

View File

@@ -1,6 +1,6 @@
{ {
"name": "openlayers", "name": "openlayers",
"version": "3.1.1", "version": "3.2.0",
"description": "Build tools and sources for developing OpenLayers based mapping applications", "description": "Build tools and sources for developing OpenLayers based mapping applications",
"keywords": [ "keywords": [
"map", "map",
@@ -25,7 +25,7 @@
}, },
"dependencies": { "dependencies": {
"async": "0.9.0", "async": "0.9.0",
"closure-util": "1.2.0", "closure-util": "1.3.0",
"fs-extra": "0.12.0", "fs-extra": "0.12.0",
"graceful-fs": "3.0.2", "graceful-fs": "3.0.2",
"htmlparser2": "3.7.3", "htmlparser2": "3.7.3",

View File

@@ -29,11 +29,13 @@
pairs = [], pairs = [],
i, i,
pair, pair,
adjusted; adjusted,
modeFound = false;
for (i = chunks.length - 1; i >= 0; --i) { for (i = chunks.length - 1; i >= 0; --i) {
pair = chunks[i].split('='); pair = chunks[i].split('=');
if (pair[0].toLowerCase() === 'mode') { if (pair[0].toLowerCase() === 'mode') {
pair[1] = newMode; pair[1] = newMode;
modeFound = true;
} }
adjusted = encodeURIComponent(pair[0]); adjusted = encodeURIComponent(pair[0]);
if (typeof pair[1] !== undefined) { if (typeof pair[1] !== undefined) {
@@ -41,8 +43,8 @@
} }
pairs.push(adjusted); pairs.push(adjusted);
} }
if (pairs.length === 0) { if (!modeFound) {
pairs[0] = 'mode=' + encodeURIComponent(newMode); pairs.push('mode=' + encodeURIComponent(newMode));
} }
location.href = baseUrl + '?' + pairs.join('&'); location.href = baseUrl + '?' + pairs.join('&');
}; };

View File

@@ -95,7 +95,7 @@ ol.Collection = function(opt_array) {
* @private * @private
* @type {Array.<T>} * @type {Array.<T>}
*/ */
this.array_ = opt_array || []; this.array_ = goog.isDef(opt_array) ? opt_array : [];
this.updateLength_(); this.updateLength_();

View File

@@ -69,32 +69,33 @@ ol.control.Attribution = function(opt_options) {
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = goog.isDef(options.tipLabel) ?
options.tipLabel : 'Attributions'; options.tipLabel : 'Attributions';
/** var collapseLabel = goog.isDef(options.collapseLabel) ?
* @private
* @type {string}
*/
this.collapseLabel_ = goog.isDef(options.collapseLabel) ?
options.collapseLabel : '\u00BB'; options.collapseLabel : '\u00BB';
/** /**
* @private * @private
* @type {string} * @type {Node}
*/ */
this.label_ = goog.isDef(options.label) ? options.label : 'i'; this.collapseLabel_ = /** @type {Node} */ (goog.isString(collapseLabel) ?
var label = goog.dom.createDom(goog.dom.TagName.SPAN, {}, goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) :
(this.collapsible_ && !this.collapsed_) ? collapseLabel);
this.collapseLabel_ : this.label_);
var label = goog.isDef(options.label) ? options.label : 'i';
/** /**
* @private * @private
* @type {Element} * @type {Node}
*/ */
this.labelSpan_ = label; this.label_ = /** @type {Node} */ (goog.isString(label) ?
goog.dom.createDom(goog.dom.TagName.SPAN, {}, label) :
label);
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
this.collapseLabel_ : this.label_;
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
'type': 'button', 'type': 'button',
'title': tipLabel 'title': tipLabel
}, this.labelSpan_); }, activeLabel);
goog.events.listen(button, goog.events.EventType.CLICK, goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this); this.handleClick_, false, this);
@@ -341,8 +342,11 @@ ol.control.Attribution.prototype.handleClick_ = function(event) {
*/ */
ol.control.Attribution.prototype.handleToggle_ = function() { ol.control.Attribution.prototype.handleToggle_ = function() {
goog.dom.classlist.toggle(this.element, 'ol-collapsed'); goog.dom.classlist.toggle(this.element, 'ol-collapsed');
goog.dom.setTextContent(this.labelSpan_, if (this.collapsed_) {
(this.collapsed_) ? this.collapseLabel_ : this.label_); goog.dom.replaceNode(this.collapseLabel_, this.label_);
} else {
goog.dom.replaceNode(this.label_, this.collapseLabel_);
}
this.collapsed_ = !this.collapsed_; this.collapsed_ = !this.collapsed_;
}; };

View File

@@ -51,8 +51,7 @@ ol.control.Control = function(options) {
* @private * @private
* @type {Element} * @type {Element}
*/ */
this.target_ = goog.isDef(options.target) ? this.target_ = null;
goog.dom.getElement(options.target) : null;
/** /**
* @private * @private
@@ -71,6 +70,10 @@ ol.control.Control = function(options) {
*/ */
this.render = goog.isDef(options.render) ? options.render : goog.nullFunction; this.render = goog.isDef(options.render) ? options.render : goog.nullFunction;
if (goog.isDef(options.target)) {
this.setTarget(options.target);
}
}; };
goog.inherits(ol.control.Control, ol.Object); goog.inherits(ol.control.Control, ol.Object);
@@ -121,3 +124,17 @@ ol.control.Control.prototype.setMap = function(map) {
map.render(); map.render();
} }
}; };
/**
* This function is used to set a target element for the control. It has no
* effect if it is called after the control has been added to the map (i.e.
* after `setMap` is called on the control). If no `target` is set in the
* options passed to the control constructor and if `setTarget` is not called
* then the control is added to the map's overlay container.
* @param {Element|string} target Target.
* @api
*/
ol.control.Control.prototype.setTarget = function(target) {
this.target_ = goog.dom.getElement(target);
};

View File

@@ -3,7 +3,6 @@ goog.provide('ol.control.FullScreen');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.dom'); goog.require('goog.dom');
goog.require('goog.dom.TagName'); goog.require('goog.dom.TagName');
goog.require('goog.dom.classlist');
goog.require('goog.dom.fullscreen'); goog.require('goog.dom.fullscreen');
goog.require('goog.dom.fullscreen.EventType'); goog.require('goog.dom.fullscreen.EventType');
goog.require('goog.events'); goog.require('goog.events');
@@ -37,13 +36,32 @@ ol.control.FullScreen = function(opt_options) {
this.cssClassName_ = goog.isDef(options.className) ? this.cssClassName_ = goog.isDef(options.className) ?
options.className : 'ol-full-screen'; options.className : 'ol-full-screen';
var label = goog.isDef(options.label) ? options.label : '\u2194';
/**
* @private
* @type {Node}
*/
this.labelNode_ = /** @type {Node} */ (goog.isString(label) ?
goog.dom.createTextNode(label) : label);
var labelActive = goog.isDef(options.labelActive) ?
options.labelActive : '\u00d7';
/**
* @private
* @type {Node}
*/
this.labelActiveNode_ = /** @type {Node} */ (goog.isString(labelActive) ?
goog.dom.createTextNode(labelActive) : labelActive);
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = goog.isDef(options.tipLabel) ?
options.tipLabel : 'Toggle full-screen'; options.tipLabel : 'Toggle full-screen';
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(), 'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(),
'type': 'button', 'type': 'button',
'title': tipLabel 'title': tipLabel
}); }, this.labelNode_);
goog.events.listen(button, goog.events.EventType.CLICK, goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this); this.handleClick_, false, this);
@@ -120,14 +138,11 @@ ol.control.FullScreen.prototype.handleFullScreen_ = function() {
* @private * @private
*/ */
ol.control.FullScreen.prototype.handleFullScreenChange_ = function() { ol.control.FullScreen.prototype.handleFullScreenChange_ = function() {
var opened = this.cssClassName_ + '-true';
var closed = this.cssClassName_ + '-false';
var anchor = goog.dom.getFirstElementChild(this.element);
var map = this.getMap(); var map = this.getMap();
if (goog.dom.fullscreen.isFullScreen()) { if (goog.dom.fullscreen.isFullScreen()) {
goog.dom.classlist.swap(anchor, closed, opened); goog.dom.replaceNode(this.labelActiveNode_, this.labelNode_);
} else { } else {
goog.dom.classlist.swap(anchor, opened, closed); goog.dom.replaceNode(this.labelNode_, this.labelActiveNode_);
} }
if (!goog.isNull(map)) { if (!goog.isNull(map)) {
map.updateSize(); map.updateSize();

View File

@@ -57,31 +57,33 @@ ol.control.OverviewMap = function(opt_options) {
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = goog.isDef(options.tipLabel) ?
options.tipLabel : 'Overview map'; options.tipLabel : 'Overview map';
/** var collapseLabel = goog.isDef(options.collapseLabel) ?
* @private
* @type {string}
*/
this.collapseLabel_ = goog.isDef(options.collapseLabel) ?
options.collapseLabel : '\u00AB'; options.collapseLabel : '\u00AB';
/** /**
* @private * @private
* @type {string} * @type {Node}
*/ */
this.label_ = goog.isDef(options.label) ? options.label : '\u00BB'; this.collapseLabel_ = /** @type {Node} */ (goog.isString(collapseLabel) ?
var label = goog.dom.createDom(goog.dom.TagName.SPAN, {}, goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) :
(this.collapsible_ && !this.collapsed_) ? collapseLabel);
this.collapseLabel_ : this.label_);
var label = goog.isDef(options.label) ? options.label : '\u00BB';
/** /**
* @private * @private
* @type {Element} * @type {Node}
*/ */
this.labelSpan_ = label; this.label_ = /** @type {Node} */ (goog.isString(label) ?
goog.dom.createDom(goog.dom.TagName.SPAN, {}, label) :
label);
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
this.collapseLabel_ : this.label_;
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
'type': 'button', 'type': 'button',
'title': tipLabel 'title': tipLabel
}, this.labelSpan_); }, activeLabel);
goog.events.listen(button, goog.events.EventType.CLICK, goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this); this.handleClick_, false, this);
@@ -427,8 +429,11 @@ ol.control.OverviewMap.prototype.handleClick_ = function(event) {
*/ */
ol.control.OverviewMap.prototype.handleToggle_ = function() { ol.control.OverviewMap.prototype.handleToggle_ = function() {
goog.dom.classlist.toggle(this.element, 'ol-collapsed'); goog.dom.classlist.toggle(this.element, 'ol-collapsed');
goog.dom.setTextContent(this.labelSpan_, if (this.collapsed_) {
(this.collapsed_) ? this.collapseLabel_ : this.label_); goog.dom.replaceNode(this.collapseLabel_, this.label_);
} else {
goog.dom.replaceNode(this.label_, this.collapseLabel_);
}
this.collapsed_ = !this.collapsed_; this.collapsed_ = !this.collapsed_;
// manage overview map if it had not been rendered before and control // manage overview map if it had not been rendered before and control

View File

@@ -1,6 +1,5 @@
goog.provide('ol.control.Rotate'); goog.provide('ol.control.Rotate');
goog.require('goog.asserts');
goog.require('goog.dom'); goog.require('goog.dom');
goog.require('goog.dom.TagName'); goog.require('goog.dom.TagName');
goog.require('goog.dom.classlist'); goog.require('goog.dom.classlist');
@@ -32,12 +31,22 @@ ol.control.Rotate = function(opt_options) {
var className = goog.isDef(options.className) ? var className = goog.isDef(options.className) ?
options.className : 'ol-rotate'; options.className : 'ol-rotate';
var label = goog.isDef(options.label) ?
options.label : '\u21E7';
/** /**
* @type {Element} * @type {Node}
* @private * @private
*/ */
this.label_ = goog.dom.createDom(goog.dom.TagName.SPAN, this.label_ = null;
'ol-compass', goog.isDef(options.label) ? options.label : '\u21E7');
if (goog.isString(label)) {
this.label_ = goog.dom.createDom(goog.dom.TagName.SPAN,
'ol-compass', label);
} else {
this.label_ = label;
goog.dom.classlist.add(this.label_, 'ol-compass');
}
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = goog.isDef(options.tipLabel) ?
options.tipLabel : 'Reset rotation'; options.tipLabel : 'Reset rotation';

View File

@@ -325,7 +325,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
++i; ++i;
} }
var html = count + suffix; var html = count + ' ' + suffix;
if (this.renderedHTML_ != html) { if (this.renderedHTML_ != html) {
this.innerElement_.innerHTML = html; this.innerElement_.innerHTML = html;
this.renderedHTML_ = html; this.renderedHTML_ = html;

View File

@@ -32,12 +32,13 @@ ol.control.ZoomToExtent = function(opt_options) {
var className = goog.isDef(options.className) ? options.className : var className = goog.isDef(options.className) ? options.className :
'ol-zoom-extent'; 'ol-zoom-extent';
var label = goog.isDef(options.label) ? options.label : 'E';
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = goog.isDef(options.tipLabel) ?
options.tipLabel : 'Fit to extent'; options.tipLabel : 'Fit to extent';
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
'type': 'button', 'type': 'button',
'title': tipLabel 'title': tipLabel
}); }, label);
goog.events.listen(button, goog.events.EventType.CLICK, goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this); this.handleClick_, false, this);

View File

@@ -78,7 +78,7 @@ ol.FeatureOverlay = function(opt_options) {
if (goog.isDef(options.features)) { if (goog.isDef(options.features)) {
if (goog.isArray(options.features)) { if (goog.isArray(options.features)) {
this.setFeatures(new ol.Collection(goog.array.clone(options.features))); this.setFeatures(new ol.Collection(options.features.slice()));
} else { } else {
goog.asserts.assertInstanceof(options.features, ol.Collection); goog.asserts.assertInstanceof(options.features, ol.Collection);
this.setFeatures(options.features); this.setFeatures(options.features);
@@ -112,6 +112,15 @@ ol.FeatureOverlay.prototype.getFeatures = function() {
}; };
/**
* @return {?ol.Map} The map with which this feature overlay is associated.
* @api
*/
ol.FeatureOverlay.prototype.getMap = function() {
return this.map_;
};
/** /**
* @private * @private
*/ */

View File

@@ -1,6 +1,5 @@
goog.provide('ol.format.Feature'); goog.provide('ol.format.Feature');
goog.require('goog.array');
goog.require('ol.geom.Geometry'); goog.require('ol.geom.Geometry');
goog.require('ol.proj'); goog.require('ol.proj');
@@ -41,8 +40,7 @@ ol.format.Feature.prototype.getExtensions = goog.abstractMethod;
* @return {olx.format.ReadOptions|undefined} Options. * @return {olx.format.ReadOptions|undefined} Options.
* @protected * @protected
*/ */
ol.format.Feature.prototype.getReadOptions = function( ol.format.Feature.prototype.getReadOptions = function(source, opt_options) {
source, opt_options) {
var options; var options;
if (goog.isDef(opt_options)) { if (goog.isDef(opt_options)) {
options = { options = {
@@ -64,8 +62,7 @@ ol.format.Feature.prototype.getReadOptions = function(
* @return {olx.format.WriteOptions|olx.format.ReadOptions|undefined} * @return {olx.format.WriteOptions|olx.format.ReadOptions|undefined}
* Updated options. * Updated options.
*/ */
ol.format.Feature.prototype.adaptOptions = function( ol.format.Feature.prototype.adaptOptions = function(options) {
options) {
var updatedOptions; var updatedOptions;
if (goog.isDef(options)) { if (goog.isDef(options)) {
updatedOptions = { updatedOptions = {
@@ -177,7 +174,7 @@ ol.format.Feature.transformWithOptions = function(
// FIXME this is necessary because ol.format.GML treats extents // FIXME this is necessary because ol.format.GML treats extents
// as geometries // as geometries
return ol.proj.transformExtent( return ol.proj.transformExtent(
write ? goog.array.clone(geometry) : geometry, write ? geometry.slice() : geometry,
write ? featureProjection : dataProjection, write ? featureProjection : dataProjection,
write ? dataProjection : featureProjection); write ? dataProjection : featureProjection);
} }

View File

@@ -64,7 +64,7 @@ ol.format.GeoJSON.EXTENSIONS_ = ['.geojson'];
/** /**
* @param {GeoJSONObject} object Object. * @param {GeoJSONGeometry|GeoJSONGeometryCollection} object Object.
* @param {olx.format.ReadOptions=} opt_options Read options. * @param {olx.format.ReadOptions=} opt_options Read options.
* @private * @private
* @return {ol.geom.Geometry} Geometry. * @return {ol.geom.Geometry} Geometry.
@@ -92,7 +92,7 @@ ol.format.GeoJSON.readGeometryCollectionGeometry_ = function(
goog.asserts.assert(object.type == 'GeometryCollection'); goog.asserts.assert(object.type == 'GeometryCollection');
var geometries = goog.array.map(object.geometries, var geometries = goog.array.map(object.geometries,
/** /**
* @param {GeoJSONObject} geometry Geometry. * @param {GeoJSONGeometry} geometry Geometry.
* @return {ol.geom.Geometry} geometry Geometry. * @return {ol.geom.Geometry} geometry Geometry.
*/ */
function(geometry) { function(geometry) {
@@ -505,18 +505,17 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(
}; };
var id = feature.getId(); var id = feature.getId();
if (goog.isDefAndNotNull(id)) { if (goog.isDefAndNotNull(id)) {
goog.object.set(object, 'id', id); object['id'] = id;
} }
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (goog.isDefAndNotNull(geometry)) { if (goog.isDefAndNotNull(geometry)) {
goog.object.set( object['geometry'] =
object, 'geometry', ol.format.GeoJSON.writeGeometry_(geometry, opt_options);
ol.format.GeoJSON.writeGeometry_(geometry, opt_options));
} }
var properties = feature.getProperties(); var properties = feature.getProperties();
goog.object.remove(properties, feature.getGeometryName()); goog.object.remove(properties, feature.getGeometryName());
if (!goog.object.isEmpty(properties)) { if (!goog.object.isEmpty(properties)) {
goog.object.set(object, 'properties', properties); object['properties'] = properties;
} }
return object; return object;
}; };

View File

@@ -1,9 +1,7 @@
goog.provide('ol.format.GML2'); goog.provide('ol.format.GML2');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.NodeType'); goog.require('goog.dom.NodeType');
goog.require('goog.object');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.format.GML'); goog.require('ol.format.GML');
goog.require('ol.format.GMLBase'); goog.require('ol.format.GMLBase');
@@ -44,8 +42,8 @@ goog.inherits(ol.format.GML2, ol.format.GMLBase);
* @type {string} * @type {string}
* @private * @private
*/ */
ol.format.GML2.schemaLocation_ = 'http://www.opengis.net/gml ' + ol.format.GML2.schemaLocation_ = ol.format.GMLBase.GMLNS +
'http://schemas.opengis.net/gml/2.1.2/feature.xsd'; ' http://schemas.opengis.net/gml/2.1.2/feature.xsd';
/** /**
@@ -58,7 +56,7 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, ''); var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var context = objectStack[0]; var context = objectStack[0];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var containerSrs = goog.object.get(context, 'srsName'); var containerSrs = context['srsName'];
var containerDimension = node.parentNode.getAttribute('srsDimension'); var containerDimension = node.parentNode.getAttribute('srsDimension');
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (!goog.isNull(containerSrs)) { if (!goog.isNull(containerSrs)) {

View File

@@ -3,7 +3,6 @@ goog.provide('ol.format.GML3');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.NodeType'); goog.require('goog.dom.NodeType');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol.Feature'); goog.require('ol.Feature');
@@ -84,8 +83,8 @@ goog.inherits(ol.format.GML3, ol.format.GMLBase);
* @type {string} * @type {string}
* @private * @private
*/ */
ol.format.GML3.schemaLocation_ = 'http://www.opengis.net/gml ' + ol.format.GML3.schemaLocation_ = ol.format.GMLBase.GMLNS +
'http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' + ' http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/' +
'1.0.0/gmlsf.xsd'; '1.0.0/gmlsf.xsd';
@@ -356,7 +355,7 @@ ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) {
} }
var context = objectStack[0]; var context = objectStack[0];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var containerSrs = goog.object.get(context, 'srsName'); var containerSrs = context['srsName'];
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (!goog.isNull(containerSrs)) { if (!goog.isNull(containerSrs)) {
var proj = ol.proj.get(containerSrs); var proj = ol.proj.get(containerSrs);
@@ -392,7 +391,7 @@ ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) {
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, ''); var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var context = objectStack[0]; var context = objectStack[0];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var containerSrs = goog.object.get(context, 'srsName'); var containerSrs = context['srsName'];
var containerDimension = node.parentNode.getAttribute('srsDimension'); var containerDimension = node.parentNode.getAttribute('srsDimension');
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (!goog.isNull(containerSrs)) { if (!goog.isNull(containerSrs)) {
@@ -614,7 +613,7 @@ ol.format.GML3.prototype.SEGMENTS_PARSERS_ = Object({
ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) { ol.format.GML3.prototype.writePos_ = function(node, value, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (goog.isDefAndNotNull(srsName)) { if (goog.isDefAndNotNull(srsName)) {
axisOrientation = ol.proj.get(srsName).getAxisOrientation(); axisOrientation = ol.proj.get(srsName).getAxisOrientation();
@@ -657,7 +656,7 @@ ol.format.GML3.prototype.getCoords_ = function(point, opt_srsName) {
ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) { ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
// only 2d for simple features profile // only 2d for simple features profile
var points = value.getCoordinates(); var points = value.getCoordinates();
var len = points.length; var len = points.length;
@@ -680,7 +679,7 @@ ol.format.GML3.prototype.writePosList_ = function(node, value, objectStack) {
ol.format.GML3.prototype.writePoint_ = function(node, geometry, objectStack) { ol.format.GML3.prototype.writePoint_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
if (goog.isDefAndNotNull(srsName)) { if (goog.isDefAndNotNull(srsName)) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
@@ -711,7 +710,7 @@ ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) {
goog.asserts.assert(extent.length == 4); goog.asserts.assert(extent.length == 4);
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
if (goog.isDef(srsName)) { if (goog.isDef(srsName)) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
@@ -735,7 +734,7 @@ ol.format.GML3.prototype.writeLinearRing_ =
function(node, geometry, objectStack) { function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
if (goog.isDefAndNotNull(srsName)) { if (goog.isDefAndNotNull(srsName)) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
@@ -757,9 +756,9 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ =
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
var parentNode = context.node; var parentNode = context.node;
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var exteriorWritten = goog.object.get(context, 'exteriorWritten'); var exteriorWritten = context['exteriorWritten'];
if (!goog.isDef(exteriorWritten)) { if (!goog.isDef(exteriorWritten)) {
goog.object.set(context, 'exteriorWritten', true); context['exteriorWritten'] = true;
} }
return ol.xml.createElementNS(parentNode.namespaceURI, return ol.xml.createElementNS(parentNode.namespaceURI,
goog.isDef(exteriorWritten) ? 'interior' : 'exterior'); goog.isDef(exteriorWritten) ? 'interior' : 'exterior');
@@ -776,7 +775,7 @@ ol.format.GML3.prototype.writeSurfaceOrPolygon_ =
function(node, geometry, objectStack) { function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
if (node.nodeName !== 'PolygonPatch' && goog.isDefAndNotNull(srsName)) { if (node.nodeName !== 'PolygonPatch' && goog.isDefAndNotNull(srsName)) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
@@ -806,7 +805,7 @@ ol.format.GML3.prototype.writeCurveOrLineString_ =
function(node, geometry, objectStack) { function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
if (node.nodeName !== 'LineStringSegment' && if (node.nodeName !== 'LineStringSegment' &&
goog.isDefAndNotNull(srsName)) { goog.isDefAndNotNull(srsName)) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
@@ -835,8 +834,8 @@ ol.format.GML3.prototype.writeMultiSurfaceOrPolygon_ =
function(node, geometry, objectStack) { function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
var surface = goog.object.get(context, 'surface'); var surface = context['surface'];
if (goog.isDefAndNotNull(srsName)) { if (goog.isDefAndNotNull(srsName)) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
@@ -858,7 +857,7 @@ ol.format.GML3.prototype.writeMultiPoint_ = function(node, geometry,
objectStack) { objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
if (goog.isDefAndNotNull(srsName)) { if (goog.isDefAndNotNull(srsName)) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
@@ -880,8 +879,8 @@ ol.format.GML3.prototype.writeMultiCurveOrLineString_ =
function(node, geometry, objectStack) { function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
var curve = goog.object.get(context, 'curve'); var curve = context['curve'];
if (goog.isDefAndNotNull(srsName)) { if (goog.isDefAndNotNull(srsName)) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
@@ -1030,7 +1029,7 @@ ol.format.GML3.prototype.writeFeatureElement =
} }
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var featureNS = goog.object.get(context, 'featureNS'); var featureNS = context['featureNS'];
var geometryName = feature.getGeometryName(); var geometryName = feature.getGeometryName();
if (!goog.isDef(context.serializers)) { if (!goog.isDef(context.serializers)) {
context.serializers = {}; context.serializers = {};
@@ -1076,8 +1075,8 @@ ol.format.GML3.prototype.writeFeatureMembers_ =
function(node, features, objectStack) { function(node, features, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var featureType = goog.object.get(context, 'featureType'); var featureType = context['featureType'];
var featureNS = goog.object.get(context, 'featureNS'); var featureNS = context['featureNS'];
var serializers = {}; var serializers = {};
serializers[featureNS] = {}; serializers[featureNS] = {};
serializers[featureNS][featureType] = ol.xml.makeChildAppender( serializers[featureNS][featureType] = ol.xml.makeChildAppender(
@@ -1219,10 +1218,10 @@ ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ =
function(value, objectStack, opt_nodeName) { function(value, objectStack, opt_nodeName) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var multiSurface = goog.object.get(context, 'multiSurface'); var multiSurface = context['multiSurface'];
var surface = goog.object.get(context, 'surface'); var surface = context['surface'];
var curve = goog.object.get(context, 'curve'); var curve = context['curve'];
var multiCurve = goog.object.get(context, 'multiCurve'); var multiCurve = context['multiCurve'];
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
goog.asserts.assert(ol.xml.isNode(parentNode)); goog.asserts.assert(ol.xml.isNode(parentNode));
var nodeName; var nodeName;
@@ -1343,7 +1342,7 @@ ol.format.GML.prototype.writeFeatures;
* Encode an array of features in the GML 3.1.1 format as an XML node. * Encode an array of features in the GML 3.1.1 format as an XML node.
* *
* @function * @function
* @param {ol.Feature} feature Feature. * @param {Array.<ol.Feature>} features Features.
* @param {olx.format.WriteOptions=} opt_options Options. * @param {olx.format.WriteOptions=} opt_options Options.
* @return {Node} Node. * @return {Node} Node.
* @api * @api

View File

@@ -5,7 +5,6 @@ goog.provide('ol.format.GMLBase');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.NodeType'); goog.require('goog.dom.NodeType');
goog.require('goog.object'); goog.require('goog.object');
goog.require('goog.string'); goog.require('goog.string');
@@ -68,18 +67,35 @@ ol.format.GMLBase = function(opt_options) {
*/ */
this.schemaLocation = ''; this.schemaLocation = '';
/**
* @type {Object.<string, Object.<string, Object>>}
*/
this.FEATURE_COLLECTION_PARSERS = {};
this.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS] = {
'featureMember': ol.xml.makeReplacer(
ol.format.GMLBase.prototype.readFeaturesInternal),
'featureMembers': ol.xml.makeReplacer(
ol.format.GMLBase.prototype.readFeaturesInternal)
};
goog.base(this); goog.base(this);
}; };
goog.inherits(ol.format.GMLBase, ol.format.XMLFeature); goog.inherits(ol.format.GMLBase, ol.format.XMLFeature);
/**
* @const
* @type {string}
*/
ol.format.GMLBase.GMLNS = 'http://www.opengis.net/gml';
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
* @return {Array.<ol.Feature>} Features. * @return {Array.<ol.Feature>} Features.
* @private
*/ */
ol.format.GMLBase.prototype.readFeatures_ = function(node, objectStack) { ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
var localName = ol.xml.getLocalName(node); var localName = ol.xml.getLocalName(node);
var features; var features;
@@ -90,19 +106,19 @@ ol.format.GMLBase.prototype.readFeatures_ = function(node, objectStack) {
} else if (localName == 'featureMembers' || localName == 'featureMember') { } else if (localName == 'featureMembers' || localName == 'featureMember') {
var context = objectStack[0]; var context = objectStack[0];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var featureType = goog.object.get(context, 'featureType'); var featureType = context['featureType'];
if (!goog.isDef(featureType) && !goog.isNull(node.firstElementChild)) { if (!goog.isDef(featureType) && !goog.isNull(node.firstElementChild)) {
var member = node.firstElementChild; var member = node.firstElementChild;
featureType = member.nodeName.split(':').pop(); featureType = member.nodeName.split(':').pop();
goog.object.set(context, 'featureType', featureType); context['featureType'] = featureType;
goog.object.set(context, 'featureNS', member.namespaceURI); context['featureNS'] = member.namespaceURI;
} }
var parsers = {}; var parsers = {};
var parsersNS = {}; var parsersNS = {};
parsers[featureType] = (localName == 'featureMembers') ? parsers[featureType] = (localName == 'featureMembers') ?
ol.xml.makeArrayPusher(this.readFeatureElement, this) : ol.xml.makeArrayPusher(this.readFeatureElement, this) :
ol.xml.makeReplacer(this.readFeatureElement, this); ol.xml.makeReplacer(this.readFeatureElement, this);
parsersNS[goog.object.get(context, 'featureNS')] = parsers; parsersNS[context['featureNS']] = parsers;
features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack); features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack);
} }
if (!goog.isDef(features)) { if (!goog.isDef(features)) {
@@ -112,19 +128,6 @@ ol.format.GMLBase.prototype.readFeatures_ = function(node, objectStack) {
}; };
/**
* @type {Object.<string, Object.<string, Object>>}
*/
ol.format.GMLBase.prototype.FEATURE_COLLECTION_PARSERS = Object({
'http://www.opengis.net/gml': {
'featureMember': ol.xml.makeArrayPusher(
ol.format.GMLBase.prototype.readFeatures_),
'featureMembers': ol.xml.makeReplacer(
ol.format.GMLBase.prototype.readFeatures_)
}
});
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
@@ -133,8 +136,7 @@ ol.format.GMLBase.prototype.FEATURE_COLLECTION_PARSERS = Object({
ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) { ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) {
var context = objectStack[0]; var context = objectStack[0];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
goog.object.set(context, 'srsName', context['srsName'] = node.firstElementChild.getAttribute('srsName');
node.firstElementChild.getAttribute('srsName'));
var geometry = ol.xml.pushParseAndPop(/** @type {ol.geom.Geometry} */(null), var geometry = ol.xml.pushParseAndPop(/** @type {ol.geom.Geometry} */(null),
this.GEOMETRY_PARSERS_, node, objectStack, this); this.GEOMETRY_PARSERS_, node, objectStack, this);
if (goog.isDefAndNotNull(geometry)) { if (goog.isDefAndNotNull(geometry)) {
@@ -154,7 +156,7 @@ ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) {
ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) { ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
var n; var n;
var fid = node.getAttribute('fid') || var fid = node.getAttribute('fid') ||
ol.xml.getAttributeNS(node, 'http://www.opengis.net/gml', 'id'); ol.xml.getAttributeNS(node, ol.format.GMLBase.GMLNS, 'id');
var values = {}, geometryName; var values = {}, geometryName;
for (n = node.firstElementChild; !goog.isNull(n); for (n = node.firstElementChild; !goog.isNull(n);
n = n.nextElementSibling) { n = n.nextElementSibling) {
@@ -550,7 +552,7 @@ ol.format.GMLBase.prototype.readFeaturesFromNode =
if (goog.isDef(opt_options)) { if (goog.isDef(opt_options)) {
goog.object.extend(options, this.getReadOptions(node, opt_options)); goog.object.extend(options, this.getReadOptions(node, opt_options));
} }
return this.readFeatures_(node, [options]); return this.readFeaturesInternal(node, [options]);
}; };

View File

@@ -71,14 +71,14 @@ ol.format.GPX.appendCoordinate_ = function(flatCoordinates, node, values) {
parseFloat(node.getAttribute('lat'))); parseFloat(node.getAttribute('lat')));
if (goog.object.containsKey(values, 'ele')) { if (goog.object.containsKey(values, 'ele')) {
flatCoordinates.push( flatCoordinates.push(
/** @type {number} */ (goog.object.get(values, 'ele'))); /** @type {number} */ (values['ele']));
goog.object.remove(values, 'ele'); goog.object.remove(values, 'ele');
} else { } else {
flatCoordinates.push(0); flatCoordinates.push(0);
} }
if (goog.object.containsKey(values, 'time')) { if (goog.object.containsKey(values, 'time')) {
flatCoordinates.push( flatCoordinates.push(
/** @type {number} */ (goog.object.get(values, 'time'))); /** @type {number} */ (values['time']));
goog.object.remove(values, 'time'); goog.object.remove(values, 'time');
} else { } else {
flatCoordinates.push(0); flatCoordinates.push(0);
@@ -98,7 +98,7 @@ ol.format.GPX.parseLink_ = function(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var href = node.getAttribute('href'); var href = node.getAttribute('href');
if (!goog.isNull(href)) { if (!goog.isNull(href)) {
goog.object.set(values, 'link', href); values['link'] = href;
} }
ol.xml.parseNode(ol.format.GPX.LINK_PARSERS_, node, objectStack); ol.xml.parseNode(ol.format.GPX.LINK_PARSERS_, node, objectStack);
}; };
@@ -113,7 +113,7 @@ ol.format.GPX.parseExtensions_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'extensions'); goog.asserts.assert(node.localName == 'extensions');
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
goog.object.set(values, 'extensionsNode_', node); values['extensionsNode_'] = node;
}; };
@@ -130,7 +130,7 @@ ol.format.GPX.parseRtePt_ = function(node, objectStack) {
if (goog.isDef(values)) { if (goog.isDef(values)) {
var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
(goog.object.get(rteValues, 'flatCoordinates')); (rteValues['flatCoordinates']);
ol.format.GPX.appendCoordinate_(flatCoordinates, node, values); ol.format.GPX.appendCoordinate_(flatCoordinates, node, values);
} }
}; };
@@ -149,7 +149,7 @@ ol.format.GPX.parseTrkPt_ = function(node, objectStack) {
if (goog.isDef(values)) { if (goog.isDef(values)) {
var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
(goog.object.get(trkValues, 'flatCoordinates')); (trkValues['flatCoordinates']);
ol.format.GPX.appendCoordinate_(flatCoordinates, node, values); ol.format.GPX.appendCoordinate_(flatCoordinates, node, values);
} }
}; };
@@ -166,8 +166,8 @@ ol.format.GPX.parseTrkSeg_ = function(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
ol.xml.parseNode(ol.format.GPX.TRKSEG_PARSERS_, node, objectStack); ol.xml.parseNode(ol.format.GPX.TRKSEG_PARSERS_, node, objectStack);
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
(goog.object.get(values, 'flatCoordinates')); (values['flatCoordinates']);
var ends = /** @type {Array.<number>} */ (goog.object.get(values, 'ends')); var ends = /** @type {Array.<number>} */ (values['ends']);
ends.push(flatCoordinates.length); ends.push(flatCoordinates.length);
}; };
@@ -189,7 +189,7 @@ ol.format.GPX.readRte_ = function(node, objectStack) {
return undefined; return undefined;
} }
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
(goog.object.get(values, 'flatCoordinates')); (values['flatCoordinates']);
goog.object.remove(values, 'flatCoordinates'); goog.object.remove(values, 'flatCoordinates');
var geometry = new ol.geom.LineString(null); var geometry = new ol.geom.LineString(null);
geometry.setFlatCoordinates(ol.geom.GeometryLayout.XYZM, flatCoordinates); geometry.setFlatCoordinates(ol.geom.GeometryLayout.XYZM, flatCoordinates);
@@ -218,9 +218,9 @@ ol.format.GPX.readTrk_ = function(node, objectStack) {
return undefined; return undefined;
} }
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
(goog.object.get(values, 'flatCoordinates')); (values['flatCoordinates']);
goog.object.remove(values, 'flatCoordinates'); goog.object.remove(values, 'flatCoordinates');
var ends = /** @type {Array.<number>} */ (goog.object.get(values, 'ends')); var ends = /** @type {Array.<number>} */ (values['ends']);
goog.object.remove(values, 'ends'); goog.object.remove(values, 'ends');
var geometry = new ol.geom.MultiLineString(null); var geometry = new ol.geom.MultiLineString(null);
geometry.setFlatCoordinates( geometry.setFlatCoordinates(
@@ -501,22 +501,6 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) {
ol.format.GPX.prototype.readProjection; ol.format.GPX.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.GPX.prototype.readProjectionFromDocument = function(doc) {
return this.defaultDataProjection;
};
/**
* @inheritDoc
*/
ol.format.GPX.prototype.readProjectionFromNode = function(node) {
return this.defaultDataProjection;
};
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {string} value Value for the link's `href` attribute. * @param {string} value Value for the link's `href` attribute.
@@ -527,10 +511,10 @@ ol.format.GPX.writeLink_ = function(node, value, objectStack) {
node.setAttribute('href', value); node.setAttribute('href', value);
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var properties = goog.object.get(context, 'properties'); var properties = context['properties'];
var link = [ var link = [
goog.object.get(properties, 'linkText'), properties['linkText'],
goog.object.get(properties, 'linkType') properties['linkType']
]; ];
ol.xml.pushSerializeAndPop(/** @type {ol.xml.NodeStackItem} */ ({node: node}), ol.xml.pushSerializeAndPop(/** @type {ol.xml.NodeStackItem} */ ({node: node}),
ol.format.GPX.LINK_SERIALIZERS_, ol.xml.OBJECT_PROPERTY_NODE_FACTORY, ol.format.GPX.LINK_SERIALIZERS_, ol.xml.OBJECT_PROPERTY_NODE_FACTORY,
@@ -550,25 +534,25 @@ ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) {
var parentNode = context.node; var parentNode = context.node;
goog.asserts.assert(ol.xml.isNode(parentNode)); goog.asserts.assert(ol.xml.isNode(parentNode));
var namespaceURI = parentNode.namespaceURI; var namespaceURI = parentNode.namespaceURI;
var properties = goog.object.get(context, 'properties'); var properties = context['properties'];
//FIXME Projection handling //FIXME Projection handling
ol.xml.setAttributeNS(node, null, 'lat', coordinate[1]); ol.xml.setAttributeNS(node, null, 'lat', coordinate[1]);
ol.xml.setAttributeNS(node, null, 'lon', coordinate[0]); ol.xml.setAttributeNS(node, null, 'lon', coordinate[0]);
var geometryLayout = goog.object.get(context, 'geometryLayout'); var geometryLayout = context['geometryLayout'];
/* jshint -W086 */ /* jshint -W086 */
switch (geometryLayout) { switch (geometryLayout) {
case ol.geom.GeometryLayout.XYZM: case ol.geom.GeometryLayout.XYZM:
if (coordinate[3] !== 0) { if (coordinate[3] !== 0) {
goog.object.set(properties, 'time', coordinate[3]); properties['time'] = coordinate[3];
} }
case ol.geom.GeometryLayout.XYZ: case ol.geom.GeometryLayout.XYZ:
if (coordinate[2] !== 0) { if (coordinate[2] !== 0) {
goog.object.set(properties, 'ele', coordinate[2]); properties['ele'] = coordinate[2];
} }
break; break;
case ol.geom.GeometryLayout.XYM: case ol.geom.GeometryLayout.XYM:
if (coordinate[2] !== 0) { if (coordinate[2] !== 0) {
goog.object.set(properties, 'time', coordinate[2]); properties['time'] = coordinate[2];
} }
} }
/* jshint +W086 */ /* jshint +W086 */
@@ -596,8 +580,8 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) {
goog.asserts.assertInstanceof(geometry, ol.geom.LineString); goog.asserts.assertInstanceof(geometry, ol.geom.LineString);
geometry = /** @type {ol.geom.LineString} */ geometry = /** @type {ol.geom.LineString} */
(ol.format.Feature.transformWithOptions(geometry, true, options)); (ol.format.Feature.transformWithOptions(geometry, true, options));
goog.object.set(context, 'geometryLayout', geometry.getLayout()); context['geometryLayout'] = geometry.getLayout();
goog.object.set(properties, 'rtept', geometry.getCoordinates()); properties['rtept'] = geometry.getCoordinates();
} }
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = ol.format.GPX.RTE_SEQUENCE_[parentNode.namespaceURI]; var orderedKeys = ol.format.GPX.RTE_SEQUENCE_[parentNode.namespaceURI];
@@ -623,7 +607,7 @@ ol.format.GPX.writeTrk_ = function(node, feature, objectStack) {
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString); goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString);
geometry = /** @type {ol.geom.MultiLineString} */ geometry = /** @type {ol.geom.MultiLineString} */
(ol.format.Feature.transformWithOptions(geometry, true, options)); (ol.format.Feature.transformWithOptions(geometry, true, options));
goog.object.set(properties, 'trkseg', geometry.getLineStrings()); properties['trkseg'] = geometry.getLineStrings();
} }
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = ol.format.GPX.TRK_SEQUENCE_[parentNode.namespaceURI]; var orderedKeys = ol.format.GPX.TRK_SEQUENCE_[parentNode.namespaceURI];
@@ -659,13 +643,13 @@ ol.format.GPX.writeWpt_ = function(node, feature, objectStack) {
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]); var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
goog.object.set(context, 'properties', feature.getProperties()); context['properties'] = feature.getProperties();
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (goog.isDef(geometry)) { if (goog.isDef(geometry)) {
goog.asserts.assertInstanceof(geometry, ol.geom.Point); goog.asserts.assertInstanceof(geometry, ol.geom.Point);
geometry = /** @type {ol.geom.Point} */ geometry = /** @type {ol.geom.Point} */
(ol.format.Feature.transformWithOptions(geometry, true, options)); (ol.format.Feature.transformWithOptions(geometry, true, options));
goog.object.set(context, 'geometryLayout', geometry.getLayout()); context['geometryLayout'] = geometry.getLayout();
ol.format.GPX.writeWptType_(node, geometry.getCoordinates(), objectStack); ol.format.GPX.writeWptType_(node, geometry.getCoordinates(), objectStack);
} }
}; };
@@ -754,10 +738,7 @@ ol.format.GPX.TRK_SERIALIZERS_ = ol.xml.makeStructureNS(
/** /**
* @const * @const
* @param {*} value Value. * @type {function(*, Array.<*>, string=): (Node|undefined)}
* @param {Array.<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @return {Node|undefined} Node.
* @private * @private
*/ */
ol.format.GPX.TRKSEG_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('trkpt'); ol.format.GPX.TRKSEG_NODE_FACTORY_ = ol.xml.makeSimpleNodeFactory('trkpt');

View File

@@ -218,11 +218,3 @@ ol.format.IGC.prototype.readFeaturesFromText = function(text, opt_options) {
* @api * @api
*/ */
ol.format.IGC.prototype.readProjection; ol.format.IGC.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.IGC.prototype.readProjectionFromText = function(text) {
return this.defaultDataProjection;
};

View File

@@ -208,7 +208,7 @@ ol.format.KML.DEFAULT_FILL_STYLE_ = new ol.style.Fill({
* @type {ol.Size} * @type {ol.Size}
* @private * @private
*/ */
ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_ = [2, 20]; // FIXME maybe [8, 32] ? ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_ = [20, 2]; // FIXME maybe [8, 32] ?
/** /**
@@ -234,7 +234,7 @@ ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ =
* @type {ol.Size} * @type {ol.Size}
* @private * @private
*/ */
ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_ = [32, 32]; ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_ = [64, 64];
/** /**
@@ -253,11 +253,12 @@ ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_ =
*/ */
ol.format.KML.DEFAULT_IMAGE_STYLE_ = new ol.style.Icon({ ol.format.KML.DEFAULT_IMAGE_STYLE_ = new ol.style.Icon({
anchor: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_, anchor: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_,
anchorOrigin: ol.style.IconOrigin.BOTTOM_LEFT,
anchorXUnits: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_, anchorXUnits: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_,
anchorYUnits: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_, anchorYUnits: ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_,
crossOrigin: 'anonymous', crossOrigin: 'anonymous',
rotation: 0, rotation: 0,
scale: 1, scale: 0.5,
size: ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_, size: ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_,
src: ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_ src: ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_
}); });
@@ -472,7 +473,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
var IconObject = /** @type {Object} */ (goog.object.get(object, 'Icon', {})); var IconObject = /** @type {Object} */ (goog.object.get(object, 'Icon', {}));
var src; var src;
var href = /** @type {string|undefined} */ var href = /** @type {string|undefined} */
(goog.object.get(IconObject, 'href')); (IconObject['href']);
if (goog.isDef(href)) { if (goog.isDef(href)) {
src = href; src = href;
} else { } else {
@@ -480,7 +481,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
} }
var anchor, anchorXUnits, anchorYUnits; var anchor, anchorXUnits, anchorYUnits;
var hotSpot = /** @type {ol.format.KMLVec2_|undefined} */ var hotSpot = /** @type {ol.format.KMLVec2_|undefined} */
(goog.object.get(object, 'hotSpot')); (object['hotSpot']);
if (goog.isDef(hotSpot)) { if (goog.isDef(hotSpot)) {
anchor = [hotSpot.x, hotSpot.y]; anchor = [hotSpot.x, hotSpot.y];
anchorXUnits = hotSpot.xunits; anchorXUnits = hotSpot.xunits;
@@ -497,31 +498,31 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
var offset; var offset;
var x = /** @type {number|undefined} */ var x = /** @type {number|undefined} */
(goog.object.get(IconObject, 'x')); (IconObject['x']);
var y = /** @type {number|undefined} */ var y = /** @type {number|undefined} */
(goog.object.get(IconObject, 'y')); (IconObject['y']);
if (goog.isDef(x) && goog.isDef(y)) { if (goog.isDef(x) && goog.isDef(y)) {
offset = [x, y]; offset = [x, y];
} }
var size; var size;
var w = /** @type {number|undefined} */ var w = /** @type {number|undefined} */
(goog.object.get(IconObject, 'w')); (IconObject['w']);
var h = /** @type {number|undefined} */ var h = /** @type {number|undefined} */
(goog.object.get(IconObject, 'h')); (IconObject['h']);
if (goog.isDef(w) && goog.isDef(h)) { if (goog.isDef(w) && goog.isDef(h)) {
size = [w, h]; size = [w, h];
} }
var rotation; var rotation;
var heading = /** @type {number|undefined} */ var heading = /** @type {number|undefined} */
(goog.object.get(object, 'heading')); (object['heading']);
if (goog.isDef(heading)) { if (goog.isDef(heading)) {
rotation = goog.math.toRadians(heading); rotation = goog.math.toRadians(heading);
} }
var scale = /** @type {number|undefined} */ var scale = /** @type {number|undefined} */
(goog.object.get(object, 'scale')); (object['scale']);
if (src == ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_) { if (src == ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_) {
size = ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_; size = ol.format.KML.DEFAULT_IMAGE_STYLE_SIZE_;
} }
@@ -539,7 +540,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
size: size, size: size,
src: src src: src
}); });
goog.object.set(styleObject, 'imageStyle', imageStyle); styleObject['imageStyle'] = imageStyle;
}; };
@@ -565,9 +566,9 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
(goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_)) (goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_))
}), }),
scale: /** @type {number|undefined} */ scale: /** @type {number|undefined} */
(goog.object.get(object, 'scale')) (object['scale'])
}); });
goog.object.set(styleObject, 'textStyle', textStyle); styleObject['textStyle'] = textStyle;
}; };
@@ -596,7 +597,7 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
(goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_)), (goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_)),
width: /** @type {number} */ (goog.object.get(object, 'width', 1)) width: /** @type {number} */ (goog.object.get(object, 'width', 1))
}); });
goog.object.set(styleObject, 'strokeStyle', strokeStyle); styleObject['strokeStyle'] = strokeStyle;
}; };
@@ -620,15 +621,15 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
color: /** @type {ol.Color} */ color: /** @type {ol.Color} */
(goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_)) (goog.object.get(object, 'color', ol.format.KML.DEFAULT_COLOR_))
}); });
goog.object.set(styleObject, 'fillStyle', fillStyle); styleObject['fillStyle'] = fillStyle;
var fill = /** @type {boolean|undefined} */ (goog.object.get(object, 'fill')); var fill = /** @type {boolean|undefined} */ (object['fill']);
if (goog.isDef(fill)) { if (goog.isDef(fill)) {
goog.object.set(styleObject, 'fill', fill); styleObject['fill'] = fill;
} }
var outline = var outline =
/** @type {boolean|undefined} */ (goog.object.get(object, 'outline')); /** @type {boolean|undefined} */ (object['outline']);
if (goog.isDef(outline)) { if (goog.isDef(outline)) {
goog.object.set(styleObject, 'outline', outline); styleObject['outline'] = outline;
} }
}; };
@@ -944,7 +945,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get( var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get(
styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_)); styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_));
var fill = /** @type {boolean|undefined} */ var fill = /** @type {boolean|undefined} */
(goog.object.get(styleObject, 'fill')); (styleObject['fill']);
if (goog.isDef(fill) && !fill) { if (goog.isDef(fill) && !fill) {
fillStyle = null; fillStyle = null;
} }
@@ -955,7 +956,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
var strokeStyle = /** @type {ol.style.Stroke} */ (goog.object.get( var strokeStyle = /** @type {ol.style.Stroke} */ (goog.object.get(
styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_)); styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_));
var outline = /** @type {boolean|undefined} */ var outline = /** @type {boolean|undefined} */
(goog.object.get(styleObject, 'outline')); (styleObject['outline']);
if (goog.isDef(outline) && !outline) { if (goog.isDef(outline) && !outline) {
strokeStyle = null; strokeStyle = null;
} }
@@ -985,7 +986,7 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
var featureObject = var featureObject =
/** @type {Object} */ (objectStack[objectStack.length - 1]); /** @type {Object} */ (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isObject(featureObject)); goog.asserts.assert(goog.isObject(featureObject));
goog.object.set(featureObject, name, data); featureObject[name] = data;
} }
} }
}; };
@@ -1017,15 +1018,15 @@ ol.format.KML.PairDataParser_ = function(node, objectStack) {
return; return;
} }
var key = /** @type {string|undefined} */ var key = /** @type {string|undefined} */
(goog.object.get(pairObject, 'key')); (pairObject['key']);
if (goog.isDef(key) && key == 'normal') { if (goog.isDef(key) && key == 'normal') {
var styleUrl = /** @type {string|undefined} */ var styleUrl = /** @type {string|undefined} */
(goog.object.get(pairObject, 'styleUrl')); (pairObject['styleUrl']);
if (goog.isDef(styleUrl)) { if (goog.isDef(styleUrl)) {
objectStack[objectStack.length - 1] = styleUrl; objectStack[objectStack.length - 1] = styleUrl;
} }
var Style = /** @type {ol.style.Style} */ var Style = /** @type {ol.style.Style} */
(goog.object.get(pairObject, 'Style')); (pairObject['Style']);
if (goog.isDef(Style)) { if (goog.isDef(Style)) {
objectStack[objectStack.length - 1] = Style; objectStack[objectStack.length - 1] = Style;
} }
@@ -1048,9 +1049,9 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
var placemarkObject = objectStack[objectStack.length - 1]; var placemarkObject = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(placemarkObject)); goog.asserts.assert(goog.isObject(placemarkObject));
if (goog.isArray(styleMapValue)) { if (goog.isArray(styleMapValue)) {
goog.object.set(placemarkObject, 'Style', styleMapValue); placemarkObject['Style'] = styleMapValue;
} else if (goog.isString(styleMapValue)) { } else if (goog.isString(styleMapValue)) {
goog.object.set(placemarkObject, 'styleUrl', styleMapValue); placemarkObject['styleUrl'] = styleMapValue;
} else { } else {
goog.asserts.fail(); goog.asserts.fail();
} }
@@ -1082,7 +1083,7 @@ ol.format.KML.SimpleDataParser_ = function(node, objectStack) {
var data = ol.format.XSD.readString(node); var data = ol.format.XSD.readString(node);
var featureObject = var featureObject =
/** @type {Object} */ (objectStack[objectStack.length - 1]); /** @type {Object} */ (objectStack[objectStack.length - 1]);
goog.object.set(featureObject, name, data); featureObject[name] = data;
} }
}; };
@@ -1129,6 +1130,18 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
}; };
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
*/
ol.format.KML.LinkParser_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Link');
ol.xml.parseNode(ol.format.KML.LINK_PARSERS_, node, objectStack);
};
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
@@ -1330,6 +1343,35 @@ ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_ = ol.xml.makeParsersNS(
}); });
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.KML.NETWORK_LINK_PARSERS_ = ol.xml.makeParsersNS(
ol.format.KML.NAMESPACE_URIS_, {
'ExtendedData': ol.format.KML.ExtendedDataParser_,
'Link': ol.format.KML.LinkParser_,
'address': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'description': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'open': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean),
'phoneNumber': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'visibility': ol.xml.makeObjectPropertySetter(ol.format.XSD.readBoolean)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.KML.LINK_PARSERS_ = ol.xml.makeParsersNS(
ol.format.KML.NAMESPACE_URIS_, {
'href': ol.xml.makeObjectPropertySetter(ol.format.KML.readURI_)
});
/** /**
* @const * @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>} * @type {Object.<string, Object.<string, ol.xml.Parser>>}
@@ -1710,6 +1752,71 @@ ol.format.KML.prototype.readNameFromNode = function(node) {
}; };
/**
* @param {Document|Node|string} source Souce.
* @return {Array.<Object>} Network links.
* @api
*/
ol.format.KML.prototype.readNetworkLinks = function(source) {
var networkLinks = [];
if (ol.xml.isDocument(source)) {
goog.array.extend(networkLinks, this.readNetworkLinksFromDocument(
/** @type {Document} */ (source)));
} else if (ol.xml.isNode(source)) {
goog.array.extend(networkLinks, this.readNetworkLinksFromNode(
/** @type {Node} */ (source)));
} else if (goog.isString(source)) {
var doc = ol.xml.parse(source);
goog.array.extend(networkLinks, this.readNetworkLinksFromDocument(doc));
} else {
goog.asserts.fail();
}
return networkLinks;
};
/**
* @param {Document} doc Document.
* @return {Array.<Object>} Network links.
*/
ol.format.KML.prototype.readNetworkLinksFromDocument = function(doc) {
var n, networkLinks = [];
for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) {
goog.array.extend(networkLinks, this.readNetworkLinksFromNode(n));
}
}
return networkLinks;
};
/**
* @param {Node} node Node.
* @return {Array.<Object>} Network links.
*/
ol.format.KML.prototype.readNetworkLinksFromNode = function(node) {
var n, networkLinks = [];
for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) {
if (goog.array.contains(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) &&
n.localName == 'NetworkLink') {
var obj = ol.xml.pushParseAndPop({}, ol.format.KML.NETWORK_LINK_PARSERS_,
n, []);
networkLinks.push(obj);
}
}
for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) {
var localName = ol.xml.getLocalName(n);
if (goog.array.contains(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) &&
(localName == 'Document' ||
localName == 'Folder' ||
localName == 'kml')) {
goog.array.extend(networkLinks, this.readNetworkLinksFromNode(n));
}
}
return networkLinks;
};
/** /**
* Read the projection from a KML source. * Read the projection from a KML source.
* *
@@ -1721,22 +1828,6 @@ ol.format.KML.prototype.readNameFromNode = function(node) {
ol.format.KML.prototype.readProjection; ol.format.KML.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.KML.prototype.readProjectionFromDocument = function(doc) {
return this.defaultDataProjection;
};
/**
* @inheritDoc
*/
ol.format.KML.prototype.readProjectionFromNode = function(node) {
return this.defaultDataProjection;
};
/** /**
* @param {Node} node Node to append a TextNode with the color to. * @param {Node} node Node to append a TextNode with the color to.
* @param {ol.Color|string} color Color. * @param {ol.Color|string} color Color.
@@ -1766,8 +1857,8 @@ ol.format.KML.writeCoordinatesTextNode_ =
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var layout = goog.object.get(context, 'layout'); var layout = context['layout'];
var stride = goog.object.get(context, 'stride'); var stride = context['stride'];
var dimension; var dimension;
if (layout == ol.geom.GeometryLayout.XY || if (layout == ol.geom.GeometryLayout.XY ||
@@ -1851,16 +1942,15 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) {
}; };
if (!goog.isNull(size)) { if (!goog.isNull(size)) {
goog.object.set(iconProperties, 'w', size[0]); iconProperties['w'] = size[0];
goog.object.set(iconProperties, 'h', size[1]); iconProperties['h'] = size[1];
var anchor = style.getAnchor(); // top-left var anchor = style.getAnchor(); // top-left
var origin = style.getOrigin(); // top-left var origin = style.getOrigin(); // top-left
if (!goog.isNull(origin) && !goog.isNull(iconImageSize) && if (!goog.isNull(origin) && !goog.isNull(iconImageSize) &&
origin[0] !== 0 && origin[1] !== size[1]) { origin[0] !== 0 && origin[1] !== size[1]) {
goog.object.set(iconProperties, 'x', origin[0]); iconProperties['x'] = origin[0];
goog.object.set(iconProperties, 'y', iconProperties['y'] = iconImageSize[1] - (origin[1] + size[1]);
iconImageSize[1] - (origin[1] + size[1]));
} }
if (!goog.isNull(anchor) && if (!goog.isNull(anchor) &&
@@ -1871,20 +1961,20 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) {
y: size[1] - anchor[1], y: size[1] - anchor[1],
yunits: ol.style.IconAnchorUnits.PIXELS yunits: ol.style.IconAnchorUnits.PIXELS
}; };
goog.object.set(properties, 'hotSpot', hotSpot); properties['hotSpot'] = hotSpot;
} }
} }
goog.object.set(properties, 'Icon', iconProperties); properties['Icon'] = iconProperties;
var scale = style.getScale(); var scale = style.getScale();
if (scale !== 1) { if (scale !== 1) {
goog.object.set(properties, 'scale', scale); properties['scale'] = scale;
} }
var rotation = style.getRotation(); var rotation = style.getRotation();
if (rotation !== 0) { if (rotation !== 0) {
goog.object.set(properties, 'heading', rotation); // 0-360 properties['heading'] = rotation; // 0-360
} }
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
@@ -1906,11 +1996,11 @@ ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) {
var properties = {}; var properties = {};
var fill = style.getFill(); var fill = style.getFill();
if (!goog.isNull(fill)) { if (!goog.isNull(fill)) {
goog.object.set(properties, 'color', fill.getColor()); properties['color'] = fill.getColor();
} }
var scale = style.getScale(); var scale = style.getScale();
if (goog.isDef(scale) && scale !== 1) { if (goog.isDef(scale) && scale !== 1) {
goog.object.set(properties, 'scale', scale); properties['scale'] = scale;
} }
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = var orderedKeys =
@@ -2019,10 +2109,10 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
// resolution-independent here // resolution-independent here
var styles = styleFunction.call(feature, 0); var styles = styleFunction.call(feature, 0);
if (!goog.isNull(styles) && styles.length > 0) { if (!goog.isNull(styles) && styles.length > 0) {
goog.object.set(properties, 'Style', styles[0]); properties['Style'] = styles[0];
var textStyle = styles[0].getText(); var textStyle = styles[0].getText();
if (!goog.isNull(textStyle)) { if (!goog.isNull(textStyle)) {
goog.object.set(properties, 'name', textStyle.getText()); properties['name'] = textStyle.getText();
} }
} }
} }
@@ -2057,8 +2147,8 @@ ol.format.KML.writePrimitiveGeometry_ = function(node, geometry, objectStack) {
(geometry instanceof ol.geom.LinearRing)); (geometry instanceof ol.geom.LinearRing));
var flatCoordinates = geometry.getFlatCoordinates(); var flatCoordinates = geometry.getFlatCoordinates();
var /** @type {ol.xml.NodeStackItem} */ context = {node: node}; var /** @type {ol.xml.NodeStackItem} */ context = {node: node};
goog.object.set(context, 'layout', geometry.getLayout()); context['layout'] = geometry.getLayout();
goog.object.set(context, 'stride', geometry.getStride()); context['stride'] = geometry.getStride();
ol.xml.pushSerializeAndPop(context, ol.xml.pushSerializeAndPop(context,
ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_, ol.format.KML.PRIMITIVE_GEOMETRY_SERIALIZERS_,
ol.format.KML.COORDINATES_NODE_FACTORY_, ol.format.KML.COORDINATES_NODE_FACTORY_,
@@ -2128,16 +2218,16 @@ ol.format.KML.writeStyle_ = function(node, style, objectStack) {
var imageStyle = style.getImage(); var imageStyle = style.getImage();
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(imageStyle)) { if (!goog.isNull(imageStyle)) {
goog.object.set(properties, 'IconStyle', imageStyle); properties['IconStyle'] = imageStyle;
} }
if (!goog.isNull(textStyle)) { if (!goog.isNull(textStyle)) {
goog.object.set(properties, 'LabelStyle', textStyle); properties['LabelStyle'] = textStyle;
} }
if (!goog.isNull(strokeStyle)) { if (!goog.isNull(strokeStyle)) {
goog.object.set(properties, 'LineStyle', strokeStyle); properties['LineStyle'] = strokeStyle;
} }
if (!goog.isNull(fillStyle)) { if (!goog.isNull(fillStyle)) {
goog.object.set(properties, 'PolyStyle', fillStyle); properties['PolyStyle'] = fillStyle;
} }
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = ol.format.KML.STYLE_SEQUENCE_[parentNode.namespaceURI]; var orderedKeys = ol.format.KML.STYLE_SEQUENCE_[parentNode.namespaceURI];
@@ -2608,9 +2698,9 @@ ol.format.KML.prototype.writeFeaturesNode = function(features, opt_options) {
var /** @type {ol.xml.NodeStackItem} */ context = {node: kml}; var /** @type {ol.xml.NodeStackItem} */ context = {node: kml};
var properties = {}; var properties = {};
if (features.length > 1) { if (features.length > 1) {
goog.object.set(properties, 'Document', features); properties['Document'] = features;
} else if (features.length == 1) { } else if (features.length == 1) {
goog.object.set(properties, 'Placemark', features[0]); properties['Placemark'] = features[0];
} }
var orderedKeys = ol.format.KML.KML_SEQUENCE_[kml.namespaceURI]; var orderedKeys = ol.format.KML.KML_SEQUENCE_[kml.namespaceURI];
var values = ol.xml.makeSequence(properties, orderedKeys); var values = ol.xml.makeSequence(properties, orderedKeys);

View File

@@ -67,7 +67,7 @@ ol.format.OSMXML.readNode_ = function(node, objectStack) {
parseFloat(node.getAttribute('lon')), parseFloat(node.getAttribute('lon')),
parseFloat(node.getAttribute('lat')) parseFloat(node.getAttribute('lat'))
]); ]);
goog.object.set(state.nodes, id, coordinates); state.nodes[id] = coordinates;
var values = ol.xml.pushParseAndPop({ var values = ol.xml.pushParseAndPop({
tags: {} tags: {}
@@ -100,7 +100,7 @@ ol.format.OSMXML.readWay_ = function(node, objectStack) {
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]); var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array.<number>} */ ([]); var flatCoordinates = /** @type {Array.<number>} */ ([]);
for (var i = 0, ii = values.ndrefs.length; i < ii; i++) { for (var i = 0, ii = values.ndrefs.length; i < ii; i++) {
var point = goog.object.get(state.nodes, values.ndrefs[i]); var point = state.nodes[values.ndrefs[i]];
goog.array.extend(flatCoordinates, point); goog.array.extend(flatCoordinates, point);
} }
var geometry; var geometry;
@@ -145,7 +145,7 @@ ol.format.OSMXML.readTag_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'tag'); goog.asserts.assert(node.localName == 'tag');
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
goog.object.set(values.tags, node.getAttribute('k'), node.getAttribute('v')); values.tags[node.getAttribute('k')] = node.getAttribute('v');
}; };
@@ -234,19 +234,3 @@ ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
* @api stable * @api stable
*/ */
ol.format.OSMXML.prototype.readProjection; ol.format.OSMXML.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.OSMXML.prototype.readProjectionFromDocument = function(doc) {
return this.defaultDataProjection;
};
/**
* @inheritDoc
*/
ol.format.OSMXML.prototype.readProjectionFromNode = function(node) {
return this.defaultDataProjection;
};

View File

@@ -2,7 +2,6 @@ goog.provide('ol.format.OWS');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.dom.NodeType'); goog.require('goog.dom.NodeType');
goog.require('goog.object');
goog.require('ol.format.XLink'); goog.require('ol.format.XLink');
goog.require('ol.format.XML'); goog.require('ol.format.XML');
goog.require('ol.format.XSD'); goog.require('ol.format.XSD');
@@ -84,20 +83,13 @@ ol.format.OWS.readAllowedValues_ = function(node, objectStack) {
ol.format.OWS.readConstraint_ = function(node, objectStack) { ol.format.OWS.readConstraint_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Constraint'); goog.asserts.assert(node.localName == 'Constraint');
var object = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(object));
var name = node.getAttribute('name'); var name = node.getAttribute('name');
var value = ol.xml.pushParseAndPop({}, if (!goog.isDef(name)) {
ol.format.OWS.CONSTRAINT_PARSERS_, node,
objectStack);
if (!goog.isDef(value)) {
return undefined; return undefined;
} }
if (!goog.isDef(object.constraints)) { return ol.xml.pushParseAndPop({'name': name},
object.constraints = {}; ol.format.OWS.CONSTRAINT_PARSERS_, node,
} objectStack);
object.constraints[name] = value;
}; };
@@ -138,22 +130,12 @@ ol.format.OWS.readDcp_ = function(node, objectStack) {
ol.format.OWS.readGet_ = function(node, objectStack) { ol.format.OWS.readGet_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Get'); goog.asserts.assert(node.localName == 'Get');
var object = objectStack[objectStack.length - 1]; var href = ol.format.XLink.readHref(node);
var url = ol.format.XLink.readHref(node); if (!goog.isDef(href)) {
goog.asserts.assert(goog.isObject(object));
var value = ol.xml.pushParseAndPop({'url': url},
ol.format.OWS.REQUEST_METHOD_PARSERS_, node, objectStack);
if (!goog.isDef(value)) {
return undefined; return undefined;
} }
var get = goog.object.get(object, 'get'); return ol.xml.pushParseAndPop({'href': href},
if (!goog.isDef(get)) { ol.format.OWS.REQUEST_METHOD_PARSERS_, node, objectStack);
goog.object.set(object, 'get', [value]);
}else {
goog.asserts.assert(goog.isArray(get));
get.push(value);
}
}; };
@@ -189,7 +171,7 @@ ol.format.OWS.readOperation_ = function(node, objectStack) {
var object = /** @type {Object} */ var object = /** @type {Object} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isObject(object)); goog.asserts.assert(goog.isObject(object));
goog.object.set(object, name, value); object[name] = value;
}; };
@@ -274,18 +256,12 @@ ol.format.OWS.readServiceProvider_ = function(node, objectStack) {
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
* @private * @private
* @return {Object|undefined} * @return {string|undefined}
*/ */
ol.format.OWS.readValue_ = function(node, objectStack) { ol.format.OWS.readValue_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Value'); goog.asserts.assert(node.localName == 'Value');
var object = objectStack[objectStack.length - 1]; return ol.format.XSD.readString(node);
goog.asserts.assert(goog.isObject(object));
var key = ol.format.XSD.readString(node);
if (!goog.isDef(key)) {
return undefined;
}
goog.object.set(object, key, true);
}; };
@@ -308,14 +284,11 @@ ol.format.OWS.NAMESPACE_URIS_ = [
ol.format.OWS.PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'ServiceIdentification': ol.xml.makeObjectPropertySetter( 'ServiceIdentification': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readServiceIdentification_, ol.format.OWS.readServiceIdentification_),
'serviceIdentification'),
'ServiceProvider': ol.xml.makeObjectPropertySetter( 'ServiceProvider': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readServiceProvider_, ol.format.OWS.readServiceProvider_),
'serviceProvider'),
'OperationsMetadata': ol.xml.makeObjectPropertySetter( 'OperationsMetadata': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readOperationsMetadata_, ol.format.OWS.readOperationsMetadata_)
'operationsMetadata')
}); });
@@ -327,17 +300,14 @@ ol.format.OWS.PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'DeliveryPoint': ol.xml.makeObjectPropertySetter( 'DeliveryPoint': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'deliveryPoint'), ol.format.XSD.readString),
'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'city'),
'AdministrativeArea': ol.xml.makeObjectPropertySetter( 'AdministrativeArea': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'administrativeArea'), ol.format.XSD.readString),
'PostalCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'PostalCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'postalCode'), 'Country': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'Country': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'country'),
'ElectronicMailAddress': ol.xml.makeObjectPropertySetter( 'ElectronicMailAddress': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'electronicMailAddress') ol.format.XSD.readString)
}); });
@@ -348,7 +318,7 @@ ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS(
*/ */
ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'Value': ol.format.OWS.readValue_ 'Value': ol.xml.makeObjectPropertyPusher(ol.format.OWS.readValue_)
}); });
@@ -360,8 +330,7 @@ ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'AllowedValues': ol.xml.makeObjectPropertySetter( 'AllowedValues': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readAllowedValues_, 'allowedValues' ol.format.OWS.readAllowedValues_)
)
}); });
@@ -372,10 +341,8 @@ ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS(
*/ */
ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'Phone': ol.xml.makeObjectPropertySetter( 'Phone': ol.xml.makeObjectPropertySetter(ol.format.OWS.readPhone_),
ol.format.OWS.readPhone_, 'phone'), 'Address': ol.xml.makeObjectPropertySetter(ol.format.OWS.readAddress_)
'Address': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readAddress_, 'address')
}); });
@@ -386,8 +353,7 @@ ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS(
*/ */
ol.format.OWS.DCP_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.DCP_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'HTTP': ol.xml.makeObjectPropertySetter( 'HTTP': ol.xml.makeObjectPropertySetter(ol.format.OWS.readHttp_)
ol.format.OWS.readHttp_, 'http')
}); });
@@ -398,7 +364,7 @@ ol.format.OWS.DCP_PARSERS_ = ol.xml.makeParsersNS(
*/ */
ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'Get': ol.format.OWS.readGet_, 'Get': ol.xml.makeObjectPropertyPusher(ol.format.OWS.readGet_),
'Post': undefined // TODO 'Post': undefined // TODO
}); });
@@ -410,8 +376,7 @@ ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeParsersNS(
*/ */
ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'DCP': ol.xml.makeObjectPropertySetter( 'DCP': ol.xml.makeObjectPropertySetter(ol.format.OWS.readDcp_)
ol.format.OWS.readDcp_, 'dcp')
}); });
@@ -433,10 +398,8 @@ ol.format.OWS.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS(
*/ */
ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'Voice': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'Voice': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'voice'), 'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
'facsimile')
}); });
@@ -447,7 +410,8 @@ ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeParsersNS(
*/ */
ol.format.OWS.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'Constraint': ol.format.OWS.readConstraint_ 'Constraint': ol.xml.makeObjectPropertyPusher(
ol.format.OWS.readConstraint_)
}); });
@@ -460,11 +424,10 @@ ol.format.OWS.SERVICE_CONTACT_PARSERS_ =
ol.xml.makeParsersNS( ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'IndividualName': ol.xml.makeObjectPropertySetter( 'IndividualName': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'individualName'), ol.format.XSD.readString),
'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'positionName'),
'ContactInfo': ol.xml.makeObjectPropertySetter( 'ContactInfo': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readContactInfo_, 'contactInfo') ol.format.OWS.readContactInfo_)
}); });
@@ -476,12 +439,10 @@ ol.format.OWS.SERVICE_CONTACT_PARSERS_ =
ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ = ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ =
ol.xml.makeParsersNS( ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'title'),
'ServiceTypeVersion': ol.xml.makeObjectPropertySetter( 'ServiceTypeVersion': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'serviceTypeVersion'), ol.format.XSD.readString),
'ServiceType': ol.xml.makeObjectPropertySetter( 'ServiceType': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
ol.format.XSD.readString, 'serviceType')
}); });
@@ -493,10 +454,8 @@ ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ =
ol.format.OWS.SERVICE_PROVIDER_PARSERS_ = ol.format.OWS.SERVICE_PROVIDER_PARSERS_ =
ol.xml.makeParsersNS( ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, { ol.format.OWS.NAMESPACE_URIS_, {
'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
'providerName'), 'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref),
'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref,
'providerSite'),
'ServiceContact': ol.xml.makeObjectPropertySetter( 'ServiceContact': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readServiceContact_, 'serviceContact') ol.format.OWS.readServiceContact_)
}); });

View File

@@ -340,14 +340,6 @@ ol.format.Polyline.prototype.readGeometryFromText =
ol.format.Polyline.prototype.readProjection; ol.format.Polyline.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.Polyline.prototype.readProjectionFromText = function(text) {
return this.defaultDataProjection;
};
/** /**
* @inheritDoc * @inheritDoc
*/ */

View File

@@ -111,7 +111,9 @@ ol.format.TextFeature.prototype.readProjection = function(source) {
* @protected * @protected
* @return {ol.proj.Projection} Projection. * @return {ol.proj.Projection} Projection.
*/ */
ol.format.TextFeature.prototype.readProjectionFromText = goog.abstractMethod; ol.format.TextFeature.prototype.readProjectionFromText = function(text) {
return this.defaultDataProjection;
};
/** /**

View File

@@ -397,7 +397,7 @@ ol.format.TopoJSON.prototype.readProjection = function(object) {
/** /**
* @const * @const
* @private * @private
* @type {Object.<string, function(TopoJSONGeometry, Array, ...[Array]): ol.geom.Geometry>} * @type {Object.<string, function(TopoJSONGeometry, Array, ...Array): ol.geom.Geometry>}
*/ */
ol.format.TopoJSON.GEOMETRY_READERS_ = { ol.format.TopoJSON.GEOMETRY_READERS_ = {
'Point': ol.format.TopoJSON.readPointGeometry_, 'Point': ol.format.TopoJSON.readPointGeometry_,

View File

@@ -125,6 +125,9 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) {
goog.object.extend(context, this.getReadOptions(node, goog.object.extend(context, this.getReadOptions(node,
goog.isDef(opt_options) ? opt_options : {})); goog.isDef(opt_options) ? opt_options : {}));
var objectStack = [context]; var objectStack = [context];
this.gmlFormat_.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][
'featureMember'] =
ol.xml.makeArrayPusher(ol.format.GMLBase.prototype.readFeaturesInternal);
var features = ol.xml.pushParseAndPop([], var features = ol.xml.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
objectStack, this.gmlFormat_); objectStack, this.gmlFormat_);
@@ -220,7 +223,7 @@ ol.format.WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
var result = {}; var result = {};
var value = ol.format.XSD.readNonNegativeIntegerString( var value = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('numberOfFeatures')); node.getAttribute('numberOfFeatures'));
goog.object.set(result, 'numberOfFeatures', value); result['numberOfFeatures'] = value;
return ol.xml.pushParseAndPop( return ol.xml.pushParseAndPop(
/** @type {ol.format.WFS.FeatureCollectionMetadata} */ (result), /** @type {ol.format.WFS.FeatureCollectionMetadata} */ (result),
ol.format.WFS.FEATURE_COLLECTION_PARSERS_, node, [], this.gmlFormat_); ol.format.WFS.FEATURE_COLLECTION_PARSERS_, node, [], this.gmlFormat_);
@@ -367,8 +370,8 @@ ol.format.WFS.QUERY_SERIALIZERS_ = {
ol.format.WFS.writeFeature_ = function(node, feature, objectStack) { ol.format.WFS.writeFeature_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var featureType = goog.object.get(context, 'featureType'); var featureType = context['featureType'];
var featureNS = goog.object.get(context, 'featureNS'); var featureNS = context['featureNS'];
var child = ol.xml.createElementNS(featureNS, featureType); var child = ol.xml.createElementNS(featureNS, featureType);
node.appendChild(child); node.appendChild(child);
ol.format.GML3.prototype.writeFeatureElement(child, feature, objectStack); ol.format.GML3.prototype.writeFeatureElement(child, feature, objectStack);
@@ -399,11 +402,11 @@ ol.format.WFS.writeOgcFidFilter_ = function(node, fid, objectStack) {
ol.format.WFS.writeDelete_ = function(node, feature, objectStack) { ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var featureType = goog.object.get(context, 'featureType'); var featureType = context['featureType'];
var featurePrefix = goog.object.get(context, 'featurePrefix'); var featurePrefix = context['featurePrefix'];
featurePrefix = goog.isDef(featurePrefix) ? featurePrefix : featurePrefix = goog.isDef(featurePrefix) ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX; ol.format.WFS.FEATURE_PREFIX;
var featureNS = goog.object.get(context, 'featureNS'); var featureNS = context['featureNS'];
node.setAttribute('typeName', featurePrefix + ':' + featureType); node.setAttribute('typeName', featurePrefix + ':' + featureType);
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS); featureNS);
@@ -423,11 +426,11 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) { ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var featureType = goog.object.get(context, 'featureType'); var featureType = context['featureType'];
var featurePrefix = goog.object.get(context, 'featurePrefix'); var featurePrefix = context['featurePrefix'];
featurePrefix = goog.isDef(featurePrefix) ? featurePrefix : featurePrefix = goog.isDef(featurePrefix) ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX; ol.format.WFS.FEATURE_PREFIX;
var featureNS = goog.object.get(context, 'featureNS'); var featureNS = context['featureNS'];
node.setAttribute('typeName', featurePrefix + ':' + featureType); node.setAttribute('typeName', featurePrefix + ':' + featureType);
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS); featureNS);
@@ -442,7 +445,7 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
} }
} }
ol.xml.pushSerializeAndPop({node: node, srsName: ol.xml.pushSerializeAndPop({node: node, srsName:
goog.object.get(context, 'srsName')}, context['srsName']},
ol.format.WFS.TRANSACTION_SERIALIZERS_, ol.format.WFS.TRANSACTION_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('Property'), values, ol.xml.makeSimpleNodeFactory('Property'), values,
objectStack); objectStack);
@@ -518,10 +521,10 @@ ol.format.WFS.TRANSACTION_SERIALIZERS_ = {
ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) { ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var featurePrefix = goog.object.get(context, 'featurePrefix'); var featurePrefix = context['featurePrefix'];
var featureNS = goog.object.get(context, 'featureNS'); var featureNS = context['featureNS'];
var propertyNames = goog.object.get(context, 'propertyNames'); var propertyNames = context['propertyNames'];
var srsName = goog.object.get(context, 'srsName'); var srsName = context['srsName'];
var prefix = goog.isDef(featurePrefix) ? featurePrefix + ':' : ''; var prefix = goog.isDef(featurePrefix) ? featurePrefix + ':' : '';
node.setAttribute('typeName', prefix + featureType); node.setAttribute('typeName', prefix + featureType);
if (goog.isDef(srsName)) { if (goog.isDef(srsName)) {
@@ -537,7 +540,7 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
ol.format.WFS.QUERY_SERIALIZERS_, ol.format.WFS.QUERY_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory('PropertyName'), propertyNames, ol.xml.makeSimpleNodeFactory('PropertyName'), propertyNames,
objectStack); objectStack);
var bbox = goog.object.get(context, 'bbox'); var bbox = context['bbox'];
if (goog.isDef(bbox)) { if (goog.isDef(bbox)) {
var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter'); var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter');
ol.format.WFS.writeOgcBBOX_(child, bbox, objectStack); ol.format.WFS.writeOgcBBOX_(child, bbox, objectStack);
@@ -569,7 +572,7 @@ ol.format.WFS.writeOgcPropertyName_ = function(node, value, objectStack) {
ol.format.WFS.writeOgcBBOX_ = function(node, bbox, objectStack) { ol.format.WFS.writeOgcBBOX_ = function(node, bbox, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var geometryName = goog.object.get(context, 'geometryName'); var geometryName = context['geometryName'];
var bboxNode = ol.xml.createElementNS('http://www.opengis.net/ogc', 'BBOX'); var bboxNode = ol.xml.createElementNS('http://www.opengis.net/ogc', 'BBOX');
node.appendChild(bboxNode); node.appendChild(bboxNode);
ol.format.WFS.writeOgcPropertyName_(bboxNode, geometryName, objectStack); ol.format.WFS.writeOgcPropertyName_(bboxNode, geometryName, objectStack);
@@ -747,8 +750,10 @@ ol.format.WFS.prototype.readProjectionFromDocument = function(doc) {
ol.format.WFS.prototype.readProjectionFromNode = function(node) { ol.format.WFS.prototype.readProjectionFromNode = function(node) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'FeatureCollection'); goog.asserts.assert(node.localName == 'FeatureCollection');
node = node.firstElementChild.firstElementChild;
if (goog.isDefAndNotNull(node)) { if (goog.isDefAndNotNull(node.firstElementChild) &&
goog.isDefAndNotNull(node.firstElementChild.firstElementChild)) {
node = node.firstElementChild.firstElementChild;
for (var n = node.firstElementChild; !goog.isNull(n); for (var n = node.firstElementChild; !goog.isNull(n);
n = n.nextElementSibling) { n = n.nextElementSibling) {
if (!(n.childNodes.length === 0 || if (!(n.childNodes.length === 0 ||
@@ -760,5 +765,6 @@ ol.format.WFS.prototype.readProjectionFromNode = function(node) {
} }
} }
} }
return null; return null;
}; };

View File

@@ -291,14 +291,6 @@ ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) {
}; };
/**
* @inheritDoc
*/
ol.format.WKT.prototype.readProjectionFromText = function(text) {
return null;
};
/** /**
* Encode a feature as a WKT string. * Encode a feature as a WKT string.
* *

View File

@@ -136,14 +136,14 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ =
if (!goog.isDef(geographicBoundingBox)) { if (!goog.isDef(geographicBoundingBox)) {
return undefined; return undefined;
} }
var westBoundLongitude = /** @type {number|undefined} */ (goog.object.get( var westBoundLongitude = /** @type {number|undefined} */
geographicBoundingBox, 'westBoundLongitude')); (geographicBoundingBox['westBoundLongitude']);
var southBoundLatitude = /** @type {number|undefined} */ (goog.object.get( var southBoundLatitude = /** @type {number|undefined} */
geographicBoundingBox, 'southBoundLatitude')); (geographicBoundingBox['southBoundLatitude']);
var eastBoundLongitude = /** @type {number|undefined} */ (goog.object.get( var eastBoundLongitude = /** @type {number|undefined} */
geographicBoundingBox, 'eastBoundLongitude')); (geographicBoundingBox['eastBoundLongitude']);
var northBoundLatitude = /** @type {number|undefined} */ (goog.object.get( var northBoundLatitude = /** @type {number|undefined} */
geographicBoundingBox, 'northBoundLatitude')); (geographicBoundingBox['northBoundLatitude']);
if (!goog.isDef(westBoundLongitude) || !goog.isDef(southBoundLatitude) || if (!goog.isDef(westBoundLongitude) || !goog.isDef(southBoundLatitude) ||
!goog.isDef(eastBoundLongitude) || !goog.isDef(northBoundLatitude)) { !goog.isDef(eastBoundLongitude) || !goog.isDef(northBoundLatitude)) {
return undefined; return undefined;
@@ -280,64 +280,62 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
var queryable = var queryable =
ol.format.XSD.readBooleanString(node.getAttribute('queryable')); ol.format.XSD.readBooleanString(node.getAttribute('queryable'));
if (!goog.isDef(queryable)) { if (!goog.isDef(queryable)) {
queryable = goog.object.get(parentLayerObject, 'queryable'); queryable = parentLayerObject['queryable'];
} }
goog.object.set( layerObject['queryable'] = goog.isDef(queryable) ? queryable : false;
layerObject, 'queryable', goog.isDef(queryable) ? queryable : false);
var cascaded = ol.format.XSD.readNonNegativeIntegerString( var cascaded = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('cascaded')); node.getAttribute('cascaded'));
if (!goog.isDef(cascaded)) { if (!goog.isDef(cascaded)) {
cascaded = goog.object.get(parentLayerObject, 'cascaded'); cascaded = parentLayerObject['cascaded'];
} }
goog.object.set(layerObject, 'cascaded', cascaded); layerObject['cascaded'] = cascaded;
var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque')); var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque'));
if (!goog.isDef(opaque)) { if (!goog.isDef(opaque)) {
opaque = goog.object.get(parentLayerObject, 'opaque'); opaque = parentLayerObject['opaque'];
} }
goog.object.set(layerObject, 'opaque', goog.isDef(opaque) ? opaque : false); layerObject['opaque'] = goog.isDef(opaque) ? opaque : false;
var noSubsets = var noSubsets =
ol.format.XSD.readBooleanString(node.getAttribute('noSubsets')); ol.format.XSD.readBooleanString(node.getAttribute('noSubsets'));
if (!goog.isDef(noSubsets)) { if (!goog.isDef(noSubsets)) {
noSubsets = goog.object.get(parentLayerObject, 'noSubsets'); noSubsets = parentLayerObject['noSubsets'];
} }
goog.object.set( layerObject['noSubsets'] = goog.isDef(noSubsets) ? noSubsets : false;
layerObject, 'noSubsets', goog.isDef(noSubsets) ? noSubsets : false);
var fixedWidth = var fixedWidth =
ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth')); ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth'));
if (!goog.isDef(fixedWidth)) { if (!goog.isDef(fixedWidth)) {
fixedWidth = goog.object.get(parentLayerObject, 'fixedWidth'); fixedWidth = parentLayerObject['fixedWidth'];
} }
goog.object.set(layerObject, 'fixedWidth', fixedWidth); layerObject['fixedWidth'] = fixedWidth;
var fixedHeight = var fixedHeight =
ol.format.XSD.readDecimalString(node.getAttribute('fixedHeight')); ol.format.XSD.readDecimalString(node.getAttribute('fixedHeight'));
if (!goog.isDef(fixedHeight)) { if (!goog.isDef(fixedHeight)) {
fixedHeight = goog.object.get(parentLayerObject, 'fixedHeight'); fixedHeight = parentLayerObject['fixedHeight'];
} }
goog.object.set(layerObject, 'fixedHeight', fixedHeight); layerObject['fixedHeight'] = fixedHeight;
// See 7.2.4.8 // See 7.2.4.8
var addKeys = ['Style', 'CRS', 'AuthorityURL']; var addKeys = ['Style', 'CRS', 'AuthorityURL'];
goog.array.forEach(addKeys, function(key) { goog.array.forEach(addKeys, function(key) {
var parentValue = goog.object.get(parentLayerObject, key); var parentValue = parentLayerObject[key];
if (goog.isDef(parentValue)) { if (goog.isDef(parentValue)) {
var childValue = goog.object.setIfUndefined(layerObject, key, []); var childValue = goog.object.setIfUndefined(layerObject, key, []);
childValue = childValue.concat(parentValue); childValue = childValue.concat(parentValue);
goog.object.set(layerObject, key, childValue); layerObject[key] = childValue;
} }
}); });
var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension', var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension',
'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator']; 'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator'];
goog.array.forEach(replaceKeys, function(key) { goog.array.forEach(replaceKeys, function(key) {
var childValue = goog.object.get(layerObject, key); var childValue = layerObject[key];
if (!goog.isDef(childValue)) { if (!goog.isDef(childValue)) {
var parentValue = goog.object.get(parentLayerObject, key); var parentValue = parentLayerObject[key];
goog.object.set(layerObject, key, parentValue); layerObject[key] = parentValue;
} }
}); });
@@ -456,7 +454,7 @@ ol.format.WMSCapabilities.readSizedFormatOnlineresource_ =
ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('width')), ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('width')),
ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('height')) ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('height'))
]; ];
goog.object.set(formatOnlineresource, 'size', size); formatOnlineresource['size'] = size;
return formatOnlineresource; return formatOnlineresource;
} }
return undefined; return undefined;
@@ -475,7 +473,7 @@ ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
var authorityObject = var authorityObject =
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (goog.isDef(authorityObject)) { if (goog.isDef(authorityObject)) {
goog.object.set(authorityObject, 'name', node.getAttribute('name')); authorityObject['name'] = node.getAttribute('name');
return authorityObject; return authorityObject;
} }
return undefined; return undefined;
@@ -494,7 +492,7 @@ ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
var metadataObject = var metadataObject =
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (goog.isDef(metadataObject)) { if (goog.isDef(metadataObject)) {
goog.object.set(metadataObject, 'type', node.getAttribute('type')); metadataObject['type'] = node.getAttribute('type');
return metadataObject; return metadataObject;
} }
return undefined; return undefined;

View File

@@ -2,7 +2,6 @@ goog.provide('ol.format.WMSGetFeatureInfo');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.NodeType'); goog.require('goog.dom.NodeType');
goog.require('goog.object'); goog.require('goog.object');
goog.require('goog.string'); goog.require('goog.string');
@@ -90,14 +89,14 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ =
ol.format.WMSGetFeatureInfo.layerIdentifier_) + ol.format.WMSGetFeatureInfo.layerIdentifier_) +
ol.format.WMSGetFeatureInfo.featureIdentifier_; ol.format.WMSGetFeatureInfo.featureIdentifier_;
goog.object.set(context, 'featureType', featureType); context['featureType'] = featureType;
goog.object.set(context, 'featureNS', this.featureNS_); context['featureNS'] = this.featureNS_;
var parsers = {}; var parsers = {};
parsers[featureType] = ol.xml.makeArrayPusher( parsers[featureType] = ol.xml.makeArrayPusher(
this.gmlFormat_.readFeatureElement, this.gmlFormat_); this.gmlFormat_.readFeatureElement, this.gmlFormat_);
var parsersNS = ol.xml.makeParsersNS( var parsersNS = ol.xml.makeParsersNS(
[goog.object.get(context, 'featureNS'), null], parsers); [context['featureNS'], null], parsers);
layer.namespaceURI = this.featureNS_; layer.namespaceURI = this.featureNS_;
var layerFeatures = ol.xml.pushParseAndPop( var layerFeatures = ol.xml.pushParseAndPop(
[], parsersNS, layer, objectStack, this.gmlFormat_); [], parsersNS, layer, objectStack, this.gmlFormat_);

View File

@@ -0,0 +1,400 @@
goog.provide('ol.format.WMTSCapabilities');
goog.require('goog.asserts');
goog.require('goog.dom.NodeType');
goog.require('goog.object');
goog.require('goog.string');
goog.require('ol.extent');
goog.require('ol.format.OWS');
goog.require('ol.format.XLink');
goog.require('ol.format.XML');
goog.require('ol.format.XSD');
goog.require('ol.xml');
/**
* @classdesc
* Format for reading WMTS capabilities data.
*
* @constructor
* @extends {ol.format.XML}
* @api
*/
ol.format.WMTSCapabilities = function() {
goog.base(this);
/**
* @type {ol.format.OWS}
* @private
*/
this.owsParser_ = new ol.format.OWS();
};
goog.inherits(ol.format.WMTSCapabilities, ol.format.XML);
/**
* Read a WMTS capabilities document.
*
* @function
* @param {Document|Node|string} source The XML source.
* @return {Object} An object representing the WMTS capabilities.
* @api
*/
ol.format.WMTSCapabilities.prototype.read;
/**
* @param {Document} doc Document.
* @return {Object} WMTS Capability object.
*/
ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT);
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) {
return this.readFromNode(n);
}
}
return null;
};
/**
* @param {Node} node Node.
* @return {Object} WMTS Capability object.
*/
ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Capabilities');
this.version = goog.string.trim(node.getAttribute('version'));
goog.asserts.assertString(this.version);
var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
if (!goog.isDef(WMTSCapabilityObject)) {
return null;
}
goog.object.set(WMTSCapabilityObject, 'version', this.version);
WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject,
ol.format.WMTSCapabilities.PARSERS_, node, []);
return goog.isDef(WMTSCapabilityObject) ? WMTSCapabilityObject : null;
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Attribution object.
*/
ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Contents');
return ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.CONTENTS_PARSERS_, node, objectStack);
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Layers object.
*/
ol.format.WMTSCapabilities.readLayer_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Layer');
return ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.LAYER_PARSERS_, node, objectStack);
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Tile Matrix Set object.
*/
ol.format.WMTSCapabilities.readTileMatrixSet_ = function(node, objectStack) {
return ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.TMS_PARSERS_, node, objectStack);
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Style object.
*/
ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) {
var style = ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(style)) {
return undefined;
}
var isDefault = node.getAttribute('isDefault') === 'true';
style['isDefault'] = isDefault;
return style;
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Tile Matrix Set Link object.
*/
ol.format.WMTSCapabilities.readTileMatrixSetLink_ = function(node,
objectStack) {
return ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.TMS_LINKS_PARSERS_, node, objectStack);
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Resource URL object.
*/
ol.format.WMTSCapabilities.readResourceUrl_ = function(node, objectStack) {
var format = node.getAttribute('format');
var template = node.getAttribute('template');
var resourceType = node.getAttribute('resourceType');
var resource = {};
if (goog.isDef(format)) {
resource['format'] = format;
}
if (goog.isDef(template)) {
resource['template'] = template;
}
if (goog.isDef(resourceType)) {
resource['resourceType'] = resourceType;
}
return resource;
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} WGS84 BBox object.
*/
ol.format.WMTSCapabilities.readWgs84BoundingBox_ = function(node, objectStack) {
var coordinates = ol.xml.pushParseAndPop([],
ol.format.WMTSCapabilities.WGS84_BBOX_READERS_, node, objectStack);
if (coordinates.length != 2) {
return undefined;
}
return ol.extent.boundingExtent(coordinates);
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Legend object.
*/
ol.format.WMTSCapabilities.readLegendUrl_ = function(node, objectStack) {
var legend = {};
legend['format'] = node.getAttribute('format');
legend['href'] = ol.format.XLink.readHref(node);
return legend;
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Coordinates object.
*/
ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) {
var coordinates = ol.format.XSD.readString(node).split(' ');
if (!goog.isDef(coordinates) || coordinates.length != 2) {
return undefined;
}
var x = +coordinates[0];
var y = +coordinates[1];
if (isNaN(x) || isNaN(y)) {
return undefined;
}
return [x, y];
};
/**
* @private
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} TileMatrix object.
*/
ol.format.WMTSCapabilities.readTileMatrix_ = function(node, objectStack) {
return ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.TM_PARSERS_, node, objectStack);
};
/**
* @const
* @private
* @type {Array.<string>}
*/
ol.format.WMTSCapabilities.NAMESPACE_URIS_ = [
null,
'http://www.opengis.net/wmts/1.0'
];
/**
* @const
* @private
* @type {Array.<string>}
*/
ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_ = [
null,
'http://www.opengis.net/ows/1.1'
];
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.WMTSCapabilities.PARSERS_ = ol.xml.makeParsersNS(
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
'Contents': ol.xml.makeObjectPropertySetter(
ol.format.WMTSCapabilities.readContents_)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.WMTSCapabilities.CONTENTS_PARSERS_ = ol.xml.makeParsersNS(
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
'Layer': ol.xml.makeObjectPropertyPusher(
ol.format.WMTSCapabilities.readLayer_),
'TileMatrixSet': ol.xml.makeObjectPropertyPusher(
ol.format.WMTSCapabilities.readTileMatrixSet_)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.WMTSCapabilities.LAYER_PARSERS_ = ol.xml.makeParsersNS(
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
'Style': ol.xml.makeObjectPropertyPusher(
ol.format.WMTSCapabilities.readStyle_),
'Format': ol.xml.makeObjectPropertyPusher(
ol.format.XSD.readString),
'TileMatrixSetLink': ol.xml.makeObjectPropertyPusher(
ol.format.WMTSCapabilities.readTileMatrixSetLink_),
'ResourceURL': ol.xml.makeObjectPropertyPusher(
ol.format.WMTSCapabilities.readResourceUrl_)
}, ol.xml.makeParsersNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
'Title': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString),
'Abstract': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString),
'WGS84BoundingBox': ol.xml.makeObjectPropertySetter(
ol.format.WMTSCapabilities.readWgs84BoundingBox_),
'Identifier': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString)
}));
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.WMTSCapabilities.STYLE_PARSERS_ = ol.xml.makeParsersNS(
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
'LegendURL': ol.xml.makeObjectPropertyPusher(
ol.format.WMTSCapabilities.readLegendUrl_)
}, ol.xml.makeParsersNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
'Title': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString),
'Identifier': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString)
}));
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.WMTSCapabilities.TMS_LINKS_PARSERS_ = ol.xml.makeParsersNS(
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
'TileMatrixSet': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.WMTSCapabilities.WGS84_BBOX_READERS_ = ol.xml.makeParsersNS(
ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
'LowerCorner': ol.xml.makeArrayPusher(
ol.format.WMTSCapabilities.readCoordinates_),
'UpperCorner': ol.xml.makeArrayPusher(
ol.format.WMTSCapabilities.readCoordinates_)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.WMTSCapabilities.TMS_PARSERS_ = ol.xml.makeParsersNS(
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
'WellKnownScaleSet': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString),
'TileMatrix': ol.xml.makeObjectPropertyPusher(
ol.format.WMTSCapabilities.readTileMatrix_)
}, ol.xml.makeParsersNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
'SupportedCRS': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString),
'Identifier': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString)
}));
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.WMTSCapabilities.TM_PARSERS_ = ol.xml.makeParsersNS(
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
'TopLeftCorner': ol.xml.makeObjectPropertySetter(
ol.format.WMTSCapabilities.readCoordinates_),
'ScaleDenominator': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readDecimal),
'TileWidth': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readNonNegativeInteger),
'TileHeight': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readNonNegativeInteger),
'MatrixWidth': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readNonNegativeInteger),
'MatrixHeight': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readNonNegativeInteger)
}, ol.xml.makeParsersNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
'Identifier': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString)
}));

View File

@@ -185,7 +185,9 @@ ol.format.XMLFeature.prototype.readProjection = function(source) {
* @protected * @protected
* @return {ol.proj.Projection} Projection. * @return {ol.proj.Projection} Projection.
*/ */
ol.format.XMLFeature.prototype.readProjectionFromDocument = goog.abstractMethod; ol.format.XMLFeature.prototype.readProjectionFromDocument = function(doc) {
return this.defaultDataProjection;
};
/** /**
@@ -193,7 +195,9 @@ ol.format.XMLFeature.prototype.readProjectionFromDocument = goog.abstractMethod;
* @protected * @protected
* @return {ol.proj.Projection} Projection. * @return {ol.proj.Projection} Projection.
*/ */
ol.format.XMLFeature.prototype.readProjectionFromNode = goog.abstractMethod; ol.format.XMLFeature.prototype.readProjectionFromNode = function(node) {
return this.defaultDataProjection;
};
/** /**

View File

@@ -94,20 +94,14 @@ ol.geom.Circle.prototype.getCenter = function() {
/** /**
* @inheritDoc * @inheritDoc
* @api
*/ */
ol.geom.Circle.prototype.getExtent = function(opt_extent) { ol.geom.Circle.prototype.computeExtent = function(extent) {
if (this.extentRevision != this.getRevision()) { var flatCoordinates = this.flatCoordinates;
var flatCoordinates = this.flatCoordinates; var radius = flatCoordinates[this.stride] - flatCoordinates[0];
var radius = flatCoordinates[this.stride] - flatCoordinates[0]; return ol.extent.createOrUpdate(
this.extent = ol.extent.createOrUpdate( flatCoordinates[0] - radius, flatCoordinates[1] - radius,
flatCoordinates[0] - radius, flatCoordinates[1] - radius, flatCoordinates[0] + radius, flatCoordinates[1] + radius,
flatCoordinates[0] + radius, flatCoordinates[1] + radius, extent);
this.extent);
this.extentRevision = this.getRevision();
}
goog.asserts.assert(goog.isDef(this.extent));
return ol.extent.returnOrUpdate(this.extent, opt_extent);
}; };

View File

@@ -37,7 +37,7 @@ ol.geom.flat.geodesic.line_ =
/** @type {Array.<number>} */ /** @type {Array.<number>} */
var fractionStack = [1, 0]; var fractionStack = [1, 0];
/** @type {Object.<number, boolean>} */ /** @type {Object.<string, boolean>} */
var fractions = {}; var fractions = {};
var maxIterations = 1e5; var maxIterations = 1e5;
@@ -52,7 +52,7 @@ ol.geom.flat.geodesic.line_ =
key = fracA.toString(); key = fracA.toString();
if (!goog.object.containsKey(fractions, key)) { if (!goog.object.containsKey(fractions, key)) {
flatCoordinates.push(a[0], a[1]); flatCoordinates.push(a[0], a[1]);
goog.object.set(fractions, key, true); fractions[key] = true;
} }
// Pop the b coordinate off the stack // Pop the b coordinate off the stack
fracB = fractionStack.pop(); fracB = fractionStack.pop();
@@ -70,7 +70,7 @@ ol.geom.flat.geodesic.line_ =
flatCoordinates.push(b[0], b[1]); flatCoordinates.push(b[0], b[1]);
key = fracB.toString(); key = fracB.toString();
goog.asserts.assert(!goog.object.containsKey(fractions, key)); goog.asserts.assert(!goog.object.containsKey(fractions, key));
goog.object.set(fractions, key, true); fractions[key] = true;
} else { } else {
// Otherwise, we need to subdivide the current line segment. Split it // Otherwise, we need to subdivide the current line segment. Split it
// into two and push the two line segments onto the stack. // into two and push the two line segments onto the stack.

View File

@@ -1,9 +1,9 @@
goog.provide('ol.geom.Geometry'); goog.provide('ol.geom.Geometry');
goog.provide('ol.geom.GeometryType'); goog.provide('ol.geom.GeometryType');
goog.require('goog.asserts');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('ol.Observable'); goog.require('ol.Observable');
goog.require('ol.extent');
goog.require('ol.proj'); goog.require('ol.proj');
@@ -59,16 +59,16 @@ ol.geom.Geometry = function() {
goog.base(this); goog.base(this);
/** /**
* @protected * @private
* @type {ol.Extent|undefined} * @type {ol.Extent}
*/ */
this.extent = undefined; this.extent_ = ol.extent.createEmpty();
/** /**
* @protected * @private
* @type {number} * @type {number}
*/ */
this.extentRevision = -1; this.extentRevision_ = -1;
/** /**
* @protected * @protected
@@ -134,6 +134,14 @@ ol.geom.Geometry.prototype.containsCoordinate = function(coordinate) {
}; };
/**
* @param {ol.Extent} extent Extent.
* @protected
* @return {ol.Extent} extent Extent.
*/
ol.geom.Geometry.prototype.computeExtent = goog.abstractMethod;
/** /**
* @param {number} x X. * @param {number} x X.
* @param {number} y Y. * @param {number} y Y.
@@ -144,12 +152,17 @@ ol.geom.Geometry.prototype.containsXY = goog.functions.FALSE;
/** /**
* Get the extent of the geometry. * Get the extent of the geometry.
* @function
* @param {ol.Extent=} opt_extent Extent. * @param {ol.Extent=} opt_extent Extent.
* @return {ol.Extent} extent Extent. * @return {ol.Extent} extent Extent.
* @api stable * @api stable
*/ */
ol.geom.Geometry.prototype.getExtent = goog.abstractMethod; ol.geom.Geometry.prototype.getExtent = function(opt_extent) {
if (this.extentRevision_ != this.getRevision()) {
this.extent_ = this.computeExtent(this.extent_);
this.extentRevision_ = this.getRevision();
}
return ol.extent.returnOrUpdate(this.extent_, opt_extent);
};
/** /**

View File

@@ -1,7 +1,6 @@
goog.provide('ol.geom.GeometryCollection'); goog.provide('ol.geom.GeometryCollection');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.object'); goog.require('goog.object');
@@ -130,21 +129,14 @@ ol.geom.GeometryCollection.prototype.containsXY = function(x, y) {
/** /**
* @inheritDoc * @inheritDoc
* @api stable
*/ */
ol.geom.GeometryCollection.prototype.getExtent = function(opt_extent) { ol.geom.GeometryCollection.prototype.computeExtent = function(extent) {
if (this.extentRevision != this.getRevision()) { ol.extent.createOrUpdateEmpty(extent);
var extent = ol.extent.createOrUpdateEmpty(this.extent); var geometries = this.geometries_;
var geometries = this.geometries_; for (var i = 0, ii = geometries.length; i < ii; ++i) {
var i, ii; ol.extent.extend(extent, geometries[i].getExtent());
for (i = 0, ii = geometries.length; i < ii; ++i) {
ol.extent.extend(extent, geometries[i].getExtent());
}
this.extent = extent;
this.extentRevision = this.getRevision();
} }
goog.asserts.assert(goog.isDef(this.extent)); return extent;
return ol.extent.returnOrUpdate(this.extent, opt_extent);
}; };

View File

@@ -117,7 +117,7 @@ ol.geom.LineString.prototype.closestPointXY =
* return the last coordinate. * return the last coordinate.
* *
* @param {number} m M. * @param {number} m M.
* @param {boolean=} opt_extrapolate Extrapolate. * @param {boolean=} opt_extrapolate Extrapolate. Default is `false`.
* @return {ol.Coordinate} Coordinate. * @return {ol.Coordinate} Coordinate.
* @api stable * @api stable
*/ */

View File

@@ -121,8 +121,8 @@ ol.geom.MultiLineString.prototype.closestPointXY =
* LineStrings. * LineStrings.
* *
* @param {number} m M. * @param {number} m M.
* @param {boolean=} opt_extrapolate Extrapolate. * @param {boolean=} opt_extrapolate Extrapolate. Default is `false`.
* @param {boolean=} opt_interpolate Interpolate. * @param {boolean=} opt_interpolate Interpolate. Default is `false`.
* @return {ol.Coordinate} Coordinate. * @return {ol.Coordinate} Coordinate.
* @api stable * @api stable
*/ */

View File

@@ -1,6 +1,5 @@
goog.provide('ol.geom.Point'); goog.provide('ol.geom.Point');
goog.require('goog.asserts');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
goog.require('ol.geom.SimpleGeometry'); goog.require('ol.geom.SimpleGeometry');
@@ -73,14 +72,8 @@ ol.geom.Point.prototype.getCoordinates = function() {
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.geom.Point.prototype.getExtent = function(opt_extent) { ol.geom.Point.prototype.computeExtent = function(extent) {
if (this.extentRevision != this.getRevision()) { return ol.extent.createOrUpdateFromCoordinate(this.flatCoordinates, extent);
this.extent = ol.extent.createOrUpdateFromCoordinate(
this.flatCoordinates, this.extent);
this.extentRevision = this.getRevision();
}
goog.asserts.assert(goog.isDef(this.extent));
return ol.extent.returnOrUpdate(this.extent, opt_extent);
}; };

View File

@@ -90,17 +90,11 @@ ol.geom.SimpleGeometry.prototype.containsXY = goog.functions.FALSE;
/** /**
* @inheritDoc * @inheritDoc
* @api stable
*/ */
ol.geom.SimpleGeometry.prototype.getExtent = function(opt_extent) { ol.geom.SimpleGeometry.prototype.computeExtent = function(extent) {
if (this.extentRevision != this.getRevision()) { return ol.extent.createOrUpdateFromFlatCoordinates(
this.extent = ol.extent.createOrUpdateFromFlatCoordinates( this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, extent);
this.extent);
this.extentRevision = this.getRevision();
}
goog.asserts.assert(goog.isDef(this.extent));
return ol.extent.returnOrUpdate(this.extent, opt_extent);
}; };

View File

@@ -1,6 +1,5 @@
goog.provide('ol.interaction.DragRotateAndZoom'); goog.provide('ol.interaction.DragRotateAndZoom');
goog.require('goog.asserts');
goog.require('goog.math.Vec2'); goog.require('goog.math.Vec2');
goog.require('ol'); goog.require('ol');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
@@ -62,8 +61,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
this.lastScaleDelta_ = 0; this.lastScaleDelta_ = 0;
}; };
goog.inherits(ol.interaction.DragRotateAndZoom, goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer);
ol.interaction.Pointer);
/** /**

View File

@@ -1,6 +1,5 @@
goog.provide('ol.interaction.DragRotate'); goog.provide('ol.interaction.DragRotate');
goog.require('goog.asserts');
goog.require('ol'); goog.require('ol');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.events.ConditionType'); goog.require('ol.events.ConditionType');
@@ -68,10 +67,10 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
if (goog.isDef(this.lastAngle_)) { if (goog.isDef(this.lastAngle_)) {
var delta = theta - this.lastAngle_; var delta = theta - this.lastAngle_;
var view = map.getView(); var view = map.getView();
var viewState = view.getState(); var rotation = view.getRotation();
map.render(); map.render();
ol.interaction.Interaction.rotateWithoutConstraints( ol.interaction.Interaction.rotateWithoutConstraints(
map, view, viewState.rotation - delta); map, view, rotation - delta);
} }
this.lastAngle_ = theta; this.lastAngle_ = theta;
}; };
@@ -91,8 +90,8 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
var viewState = view.getState(); var rotation = view.getRotation();
ol.interaction.Interaction.rotate(map, view, viewState.rotation, ol.interaction.Interaction.rotate(map, view, rotation,
undefined, ol.DRAGROTATE_ANIMATION_DURATION); undefined, ol.DRAGROTATE_ANIMATION_DURATION);
return false; return false;
}; };

View File

@@ -3,7 +3,6 @@
goog.provide('ol.interaction.Interaction'); goog.provide('ol.interaction.Interaction');
goog.provide('ol.interaction.InteractionProperty'); goog.provide('ol.interaction.InteractionProperty');
goog.require('goog.asserts');
goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.animation'); goog.require('ol.animation');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.interaction.PinchRotate'); goog.provide('ol.interaction.PinchRotate');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.functions');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol'); goog.require('ol');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
@@ -107,10 +108,10 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
// rotate // rotate
if (this.rotating_) { if (this.rotating_) {
var view = map.getView(); var view = map.getView();
var viewState = view.getState(); var rotation = view.getRotation();
map.render(); map.render();
ol.interaction.Interaction.rotateWithoutConstraints(map, view, ol.interaction.Interaction.rotateWithoutConstraints(map, view,
viewState.rotation + rotationDelta, this.anchor_); rotation + rotationDelta, this.anchor_);
} }
}; };
@@ -127,10 +128,9 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
var view = map.getView(); var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
if (this.rotating_) { if (this.rotating_) {
var viewState = view.getState(); var rotation = view.getRotation();
ol.interaction.Interaction.rotate( ol.interaction.Interaction.rotate(
map, view, viewState.rotation, this.anchor_, map, view, rotation, this.anchor_, ol.ROTATE_ANIMATION_DURATION);
ol.ROTATE_ANIMATION_DURATION);
} }
return false; return false;
} else { } else {

View File

@@ -1,6 +1,7 @@
goog.provide('ol.interaction.PinchZoom'); goog.provide('ol.interaction.PinchZoom');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.functions');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
@@ -84,7 +85,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
var viewState = view.getState(); var resolution = view.getResolution();
// scale anchor point. // scale anchor point.
var viewportPosition = goog.style.getClientPosition(map.getViewport()); var viewportPosition = goog.style.getClientPosition(map.getViewport());
@@ -97,7 +98,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
// scale, bypass the resolution constraint // scale, bypass the resolution constraint
map.render(); map.render();
ol.interaction.Interaction.zoomWithoutConstraints( ol.interaction.Interaction.zoomWithoutConstraints(
map, view, viewState.resolution * scaleDelta, this.anchor_); map, view, resolution * scaleDelta, this.anchor_);
}; };
@@ -108,18 +109,17 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.PinchZoom} * @this {ol.interaction.PinchZoom}
* @private * @private
*/ */
ol.interaction.PinchZoom.handleUpEvent_ = ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) {
function(mapBrowserEvent) {
if (this.targetPointers.length < 2) { if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
var viewState = view.getState(); var resolution = view.getResolution();
// Zoom to final resolution, with an animation, and provide a // Zoom to final resolution, with an animation, and provide a
// direction not to zoom out/in if user was pinching in/out. // direction not to zoom out/in if user was pinching in/out.
// Direction is > 0 if pinching out, and < 0 if pinching in. // Direction is > 0 if pinching out, and < 0 if pinching in.
var direction = this.lastScaleDelta_ - 1; var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.zoom(map, view, viewState.resolution, ol.interaction.Interaction.zoom(map, view, resolution,
this.anchor_, this.duration_, direction); this.anchor_, this.duration_, direction);
return false; return false;
} else { } else {
@@ -134,8 +134,7 @@ ol.interaction.PinchZoom.handleUpEvent_ =
* @this {ol.interaction.PinchZoom} * @this {ol.interaction.PinchZoom}
* @private * @private
*/ */
ol.interaction.PinchZoom.handleDownEvent_ = ol.interaction.PinchZoom.handleDownEvent_ = function(mapBrowserEvent) {
function(mapBrowserEvent) {
if (this.targetPointers.length >= 2) { if (this.targetPointers.length >= 2) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
this.anchor_ = null; this.anchor_ = null;

View File

@@ -1,6 +1,5 @@
goog.provide('ol.interaction.Pointer'); goog.provide('ol.interaction.Pointer');
goog.require('goog.asserts');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserEvent.EventType');

View File

@@ -62,6 +62,12 @@ ol.interaction.Select = function(opt_options) {
this.toggleCondition_ = goog.isDef(options.toggleCondition) ? this.toggleCondition_ = goog.isDef(options.toggleCondition) ?
options.toggleCondition : ol.events.condition.shiftKeyOnly; options.toggleCondition : ol.events.condition.shiftKeyOnly;
/**
* @private
* @type {boolean}
*/
this.multi_ = goog.isDef(options.multi) ? options.multi : false;
var layerFilter; var layerFilter;
if (goog.isDef(options.layers)) { if (goog.isDef(options.layers)) {
if (goog.isFunction(options.layers)) { if (goog.isFunction(options.layers)) {
@@ -132,34 +138,36 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
var set = !add && !remove && !toggle; var set = !add && !remove && !toggle;
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var features = this.featureOverlay_.getFeatures(); var features = this.featureOverlay_.getFeatures();
var /** @type {Array.<ol.Feature>} */ deselected = [];
var /** @type {Array.<ol.Feature>} */ selected = [];
if (set) { if (set) {
// Replace the currently selected feature(s) with the feature at the pixel, // Replace the currently selected feature(s) with the feature(s) at the
// or clear the selected feature(s) if there is no feature at the pixel. // pixel, or clear the selected feature(s) if there is no feature at
/** @type {ol.Feature|undefined} */ // the pixel.
var feature = map.forEachFeatureAtPixel(mapBrowserEvent.pixel, map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
* @param {ol.layer.Layer} layer Layer. * @param {ol.layer.Layer} layer Layer.
*/ */
function(feature, layer) { function(feature, layer) {
return feature; selected.push(feature);
}, undefined, this.layerFilter_); }, undefined, this.layerFilter_);
if (goog.isDef(feature) && if (selected.length > 0 &&
features.getLength() == 1 && features.getLength() == 1 &&
features.item(0) == feature) { features.item(0) == selected[selected.length - 1]) {
// No change // No change
} else { } else {
if (features.getLength() !== 0) { if (features.getLength() !== 0) {
features.clear(); features.clear();
} }
if (goog.isDef(feature)) { if (this.multi_) {
features.push(feature); features.extend(selected);
} else if (selected.length > 0) {
features.push(selected[selected.length - 1]);
} }
} }
} else { } else {
// Modify the currently selected feature(s). // Modify the currently selected feature(s).
var /** @type {Array.<ol.Feature>} */ deselected = [];
var /** @type {Array.<ol.Feature>} */ selected = [];
map.forEachFeatureAtPixel(mapBrowserEvent.pixel, map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.

View File

@@ -3,6 +3,7 @@ goog.provide('ol.layer.Heatmap');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.object');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
@@ -36,7 +37,14 @@ ol.layer.HeatmapLayerProperty = {
ol.layer.Heatmap = function(opt_options) { ol.layer.Heatmap = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = goog.isDef(opt_options) ? opt_options : {};
goog.base(this, /** @type {olx.layer.VectorOptions} */ (options)); var baseOptions = goog.object.clone(options);
delete baseOptions.gradient;
delete baseOptions.radius;
delete baseOptions.blur;
delete baseOptions.shadow;
delete baseOptions.weight;
goog.base(this, /** @type {olx.layer.VectorOptions} */ (baseOptions));
/** /**
* @private * @private

View File

@@ -1,6 +1,5 @@
goog.provide('ol.layer.Layer'); goog.provide('ol.layer.Layer');
goog.require('goog.asserts');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.object'); goog.require('goog.object');

View File

@@ -87,13 +87,12 @@ goog.inherits(ol.layer.Base, ol.Object);
/** /**
* @return {number|undefined} The brightness of the layer. * @return {number} The brightness of the layer.
* @observable * @observable
* @api * @api
*/ */
ol.layer.Base.prototype.getBrightness = function() { ol.layer.Base.prototype.getBrightness = function() {
return /** @type {number|undefined} */ ( return /** @type {number} */ (this.get(ol.layer.LayerProperty.BRIGHTNESS));
this.get(ol.layer.LayerProperty.BRIGHTNESS));
}; };
goog.exportProperty( goog.exportProperty(
ol.layer.Base.prototype, ol.layer.Base.prototype,
@@ -102,13 +101,12 @@ goog.exportProperty(
/** /**
* @return {number|undefined} The contrast of the layer. * @return {number} The contrast of the layer.
* @observable * @observable
* @api * @api
*/ */
ol.layer.Base.prototype.getContrast = function() { ol.layer.Base.prototype.getContrast = function() {
return /** @type {number|undefined} */ ( return /** @type {number} */ (this.get(ol.layer.LayerProperty.CONTRAST));
this.get(ol.layer.LayerProperty.CONTRAST));
}; };
goog.exportProperty( goog.exportProperty(
ol.layer.Base.prototype, ol.layer.Base.prototype,
@@ -117,12 +115,12 @@ goog.exportProperty(
/** /**
* @return {number|undefined} The hue of the layer. * @return {number} The hue of the layer.
* @observable * @observable
* @api * @api
*/ */
ol.layer.Base.prototype.getHue = function() { ol.layer.Base.prototype.getHue = function() {
return /** @type {number|undefined} */ (this.get(ol.layer.LayerProperty.HUE)); return /** @type {number} */ (this.get(ol.layer.LayerProperty.HUE));
}; };
goog.exportProperty( goog.exportProperty(
ol.layer.Base.prototype, ol.layer.Base.prototype,
@@ -146,16 +144,16 @@ ol.layer.Base.prototype.getLayerState = function() {
var minResolution = this.getMinResolution(); var minResolution = this.getMinResolution();
return { return {
layer: /** @type {ol.layer.Layer} */ (this), layer: /** @type {ol.layer.Layer} */ (this),
brightness: goog.isDef(brightness) ? goog.math.clamp(brightness, -1, 1) : 0, brightness: goog.math.clamp(brightness, -1, 1),
contrast: goog.isDef(contrast) ? Math.max(contrast, 0) : 1, contrast: Math.max(contrast, 0),
hue: goog.isDef(hue) ? hue : 0, hue: hue,
opacity: goog.isDef(opacity) ? goog.math.clamp(opacity, 0, 1) : 1, opacity: goog.math.clamp(opacity, 0, 1),
saturation: goog.isDef(saturation) ? Math.max(saturation, 0) : 1, saturation: Math.max(saturation, 0),
sourceState: sourceState, sourceState: sourceState,
visible: goog.isDef(visible) ? !!visible : true, visible: visible,
extent: extent, extent: extent,
maxResolution: goog.isDef(maxResolution) ? maxResolution : Infinity, maxResolution: maxResolution,
minResolution: goog.isDef(minResolution) ? Math.max(minResolution, 0) : 0 minResolution: Math.max(minResolution, 0)
}; };
}; };
@@ -192,12 +190,12 @@ goog.exportProperty(
/** /**
* @return {number|undefined} The maximum resolution of the layer. * @return {number} The maximum resolution of the layer.
* @observable * @observable
* @api stable * @api stable
*/ */
ol.layer.Base.prototype.getMaxResolution = function() { ol.layer.Base.prototype.getMaxResolution = function() {
return /** @type {number|undefined} */ ( return /** @type {number} */ (
this.get(ol.layer.LayerProperty.MAX_RESOLUTION)); this.get(ol.layer.LayerProperty.MAX_RESOLUTION));
}; };
goog.exportProperty( goog.exportProperty(
@@ -207,12 +205,12 @@ goog.exportProperty(
/** /**
* @return {number|undefined} The minimum resolution of the layer. * @return {number} The minimum resolution of the layer.
* @observable * @observable
* @api stable * @api stable
*/ */
ol.layer.Base.prototype.getMinResolution = function() { ol.layer.Base.prototype.getMinResolution = function() {
return /** @type {number|undefined} */ ( return /** @type {number} */ (
this.get(ol.layer.LayerProperty.MIN_RESOLUTION)); this.get(ol.layer.LayerProperty.MIN_RESOLUTION));
}; };
goog.exportProperty( goog.exportProperty(
@@ -222,13 +220,12 @@ goog.exportProperty(
/** /**
* @return {number|undefined} The opacity of the layer. * @return {number} The opacity of the layer.
* @observable * @observable
* @api stable * @api stable
*/ */
ol.layer.Base.prototype.getOpacity = function() { ol.layer.Base.prototype.getOpacity = function() {
return /** @type {number|undefined} */ ( return /** @type {number} */ (this.get(ol.layer.LayerProperty.OPACITY));
this.get(ol.layer.LayerProperty.OPACITY));
}; };
goog.exportProperty( goog.exportProperty(
ol.layer.Base.prototype, ol.layer.Base.prototype,
@@ -237,13 +234,12 @@ goog.exportProperty(
/** /**
* @return {number|undefined} The saturation of the layer. * @return {number} The saturation of the layer.
* @observable * @observable
* @api * @api
*/ */
ol.layer.Base.prototype.getSaturation = function() { ol.layer.Base.prototype.getSaturation = function() {
return /** @type {number|undefined} */ ( return /** @type {number} */ (this.get(ol.layer.LayerProperty.SATURATION));
this.get(ol.layer.LayerProperty.SATURATION));
}; };
goog.exportProperty( goog.exportProperty(
ol.layer.Base.prototype, ol.layer.Base.prototype,
@@ -258,13 +254,12 @@ ol.layer.Base.prototype.getSourceState = goog.abstractMethod;
/** /**
* @return {boolean|undefined} The visiblity of the layer. * @return {boolean} The visibility of the layer.
* @observable * @observable
* @api stable * @api stable
*/ */
ol.layer.Base.prototype.getVisible = function() { ol.layer.Base.prototype.getVisible = function() {
return /** @type {boolean|undefined} */ ( return /** @type {boolean} */ (this.get(ol.layer.LayerProperty.VISIBLE));
this.get(ol.layer.LayerProperty.VISIBLE));
}; };
goog.exportProperty( goog.exportProperty(
ol.layer.Base.prototype, ol.layer.Base.prototype,
@@ -290,7 +285,7 @@ goog.exportProperty(
* [2] https://github.com/WebKit/webkit/commit/8f4765e569 * [2] https://github.com/WebKit/webkit/commit/8f4765e569
* [3] https://www.w3.org/Bugs/Public/show_bug.cgi?id=15647 * [3] https://www.w3.org/Bugs/Public/show_bug.cgi?id=15647
* *
* @param {number|undefined} brightness The brightness of the layer. * @param {number} brightness The brightness of the layer.
* @observable * @observable
* @api * @api
*/ */
@@ -308,7 +303,7 @@ goog.exportProperty(
* grey. A value of 1 will leave the contrast unchanged. Other values are * grey. A value of 1 will leave the contrast unchanged. Other values are
* linear multipliers on the effect (and values over 1 are permitted). * linear multipliers on the effect (and values over 1 are permitted).
* *
* @param {number|undefined} contrast The contrast of the layer. * @param {number} contrast The contrast of the layer.
* @observable * @observable
* @api * @api
*/ */
@@ -324,7 +319,7 @@ goog.exportProperty(
/** /**
* Apply a hue-rotation to the layer. A value of 0 will leave the hue * Apply a hue-rotation to the layer. A value of 0 will leave the hue
* unchanged. Other values are radians around the color circle. * unchanged. Other values are radians around the color circle.
* @param {number|undefined} hue The hue of the layer. * @param {number} hue The hue of the layer.
* @observable * @observable
* @api * @api
*/ */
@@ -354,7 +349,7 @@ goog.exportProperty(
/** /**
* @param {number|undefined} maxResolution The maximum resolution of the layer. * @param {number} maxResolution The maximum resolution of the layer.
* @observable * @observable
* @api stable * @api stable
*/ */
@@ -368,7 +363,7 @@ goog.exportProperty(
/** /**
* @param {number|undefined} minResolution The minimum resolution of the layer. * @param {number} minResolution The minimum resolution of the layer.
* @observable * @observable
* @api stable * @api stable
*/ */
@@ -382,7 +377,7 @@ goog.exportProperty(
/** /**
* @param {number|undefined} opacity The opacity of the layer. * @param {number} opacity The opacity of the layer.
* @observable * @observable
* @api stable * @api stable
*/ */
@@ -401,7 +396,7 @@ goog.exportProperty(
* values are linear multipliers of the effect (and values over 1 are * values are linear multipliers of the effect (and values over 1 are
* permitted). * permitted).
* *
* @param {number|undefined} saturation The saturation of the layer. * @param {number} saturation The saturation of the layer.
* @observable * @observable
* @api * @api
*/ */
@@ -415,7 +410,7 @@ goog.exportProperty(
/** /**
* @param {boolean|undefined} visible The visiblity of the layer. * @param {boolean} visible The visibility of the layer.
* @observable * @observable
* @api stable * @api stable
*/ */

View File

@@ -58,7 +58,7 @@ ol.layer.Group = function(opt_options) {
if (goog.isDefAndNotNull(layers)) { if (goog.isDefAndNotNull(layers)) {
if (goog.isArray(layers)) { if (goog.isArray(layers)) {
layers = new ol.Collection(goog.array.clone(layers)); layers = new ol.Collection(layers.slice());
} else { } else {
goog.asserts.assertInstanceof(layers, ol.Collection); goog.asserts.assertInstanceof(layers, ol.Collection);
layers = layers; layers = layers;

View File

@@ -1,5 +1,6 @@
goog.provide('ol.layer.Tile'); goog.provide('ol.layer.Tile');
goog.require('goog.object');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
@@ -29,19 +30,27 @@ ol.layer.TileProperty = {
*/ */
ol.layer.Tile = function(opt_options) { ol.layer.Tile = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = goog.isDef(opt_options) ? opt_options : {};
goog.base(this, /** @type {olx.layer.LayerOptions} */ (options));
var baseOptions = goog.object.clone(options);
delete baseOptions.preload;
delete baseOptions.useInterimTilesOnError;
goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions));
this.setPreload(goog.isDef(options.preload) ? options.preload : 0);
this.setUseInterimTilesOnError(goog.isDef(options.useInterimTilesOnError) ?
options.useInterimTilesOnError : true);
}; };
goog.inherits(ol.layer.Tile, ol.layer.Layer); goog.inherits(ol.layer.Tile, ol.layer.Layer);
/** /**
* @return {number|undefined} The level to preload tiles up to. * @return {number} The level to preload tiles up to.
* @observable * @observable
* @api * @api
*/ */
ol.layer.Tile.prototype.getPreload = function() { ol.layer.Tile.prototype.getPreload = function() {
return /** @type {number|undefined} */ ( return /** @type {number} */ (this.get(ol.layer.TileProperty.PRELOAD));
this.get(ol.layer.TileProperty.PRELOAD));
}; };
goog.exportProperty( goog.exportProperty(
ol.layer.Tile.prototype, ol.layer.Tile.prototype,
@@ -72,12 +81,12 @@ goog.exportProperty(
/** /**
* @return {boolean|undefined} Use interim tiles on error. * @return {boolean} Use interim tiles on error.
* @observable * @observable
* @api * @api
*/ */
ol.layer.Tile.prototype.getUseInterimTilesOnError = function() { ol.layer.Tile.prototype.getUseInterimTilesOnError = function() {
return /** @type {boolean|undefined} */ ( return /** @type {boolean} */ (
this.get(ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR)); this.get(ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR));
}; };
goog.exportProperty( goog.exportProperty(
@@ -87,7 +96,7 @@ goog.exportProperty(
/** /**
* @param {boolean|undefined} useInterimTilesOnError Use interim tiles on error. * @param {boolean} useInterimTilesOnError Use interim tiles on error.
* @observable * @observable
* @api * @api
*/ */

View File

@@ -35,6 +35,8 @@ ol.layer.Vector = function(opt_options) {
var baseOptions = goog.object.clone(options); var baseOptions = goog.object.clone(options);
delete baseOptions.style; delete baseOptions.style;
delete baseOptions.renderBuffer;
delete baseOptions.updateWhileAnimating;
goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions));
/** /**
@@ -60,6 +62,13 @@ ol.layer.Vector = function(opt_options) {
this.setStyle(options.style); this.setStyle(options.style);
/**
* @type {boolean}
* @private
*/
this.updateWhileAnimating_ = goog.isDef(options.updateWhileAnimating) ?
options.updateWhileAnimating : false;
}; };
goog.inherits(ol.layer.Vector, ol.layer.Layer); goog.inherits(ol.layer.Vector, ol.layer.Layer);
@@ -112,6 +121,15 @@ ol.layer.Vector.prototype.getStyleFunction = function() {
}; };
/**
* @return {boolean} Whether the rendered layer should be updated while
* animating.
*/
ol.layer.Vector.prototype.getUpdateWhileAnimating = function() {
return this.updateWhileAnimating_;
};
/** /**
* @param {function(ol.Feature, ol.Feature):number|null|undefined} renderOrder * @param {function(ol.Feature, ol.Feature):number|null|undefined} renderOrder
* Render order. * Render order.

View File

@@ -5,7 +5,6 @@
goog.provide('ol.Map'); goog.provide('ol.Map');
goog.provide('ol.MapProperty'); goog.provide('ol.MapProperty');
goog.require('goog.Uri.QueryData');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.async.AnimationDelay'); goog.require('goog.async.AnimationDelay');
@@ -22,6 +21,7 @@ goog.require('goog.events.KeyHandler');
goog.require('goog.events.KeyHandler.EventType'); goog.require('goog.events.KeyHandler.EventType');
goog.require('goog.events.MouseWheelHandler'); goog.require('goog.events.MouseWheelHandler');
goog.require('goog.events.MouseWheelHandler.EventType'); goog.require('goog.events.MouseWheelHandler.EventType');
goog.require('goog.functions');
goog.require('goog.log'); goog.require('goog.log');
goog.require('goog.log.Level'); goog.require('goog.log.Level');
goog.require('goog.object'); goog.require('goog.object');
@@ -165,6 +165,21 @@ ol.Map = function(options) {
var optionsInternal = ol.Map.createOptionsInternal(options); var optionsInternal = ol.Map.createOptionsInternal(options);
/**
* @type {boolean}
* @private
*/
this.loadTilesWhileAnimating_ = goog.isDef(options.loadTilesWhileAnimating) ?
options.loadTilesWhileAnimating : false;
/**
* @type {boolean}
* @private
*/
this.loadTilesWhileInteracting_ =
goog.isDef(options.loadTilesWhileInteracting) ?
options.loadTilesWhileInteracting : false;
/** /**
* @private * @private
* @type {number} * @type {number}
@@ -302,12 +317,6 @@ ol.Map = function(options) {
*/ */
this.controls_ = optionsInternal.controls; this.controls_ = optionsInternal.controls;
/**
* @type {olx.DeviceOptions}
* @private
*/
this.deviceOptions_ = optionsInternal.deviceOptions;
/** /**
* @type {ol.Collection.<ol.interaction.Interaction>} * @type {ol.Collection.<ol.interaction.Interaction>}
* @private * @private
@@ -574,12 +583,77 @@ ol.Map.prototype.forEachFeatureAtPixel =
var layerFilter = goog.isDef(opt_layerFilter) ? var layerFilter = goog.isDef(opt_layerFilter) ?
opt_layerFilter : goog.functions.TRUE; opt_layerFilter : goog.functions.TRUE;
var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null; var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null;
return this.renderer_.forEachFeatureAtPixel( return this.renderer_.forEachFeatureAtCoordinate(
coordinate, this.frameState_, callback, thisArg, coordinate, this.frameState_, callback, thisArg,
layerFilter, thisArg2); layerFilter, thisArg2);
}; };
/**
* Detect layers that have a color value at a pixel on the viewport, and
* execute a callback with each matching layer. Layers included in the
* detection can be configured through `opt_layerFilter`. Feature overlays will
* always be included in the detection.
* @param {ol.Pixel} pixel Pixel.
* @param {function(this: S, ol.layer.Layer): T} callback Layer
* callback. If the detected feature is not on a layer, but on a
* {@link ol.FeatureOverlay}, then the argument to this function will
* be `null`. To stop detection, callback functions can return a truthy
* value.
* @param {S=} opt_this Value to use as `this` when executing `callback`.
* @param {(function(this: U, ol.layer.Layer): boolean)=} opt_layerFilter Layer
* filter function, only layers which are visible and for which this
* function returns `true` will be tested for features. By default, all
* visible layers will be tested. Feature overlays will always be tested.
* @param {U=} opt_this2 Value to use as `this` when executing `layerFilter`.
* @return {T|undefined} Callback result, i.e. the return value of last
* callback execution, or the first truthy callback return value.
* @template S,T,U
* @api stable
*/
ol.Map.prototype.forEachLayerAtPixel =
function(pixel, callback, opt_this, opt_layerFilter, opt_this2) {
if (goog.isNull(this.frameState_)) {
return;
}
var thisArg = goog.isDef(opt_this) ? opt_this : null;
var layerFilter = goog.isDef(opt_layerFilter) ?
opt_layerFilter : goog.functions.TRUE;
var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null;
return this.renderer_.forEachLayerAtPixel(
pixel, this.frameState_, callback, thisArg,
layerFilter, thisArg2);
};
/**
* Detect if features intersect a pixel on the viewport. Layers included in the
* detection can be configured through `opt_layerFilter`. Feature overlays will
* always be included in the detection.
* @param {ol.Pixel} pixel Pixel.
* @param {(function(this: U, ol.layer.Layer): boolean)=} opt_layerFilter Layer
* filter function, only layers which are visible and for which this
* function returns `true` will be tested for features. By default, all
* visible layers will be tested. Feature overlays will always be tested.
* @param {U=} opt_this Value to use as `this` when executing `layerFilter`.
* @return {boolean} Is there a feature at the given pixel?
* @template U
* @api
*/
ol.Map.prototype.hasFeatureAtPixel =
function(pixel, opt_layerFilter, opt_this) {
if (goog.isNull(this.frameState_)) {
return false;
}
var coordinate = this.getCoordinateFromPixel(pixel);
var layerFilter = goog.isDef(opt_layerFilter) ?
opt_layerFilter : goog.functions.TRUE;
var thisArg = goog.isDef(opt_this) ? opt_this : null;
return this.renderer_.hasFeatureAtCoordinate(
coordinate, this.frameState_, layerFilter, thisArg);
};
/** /**
* Returns the geographical coordinate for a browser event. * Returns the geographical coordinate for a browser event.
* @param {Event} event Event. * @param {Event} event Event.
@@ -598,19 +672,12 @@ ol.Map.prototype.getEventCoordinate = function(event) {
* @api stable * @api stable
*/ */
ol.Map.prototype.getEventPixel = function(event) { ol.Map.prototype.getEventPixel = function(event) {
// Use the offsetX and offsetY values if available. // goog.style.getRelativePosition is based on event.targetTouches,
// See http://www.w3.org/TR/cssom-view/#dom-mouseevent-offsetx and // but touchend and touchcancel events have no targetTouches when
// http://www.w3.org/TR/cssom-view/#dom-mouseevent-offsety // the last finger is removed from the screen.
if (goog.isDef(event.offsetX) && goog.isDef(event.offsetY)) { // So we ourselves compute the position of touch events.
return [event.offsetX, event.offsetY]; // See https://github.com/google/closure-library/pull/323
} else if (goog.isDef(event.changedTouches)) { if (goog.isDef(event.changedTouches)) {
// offsetX and offsetY are not defined for Touch Event
//
// goog.style.getRelativePosition is based on event.targetTouches,
// 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://github.com/google/closure-library/pull/323
var touch = event.changedTouches[0]; var touch = event.changedTouches[0];
var viewportPosition = goog.style.getClientPosition(this.viewport_); var viewportPosition = goog.style.getClientPosition(this.viewport_);
return [ return [
@@ -618,8 +685,6 @@ ol.Map.prototype.getEventPixel = function(event) {
touch.clientY - viewportPosition.y touch.clientY - viewportPosition.y
]; ];
} else { } else {
// Compute offsetX and offsetY values for browsers that don't implement
// cssom-view specification
var eventPosition = goog.style.getRelativePosition(event, this.viewport_); var eventPosition = goog.style.getRelativePosition(event, this.viewport_);
return [eventPosition.x, eventPosition.y]; return [eventPosition.x, eventPosition.y];
} }
@@ -915,15 +980,12 @@ ol.Map.prototype.handlePostRender = function() {
var tileSourceCount = 0; var tileSourceCount = 0;
if (!goog.isNull(frameState)) { if (!goog.isNull(frameState)) {
var hints = frameState.viewHints; var hints = frameState.viewHints;
var deviceOptions = this.deviceOptions_;
if (hints[ol.ViewHint.ANIMATING]) { if (hints[ol.ViewHint.ANIMATING]) {
maxTotalLoading = deviceOptions.loadTilesWhileAnimating === false ? maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0;
0 : 8;
maxNewLoads = 2; maxNewLoads = 2;
} }
if (hints[ol.ViewHint.INTERACTING]) { if (hints[ol.ViewHint.INTERACTING]) {
maxTotalLoading = deviceOptions.loadTilesWhileInteracting === false ? maxTotalLoading = this.loadTilesWhileInteracting_ ? 8 : 0;
0 : 8;
maxNewLoads = 2; maxNewLoads = 2;
} }
tileSourceCount = goog.object.getCount(frameState.wantedTiles); tileSourceCount = goog.object.getCount(frameState.wantedTiles);
@@ -1397,7 +1459,6 @@ ol.Map.prototype.unskipFeature = function(feature) {
/** /**
* @typedef {{controls: ol.Collection.<ol.control.Control>, * @typedef {{controls: ol.Collection.<ol.control.Control>,
* deviceOptions: olx.DeviceOptions,
* interactions: ol.Collection.<ol.interaction.Interaction>, * interactions: ol.Collection.<ol.interaction.Interaction>,
* keyboardEventTarget: (Element|Document), * keyboardEventTarget: (Element|Document),
* logos: Object, * logos: Object,
@@ -1502,7 +1563,7 @@ ol.Map.createOptionsInternal = function(options) {
var controls; var controls;
if (goog.isDef(options.controls)) { if (goog.isDef(options.controls)) {
if (goog.isArray(options.controls)) { if (goog.isArray(options.controls)) {
controls = new ol.Collection(goog.array.clone(options.controls)); controls = new ol.Collection(options.controls.slice());
} else { } else {
goog.asserts.assertInstanceof(options.controls, ol.Collection); goog.asserts.assertInstanceof(options.controls, ol.Collection);
controls = options.controls; controls = options.controls;
@@ -1511,13 +1572,10 @@ ol.Map.createOptionsInternal = function(options) {
controls = ol.control.defaults(); controls = ol.control.defaults();
} }
var deviceOptions = goog.isDef(options.deviceOptions) ?
options.deviceOptions : /** @type {olx.DeviceOptions} */ ({});
var interactions; var interactions;
if (goog.isDef(options.interactions)) { if (goog.isDef(options.interactions)) {
if (goog.isArray(options.interactions)) { if (goog.isArray(options.interactions)) {
interactions = new ol.Collection(goog.array.clone(options.interactions)); interactions = new ol.Collection(options.interactions.slice());
} else { } else {
goog.asserts.assertInstanceof(options.interactions, ol.Collection); goog.asserts.assertInstanceof(options.interactions, ol.Collection);
interactions = options.interactions; interactions = options.interactions;
@@ -1529,7 +1587,7 @@ ol.Map.createOptionsInternal = function(options) {
var overlays; var overlays;
if (goog.isDef(options.overlays)) { if (goog.isDef(options.overlays)) {
if (goog.isArray(options.overlays)) { if (goog.isArray(options.overlays)) {
overlays = new ol.Collection(goog.array.clone(options.overlays)); overlays = new ol.Collection(options.overlays.slice());
} else { } else {
goog.asserts.assertInstanceof(options.overlays, ol.Collection); goog.asserts.assertInstanceof(options.overlays, ol.Collection);
overlays = options.overlays; overlays = options.overlays;
@@ -1540,7 +1598,6 @@ ol.Map.createOptionsInternal = function(options) {
return { return {
controls: controls, controls: controls,
deviceOptions: deviceOptions,
interactions: interactions, interactions: interactions,
keyboardEventTarget: keyboardEventTarget, keyboardEventTarget: keyboardEventTarget,
logos: logos, logos: logos,

View File

@@ -30,9 +30,11 @@ goog.require('ol.pointer.PointerEventHandler');
* @param {string} type Event type. * @param {string} type Event type.
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {goog.events.BrowserEvent} browserEvent Browser event. * @param {goog.events.BrowserEvent} browserEvent Browser event.
* @param {boolean=} opt_dragging Is the map currently being dragged?
* @param {?olx.FrameState=} opt_frameState Frame state. * @param {?olx.FrameState=} opt_frameState Frame state.
*/ */
ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) { ol.MapBrowserEvent = function(type, map, browserEvent, opt_dragging,
opt_frameState) {
goog.base(this, type, map, opt_frameState); goog.base(this, type, map, opt_frameState);
@@ -61,6 +63,15 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) {
*/ */
this.coordinate = map.getCoordinateFromPixel(this.pixel); this.coordinate = map.getCoordinateFromPixel(this.pixel);
/**
* Indicates if the map is currently being dragged. Only set for
* `POINTERDRAG` and `POINTERMOVE` events. Default is `false`.
*
* @type {boolean}
* @api stable
*/
this.dragging = goog.isDef(opt_dragging) ? opt_dragging : false;
}; };
goog.inherits(ol.MapBrowserEvent, ol.MapEvent); goog.inherits(ol.MapBrowserEvent, ol.MapEvent);
@@ -96,11 +107,14 @@ ol.MapBrowserEvent.prototype.stopPropagation = function() {
* @param {string} type Event type. * @param {string} type Event type.
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {ol.pointer.PointerEvent} pointerEvent Pointer event. * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
* @param {boolean=} opt_dragging Is the map currently being dragged?
* @param {?olx.FrameState=} opt_frameState Frame state. * @param {?olx.FrameState=} opt_frameState Frame state.
*/ */
ol.MapBrowserPointerEvent = function(type, map, pointerEvent, opt_frameState) { ol.MapBrowserPointerEvent = function(type, map, pointerEvent, opt_dragging,
opt_frameState) {
goog.base(this, type, map, pointerEvent.browserEvent, opt_frameState); goog.base(this, type, map, pointerEvent.browserEvent, opt_dragging,
opt_frameState);
/** /**
* @const * @const
@@ -139,7 +153,7 @@ ol.MapBrowserEventHandler = function(map) {
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.dragged_ = false; this.dragging_ = false;
/** /**
* @type {Array.<number>} * @type {Array.<number>}
@@ -162,6 +176,8 @@ ol.MapBrowserEventHandler = function(map) {
} }
/** /**
* The most recent "down" type event (or null if none have occurred).
* Set on pointerdown.
* @type {ol.pointer.PointerEvent} * @type {ol.pointer.PointerEvent}
* @private * @private
*/ */
@@ -222,16 +238,6 @@ ol.MapBrowserEventHandler = function(map) {
goog.inherits(ol.MapBrowserEventHandler, goog.events.EventTarget); goog.inherits(ol.MapBrowserEventHandler, goog.events.EventTarget);
/**
* Get the last "down" type event. This will be set on pointerdown.
* @return {ol.pointer.PointerEvent} The most recent "down" type event (or null
* if none have occurred).
*/
ol.MapBrowserEventHandler.prototype.getDown = function() {
return this.down_;
};
/** /**
* @param {goog.events.BrowserEvent} browserEvent Pointer event. * @param {goog.events.BrowserEvent} browserEvent Pointer event.
* @private * @private
@@ -304,22 +310,24 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
ol.MapBrowserEvent.EventType.POINTERUP, this.map_, pointerEvent); ol.MapBrowserEvent.EventType.POINTERUP, this.map_, pointerEvent);
this.dispatchEvent(newEvent); this.dispatchEvent(newEvent);
// We emulate click events on left mouse button click, touch contact, and pen
// contact. isMouseActionButton returns true in these cases (evt.button is set
// to 0).
// See http://www.w3.org/TR/pointerevents/#button-states
if (!this.dragging_ && this.isMouseActionButton_(pointerEvent)) {
goog.asserts.assert(!goog.isNull(this.down_));
this.emulateClick_(this.down_);
}
goog.asserts.assert(this.activePointers_ >= 0); goog.asserts.assert(this.activePointers_ >= 0);
if (this.activePointers_ === 0) { if (this.activePointers_ === 0) {
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey); goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
this.dragListenerKeys_ = null; this.dragListenerKeys_ = null;
this.dragging_ = false;
this.down_ = null;
goog.dispose(this.documentPointerEventHandler_); goog.dispose(this.documentPointerEventHandler_);
this.documentPointerEventHandler_ = null; this.documentPointerEventHandler_ = null;
} }
// We emulate click event on left mouse button click, touch contact, and pen
// contact. isMouseActionButton returns true in these cases (evt.button is set
// to 0).
// See http://www.w3.org/TR/pointerevents/#button-states
if (!this.dragged_ && this.isMouseActionButton_(pointerEvent)) {
goog.asserts.assert(!goog.isNull(this.down_));
this.emulateClick_(this.down_);
}
}; };
@@ -350,7 +358,6 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ =
this.dispatchEvent(newEvent); this.dispatchEvent(newEvent);
this.down_ = pointerEvent; this.down_ = pointerEvent;
this.dragged_ = false;
if (goog.isNull(this.dragListenerKeys_)) { if (goog.isNull(this.dragListenerKeys_)) {
/* Set up a pointer event handler on the `document`, /* Set up a pointer event handler on the `document`,
@@ -399,11 +406,11 @@ ol.MapBrowserEventHandler.prototype.handlePointerMove_ =
// the exact same coordinates of the pointerdown event. To avoid a // the exact same coordinates of the pointerdown event. To avoid a
// 'false' touchmove event to be dispatched , we test if the pointer // 'false' touchmove event to be dispatched , we test if the pointer
// effectively moved. // effectively moved.
if (pointerEvent.clientX != this.down_.clientX || if (this.isMoving_(pointerEvent)) {
pointerEvent.clientY != this.down_.clientY) { this.dragging_ = true;
this.dragged_ = true;
var newEvent = new ol.MapBrowserPointerEvent( var newEvent = new ol.MapBrowserPointerEvent(
ol.MapBrowserEvent.EventType.POINTERDRAG, this.map_, pointerEvent); ol.MapBrowserEvent.EventType.POINTERDRAG, this.map_, pointerEvent,
this.dragging_);
this.dispatchEvent(newEvent); this.dispatchEvent(newEvent);
} }
@@ -422,8 +429,20 @@ ol.MapBrowserEventHandler.prototype.handlePointerMove_ =
* @private * @private
*/ */
ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) { ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) {
var dragging = !goog.isNull(this.down_) && this.isMoving_(pointerEvent);
this.dispatchEvent(new ol.MapBrowserPointerEvent( this.dispatchEvent(new ol.MapBrowserPointerEvent(
pointerEvent.type, this.map_, pointerEvent)); pointerEvent.type, this.map_, pointerEvent, dragging));
};
/**
* @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
* @return {boolean}
* @private
*/
ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) {
return pointerEvent.clientX != this.down_.clientX ||
pointerEvent.clientY != this.down_.clientY;
}; };

View File

@@ -268,7 +268,7 @@ ol.Object.getSetterName = function(key) {
ol.Object.getKeyValue_ = function(obj, key) { ol.Object.getKeyValue_ = function(obj, key) {
var getterName = ol.Object.getGetterName(key); var getterName = ol.Object.getGetterName(key);
var getter = /** @type {function(): *|undefined} */ var getter = /** @type {function(): *|undefined} */
(goog.object.get(obj, getterName)); (/** @type {Object} */ (obj)[getterName]);
return goog.isDef(getter) ? getter.call(obj) : obj.get(key); return goog.isDef(getter) ? getter.call(obj) : obj.get(key);
}; };
@@ -284,7 +284,7 @@ ol.Object.getKeyValue_ = function(obj, key) {
ol.Object.setKeyValue_ = function(obj, key, value) { ol.Object.setKeyValue_ = function(obj, key, value) {
var setterName = ol.Object.getSetterName(key); var setterName = ol.Object.getSetterName(key);
var setter = /** @type {function(*)|undefined} */ var setter = /** @type {function(*)|undefined} */
(goog.object.get(obj, setterName)); (/** @type {Object} */ (obj)[setterName]);
if (goog.isDef(setter)) { if (goog.isDef(setter)) {
setter.call(obj, value); setter.call(obj, value);
} else { } else {

View File

@@ -348,7 +348,8 @@ goog.exportProperty(
/** /**
* Set the position for this overlay. * Set the position for this overlay. If the position is `undefined` the
* overlay is hidden.
* @param {ol.Coordinate|undefined} position The spatial point that the overlay * @param {ol.Coordinate|undefined} position The spatial point that the overlay
* is anchored at. * is anchored at.
* @observable * @observable

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