Compare commits

...

300 Commits

Author SHA1 Message Date
Bart van den Eijnden
f468239e71 Merge pull request #2394 from tonio/style_order
Give precedence to feature styles
2014-07-25 11:34:24 +02:00
Antoine Abt
4b8ceca8eb Move defaults style into style.js 2014-07-25 09:50:53 +02:00
Tim Schaub
10ffc8953b Merge pull request #2436 from tschaub/doc-link
Correct link to API docs.
2014-07-24 14:58:24 -06:00
Tim Schaub
d846fbc0b4 Correct link to API docs 2014-07-24 14:32:34 -06:00
Marc Jansen
f5bb790509 Merge pull request #2167 from elemoine/graticule
Add a Graticule component
2014-07-24 19:13:26 +02:00
Tim Schaub
9fd5c1370e Merge pull request #2316 from tschaub/layer-extent
Support for layers with limited extent.
2014-07-24 10:41:01 -06:00
Tim Schaub
caa0b568ad Remove extent option for sources
Most of our uses of source extent were cargo cult programming.  The source extent was seldom and inconsistently used.  Instead, layers can now be configured with an extent, and layer renderers limit rendering (and data requests) to the layer extent.

For vector sources, the `getExtent` method returns the extent of currently loaded features (this was the case before and after this change).  For tile based sources, we will likely want to allow easy construction of tile grids based on an extent (this is not possible before or after this change, but could be added later).
2014-07-24 10:30:06 -06:00
Tim Schaub
7bbd27e68e ol.tilegrid.TileGrid doesn't accept an extent option
Tile grids cannot currently be constructed with an extent (though we should perhaps provide a function that allows this - see 68815dca10 for an example).
2014-07-24 10:26:07 -06:00
Tim Schaub
2b0284a342 Only request tiles within the layer extent
Layer renderers are now responsible for requesting data within a limited extent.
2014-07-24 10:26:07 -06:00
Tim Schaub
234cff4de5 Limit image layer requests to layer extent
This has two nice consequences that can be seen in the wms-image.js and mapbuide-untiled.js examples:
 * no images are requested when you browse outside of the layer extent
 * when the layer extent is within the viewport extent, cached images are used since the intersecting extent is the same for multiple viewport extents
2014-07-24 10:26:07 -06:00
Tim Schaub
1daf36956c Layer extent option
If provided, the layer extent will be used to limit data requests and rendering.  If undefined, to limit will be imposed.
2014-07-24 10:26:07 -06:00
Tim Schaub
42f953d08d Function for getting extent intersection 2014-07-24 10:26:07 -06:00
Éric Lemoine
e5a0e736ca Add a sphere mollweide example 2014-07-24 17:59:56 +02:00
Éric Lemoine
2365e73bef Add a graticule example 2014-07-24 17:59:56 +02:00
Éric Lemoine
9bd1ab78fc Add Graticule component 2014-07-24 17:59:56 +02:00
Éric Lemoine
9c70a49fb0 Add ol.geom.flat.geodesic
Inspired by #1884 by @twpayne.
2014-07-24 17:59:56 +02:00
Éric Lemoine
9f19569144 Add a worldExtent to ol.proj.Projection 2014-07-24 17:59:56 +02:00
Antoine Abt
9de010c791 Merge pull request #2413 from tonio/logos
Revisit Logos
2014-07-24 17:25:07 +02:00
Frédéric Junod
c25b1e939e Merge pull request #2431 from probins/intro
Update introduction tutorial
2014-07-24 16:54:46 +02:00
Antoine Abt
d50f40dcce Type check with olx.LogoOptions 2014-07-24 16:40:34 +02:00
Antoine Abt
280a7c520f More complete doc for logo option 2014-07-24 15:22:20 +02:00
Antoine Abt
31c9f5806e Wording in docs 2014-07-24 15:22:19 +02:00
Antoine Abt
ba8077010a Add link support for source logos 2014-07-24 15:22:19 +02:00
Antoine Abt
c1f7db9611 Set type=button to avoid forms submit 2014-07-24 15:22:19 +02:00
Antoine Abt
a314203e12 Fixes wording in comments 2014-07-24 15:22:19 +02:00
Antoine Abt
a43c546667 Uncollapse when there’s only logos 2014-07-24 15:22:19 +02:00
Antoine Abt
a71714e8b6 Allow string & object to be passed as map logo 2014-07-24 15:22:18 +02:00
Andreas Hocevar
16cdd35f6d Test to make sure that feature styles take prececence 2014-07-24 14:37:45 +02:00
Andreas Hocevar
c1d49a8cef Update to use the correct default style function namespace 2014-07-24 14:31:12 +02:00
Peter Robins
b945147950 Update introduction tutorial 2014-07-24 11:08:20 +00:00
Frédéric Junod
b29195639f Merge pull request #2429 from fredj/reuse-pixel-for-coord
Reuse event pixel to compute the coordinate
2014-07-24 07:54:39 +02:00
Frederic Junod
b2e345c407 Reuse event pixel to compute the coordinate 2014-07-23 16:53:56 +02:00
Antoine Abt
7fbc4e3bff Rename ol3Logo to logo in map options 2014-07-23 16:27:01 +02:00
Frédéric Junod
d3e575339b Merge pull request #2427 from fredj/misc
Revert "Add FIXME"
2014-07-23 13:55:11 +02:00
Frederic Junod
9bcafc0fab Revert "Add FIXME"
This reverts commit a4afcd533f.

Code removed in 7fabff5ffa
2014-07-23 13:18:23 +02:00
Marc Jansen
8b7f80c64e Merge pull request #2425 from marcjansen/examples
Add examples to ol.coordinate functions
2014-07-23 09:26:47 +02:00
Marc Jansen
64c03d0f9c Add examples to ol.coordinate functions. 2014-07-23 09:15:50 +02:00
Tim Schaub
e81e030dcd Merge pull request #2424 from tschaub/build-css
Build css if source is newer.
2014-07-22 20:56:47 -06:00
Tim Schaub
288c997322 Build css if source is newer
Previously, build/ol.css wasn't getting rebuilt on updates to css/ol.css.
2014-07-22 14:04:52 -06:00
Frédéric Junod
1d22113420 Merge pull request #2421 from fredj/misc
miscellaneous documentation and coding style fixes
2014-07-22 15:37:06 +02:00
Frédéric Junod
962b94444c Merge pull request #2417 from probins/patch-1
Update buildcfg/readme
2014-07-22 15:30:53 +02:00
Frederic Junod
a8961877e8 Add link to the OSM XML documentation 2014-07-22 15:21:27 +02:00
Frederic Junod
8cf48eac4f Document options default value 2014-07-22 15:11:40 +02:00
Frederic Junod
7b7788973b Remove unnecessary newlines 2014-07-22 15:00:23 +02:00
Peter Robins
ddfe11042b Update buildcfg/readme 2014-07-22 10:00:56 +01:00
Bart van den Eijnden
8e106a2c98 Merge pull request #2403 from bartvde/gpx-write
ol.format.GPX writeFeatures is not working
2014-07-22 10:51:05 +02:00
Andreas Hocevar
8d805c6403 Merge pull request #2415 from probins/debugtile
Document debugtilesource
2014-07-22 10:25:17 +02:00
Peter Robins
3f1f450d5c Document debugtilesource 2014-07-22 08:14:33 +00:00
Tobias Sauerwein
a9d68a1899 Merge pull request #2405 from tsauerwein/kinetic-fast
Improve kinetic effect when panning fast
2014-07-22 08:37:57 +02:00
Tim Schaub
e593e5fb60 Merge pull request #2412 from tschaub/unused-proj
Removing unused ol.proj.CH.
2014-07-21 14:33:02 -06:00
Tim Schaub
74dbd2b3e5 Merge pull request #2404 from tschaub/builds
Two ways to use the library: advanced compilation (prod) or raw/concatenated (dev).
2014-07-21 09:39:32 -06:00
Tim Schaub
aa4ee80033 Removing unused ol.proj.CH 2014-07-21 09:28:48 -06:00
Andreas Hocevar
fa7ff506fc Merge pull request #2406 from ahocevar/scaleline-infinite
Infinite loop in ol.control.ScaleLine
2014-07-21 14:08:36 +02:00
Andreas Hocevar
eb71e8e92d Handle cases where the x-axis distance cannot be calculated 2014-07-21 12:20:51 +02:00
Frédéric Junod
82b921ff06 Merge pull request #2411 from fredj/createMouseEvent
Remove ol.pointer.PointerEvent.createMouseEvent
2014-07-21 11:07:42 +02:00
Frederic Junod
fee4c79757 Remove ol.pointer.PointerEvent.createMouseEvent
The externs declarations for MouseEvent are now fixed upstream
2014-07-21 09:51:26 +02:00
tsauerwein
73951394f9 Ensure that the first point for kinetic is valid 2014-07-21 09:05:32 +02:00
Marc Jansen
434bf0bf42 Merge pull request #2409 from vicb/patch-1
fix: typos in map.js
2014-07-20 17:37:16 +02:00
Victor Berchet
9838687d88 fix: typos in map.js 2014-07-20 17:24:09 +02:00
Tim Schaub
cee5b81ec2 Merge pull request #2408 from gingerik/wkt-apidoc
Fix apidoc for WKT format.
2014-07-19 13:28:46 -06:00
Erik Timmers
71b2bf73de Fix apidoc for WKT format 2014-07-18 22:01:17 +02:00
tsauerwein
02a2c5aceb Start earlier to log points for kinetic 2014-07-18 15:54:38 +02:00
Bart van den Eijnden
dbb72f5080 Conflate ol.format.GPX.V1_1 and ol.format.GXP into ol.format.GXP 2014-07-18 15:11:45 +02:00
Andreas Hocevar
b4f6baa613 Merge pull request #2401 from probins/layerbase
Fix issue with layergroup event docs
2014-07-18 14:19:35 +02:00
Tim Schaub
e9c6e58663 Removing the build-all target
The ol-all.json and ol.json build configurations differ only in their use of the manage_closure_dependencies Compiler option.  I don't think there is value in running both (there are plenty of other compiler options that we don't exercise in this same way).
2014-07-17 21:48:53 -06:00
Tim Schaub
737e063937 Two ways to run the hosted examples: compiled and raw
When viewing the hosted examples, people can load the compiled version of the library or load each script individually.
2014-07-17 21:42:55 -06:00
Tim Schaub
4dc601f30d Generate a ol-debug.js script useful for debugging
Instead of running everything through the Compiler just to remove whitespace, we provide a build that is a simple concatenation of all scripts in dependency order.  This build (ol-debug.js) should never be used in production (the same applies to the old ol-whitespace.js build).  Instead, the intention is that it be used to aid in debugging during development.
2014-07-17 21:33:02 -06:00
Tim Schaub
28a23a11b5 Remove ol-simple.js build
We've proven that we can, but that doesn't mean we should be building with `SIMPLE_OPTIMIZATIONS`.
2014-07-17 21:31:58 -06:00
Andreas Hocevar
3ac7cb58af Merge pull request #2402 from probins/plugins
Fix jshint issues in apidoc/plugins
2014-07-17 13:35:38 +02:00
Peter Robins
346ff9c186 Fix jshint issues in apidoc/plugins 2014-07-17 09:50:31 +00:00
Peter Robins
4dccb32545 Fix issue with layergroup event docs 2014-07-17 09:24:39 +00:00
Tim Schaub
ad272a1b3a Merge pull request #2399 from tschaub/functions
Annotate functions that are aliases for goog functions.
2014-07-17 01:11:50 -06:00
Tim Schaub
b0c0d077c9 Annotate always and never conditions as functions 2014-07-16 23:16:51 -06:00
Tim Schaub
12d94e1405 Document ol.inherits and annotate as a function 2014-07-16 23:16:30 -06:00
Paul Spencer
10aa2019e7 Merge pull request #2398 from probins/color
Add color to api docs
2014-07-16 19:35:45 -04:00
Peter Robins
2b1c96a7ea Add color to api docs 2014-07-16 19:50:06 +00:00
Andreas Hocevar
c9d44fe842 Merge pull request #2397 from probins/nav
Docs sidebar in alphanumeric sequence
2014-07-16 18:55:48 +02:00
Andreas Hocevar
e56f759574 Merge pull request #2395 from probins/defaults
Remove classdesc tag from control/interaction defaults
2014-07-16 18:52:23 +02:00
Peter Robins
6a0d08eafd Docs sidebar in alphanumeric sequence 2014-07-16 15:37:03 +00:00
Peter Robins
b77af6d416 Remove classdesc tag from control/interaction defaults 2014-07-16 12:54:18 +00:00
Antoine Abt
b7b5de659b Distinct style function types 2014-07-16 11:25:16 +02:00
Antoine Abt
60f1874766 Give precedence to feature style 2014-07-16 11:25:16 +02:00
Tim Schaub
0b9936107d Merge pull request #2377 from tschaub/portable-config
Make our build configs more portable by using the default src config.
2014-07-15 20:56:25 -06:00
Paul Spencer
7ca069de39 Merge pull request #2311 from probins/tilegrid
Improve docs for tilegrid
2014-07-15 21:12:27 -04:00
Paul Spencer
8383f60fcf Merge pull request #2349 from probins/projdocs
Improve docs for projection
2014-07-15 21:10:33 -04:00
Paul Spencer
aa9dab092a Merge pull request #2387 from bnare/patch-1
Update mapguidesource.js
2014-07-15 21:05:11 -04:00
Paul Spencer
38b36a09bd Merge pull request #2378 from pagameba/doc-feature
Improve documentation for ol.Feature
2014-07-15 20:36:06 -04:00
Tim Schaub
b96fb6ad3a Merge pull request #2345 from tschaub/no-static
Remove static and other attributes from the docs.
2014-07-15 16:54:27 -06:00
Tim Schaub
1cbedadf48 Merge pull request #2390 from tschaub/unit-conversion
Make ol.proj.METERS_PER_UNIT exportable.
2014-07-15 16:26:53 -06:00
Tim Schaub
1657ed2d23 Make ol.proj.METERS_PER_UNIT exportable
We need to apply the `@api` annotation to the object itself in order for it to be exportable.
2014-07-15 15:49:48 -06:00
Tim Schaub
7a26966c8d Merge pull request #2360 from gingerik/wkt-lexer
WKT lexer.
2014-07-15 15:39:31 -06:00
Paul Spencer
685265e1db Improve documentation for ol.Feature 2014-07-15 13:09:43 -04:00
bnare
9e3b46762b Update mapguidesource.js
Add a method updateParams to ol.source.MapGuide.
2014-07-15 17:04:19 +02:00
Erik Timmers
1e7dc5cd32 Add tests for empty & invalid WKT strings 2014-07-15 14:28:05 +02:00
Erik Timmers
4abc887f5d Encode empty geometries as WKT strings 2014-07-15 13:20:58 +02:00
Erik Timmers
fe8a72dce5 Allow for empty Point & GeometryCollection 2014-07-15 13:20:58 +02:00
Tim Schaub
0bd9be547d Merge pull request #2376 from tschaub/transitive
Add packages required by the build task to dependencies.
2014-07-14 17:59:02 -06:00
Tim Schaub
aecaa52cb1 Make our build configs more portable by using the default src config
If a `src` config is not provided, by default, all of the library sources are included.  There is some special handling in the build task to make sure all library sources are included regardless of the path to the build config.  When someone includes a `src` config, path patterns are assumed to be relative to the current working directory (unless overriden with the `cwd` config).  So, when you use the `src` config, your config is no longer portable.
2014-07-14 17:52:10 -06:00
Tim Schaub
4f7073d7aa For jsdoc to find plugins, we need to set the cwd
This allows the `build.js` (and the exports from `generate-info.js`) to be run with a different working directory.
2014-07-14 14:42:42 -06:00
Tim Schaub
4de2520109 Add packages required to build the library to dependencies
This allows other packages to depend on the ol3 package and get the build tools (devDependencies are not installed when they are transitive dependencies).  The justification here is that the ol3 package becomes useful to other packages when you are able to run the build.js task.  For this task to run all of its dependencies must be available.
2014-07-14 14:19:24 -06:00
Andreas Hocevar
4aa76977d2 Merge pull request #2374 from probins/patch-1
Remove duplication from contributing.md
2014-07-14 19:01:50 +02:00
Peter Robins
fe1131b850 Remove duplication from contributing.md 2014-07-14 17:00:28 +01:00
Tim Schaub
a2e7432e42 Merge pull request #2356 from tschaub/regenerate-info
Always regenerate info using all sources if any have changed.
2014-07-14 09:17:36 -06:00
Tim Schaub
d7f4a06f61 Merge pull request #2369 from probins/contribute
Move developer guide from wiki to CONTRIBUTING.md.
2014-07-14 08:59:17 -06:00
Antoine Abt
f57a364534 Merge pull request #2370 from gingerik/classlist
Use goog.dom.classlist functions (2)
2014-07-14 16:09:32 +02:00
Erik Timmers
bd08bfe6c8 Use goog.dom.classlist functions
The goog.dom.classes functions have now been deprecated.
See google/closure-library@97e8a0c
2014-07-14 15:15:16 +02:00
Peter Robins
313e313f7a Move developer guide from wiki to CONTRIBUTING.md 2014-07-14 11:26:49 +00:00
Andreas Hocevar
9131512598 Merge pull request #2367 from probins/collection
Improve Collection docs
2014-07-14 13:18:10 +02:00
Peter Robins
307ee09988 Improve Collection docs 2014-07-14 09:20:25 +00:00
Andreas Hocevar
3e2350b2a0 Merge pull request #2364 from probins/observable
Tag always exported methods as api/observable
2014-07-14 10:53:37 +02:00
Andreas Hocevar
29d581bbee Merge pull request #2365 from probins/patch-1
Fix missing backtick in ol.Object docs
2014-07-14 10:49:36 +02:00
Peter Robins
aa85318d78 Fix missing backtick in ol.Object docs 2014-07-14 09:47:50 +01:00
Peter Robins
97f9527f41 Tag always exported methods as api/observable 2014-07-14 08:23:17 +00:00
Erik Timmers
4c03b3b35c Parse WKT strings using a lexer/parser 2014-07-13 23:09:38 +02:00
Erik Timmers
621aafbdde Encode WKT strings statically 2014-07-13 22:36:12 +02:00
Andreas Hocevar
cc9acef01f Merge pull request #2358 from probins/patch-1
Change docs landing page to link to transformExtent
2014-07-13 17:19:35 +02:00
Marc Jansen
5cd202d50b Merge pull request #2355 from probins/mapelements
Document map DOM elements
2014-07-13 11:05:05 +02:00
Peter Robins
be09368359 Document map DOM elements 2014-07-13 07:47:47 +00:00
Peter Robins
3259b1078c Change docs landing page to link to transformExtent 2014-07-13 08:34:12 +01:00
Tim Schaub
7286c29fbc Merge pull request #2343 from tschaub/build-cleanups
Build cleanups.
2014-07-13 01:18:01 -06:00
Tim Schaub
847440f30a Merge pull request #2342 from tschaub/private-proj
Make internal proj constructors private.
2014-07-13 01:11:57 -06:00
Tim Schaub
f5830cc8e5 Unused JAVA executable 2014-07-12 14:46:05 -06:00
Tim Schaub
5010596ec0 Unused JAR executable 2014-07-12 14:45:20 -06:00
Tim Schaub
db431ebdc6 No reason for build.py to run generate-exports.js
The doc task does not use the generated exports.js file.
2014-07-12 14:43:50 -06:00
Tim Schaub
df2c14b7af Remove unnecessary linting of generated exports file 2014-07-12 14:43:50 -06:00
Tim Schaub
c93e80a14a Always regenerate info using all sources if any have changed
Because we don't know if a new or modified file includes changes to the class hierarchy, we regenerate info for all sources any time any one has changed.  An alternative would be to generate info first for the new or modified file and then (potentially) regenerate info for more source files in the class hierarchy, but this makes the generate-info.js task far more complicated.
2014-07-12 14:39:18 -06:00
Tim Schaub
543250c88a Merge pull request #2346 from tschaub/clean-css
Minify CSS.
2014-07-12 11:48:12 -06:00
Marc Jansen
59fe635b46 Merge pull request #2350 from probins/obj
Expand on docs for observable properties
2014-07-12 17:51:47 +02:00
Peter Robins
753727c15f Expand on docs for observable properties 2014-07-12 15:28:46 +00:00
Peter Robins
96ec96c4d5 Improve docs for projection 2014-07-12 11:31:38 +00:00
Tim Schaub
046ae42b38 Merge pull request #2347 from tschaub/render-sync
Fix the export map example.
2014-07-11 23:48:16 -06:00
Tim Schaub
a6f921d443 To force a download by setting the href, we need synchronous rendering 2014-07-11 21:49:57 -06:00
Tim Schaub
3e23da7c83 Minify CSS 2014-07-11 21:25:21 -06:00
Tim Schaub
aa4dbde841 Remove static and other attributes from the docs 2014-07-11 19:47:49 -06:00
Éric Lemoine
8c1ad54bd8 Merge pull request #2340 from tsauerwein/view-fitGeometry-maxZoom
Add maxZoom to ol.View.fitGeometry() options
2014-07-11 17:02:18 +02:00
tsauerwein
3b8e182856 Add maxZoom to ol.View.fitGeometry() options 2014-07-11 16:31:01 +02:00
Éric Lemoine
b8c39bd62c Merge pull request #2336 from elemoine/seturl
Add ol.source.TileWMS#setUrls and setUrl
2014-07-11 12:31:00 +02:00
Éric Lemoine
b518466968 Merge pull request #2335 from elemoine/pixelratio-xyz
Add tilePixelRatio option to ol.source.XYZ
2014-07-11 12:17:50 +02:00
Peter Robins
5fb78fb352 Add ol.source.TileWMS#setUrls and setUrl 2014-07-11 12:07:07 +02:00
Petr Pridal
1a933febcd Add tilePixelRatio option to ol.source.XYZ 2014-07-11 12:03:55 +02:00
Éric Lemoine
2b4b2dadf7 Be stricter with the type of ol.source.TileWMS#_urls 2014-07-11 12:03:02 +02:00
Antoine Abt
aafa578805 Merge pull request #2159 from tonio/attributions
Merge Logo control into Attribution
2014-07-11 11:48:21 +02:00
Antoine Abt
e707e918aa Use @api annotation 2014-07-11 10:31:03 +02:00
Antoine Abt
1c8fc8358a Remove reference to ol-logo 2014-07-11 10:31:03 +02:00
Antoine Abt
f0f9291161 Add attributions example
Showing how to dynamically change collapsed/collapsible properties for ≠
map sizes.
2014-07-11 10:31:03 +02:00
Antoine Abt
4f087f1b84 Add getter/setter for collapsed & collapsible 2014-07-11 10:18:56 +02:00
Antoine Abt
6744713a54 Register button handlers the new way 2014-07-11 10:18:56 +02:00
Antoine Abt
d5d5f58809 Do not collapse Attributions when using OSM source 2014-07-11 10:18:55 +02:00
Antoine Abt
4d150e6b84 Move Logos in attributions 2014-07-11 09:53:25 +02:00
Antoine Abt
da74fbf529 Remove Logo Control 2014-07-11 09:53:25 +02:00
Antoine Abt
aeaa172abe Remove Logo Control from defaults 2014-07-11 09:36:14 +02:00
Antoine Abt
5a1e92830f Make attribution control collapsible. 2014-07-11 09:36:14 +02:00
Tim Schaub
521cbfb1b0 Make internal proj constructors private 2014-07-10 16:37:07 -06:00
Andreas Hocevar
121d19e0ba Merge pull request #2333 from ahocevar/better-proj4-check
Check for proj4 in a way that also works in module environments
2014-07-10 20:36:52 +02:00
Andreas Hocevar
1d26c1faaf Check for proj4 in a way that also works in module environments 2014-07-10 20:23:33 +02:00
Andreas Hocevar
512c2032ed Merge pull request #2330 from ahocevar/proj4-global
Safeguard against cases where no projection and no proj4 is available
2014-07-10 18:53:26 +02:00
Éric Lemoine
31fa59c996 Merge pull request #2329 from tsauerwein/multipolygon-empty-array
Also accept empty array for ol.geom.MultiPolygon
2014-07-10 18:35:43 +02:00
Andreas Hocevar
19757ae3e0 Safeguard against cases where no projection and no proj4 is available 2014-07-10 18:32:29 +02:00
tsauerwein
7c22d8ffd4 Also accept empty array for ol.geom.MultiPolygon 2014-07-10 17:18:24 +02:00
Bart van den Eijnden
ea7c32ff6e Merge pull request #2255 from elemoine/complexgeom
Fix canvas immediate API for cases where stride ≠ 2
2014-07-10 17:03:57 +02:00
Bart van den Eijnden
60c7564268 Add test case for 3D geometries in immediate API 2014-07-10 16:51:07 +02:00
Éric Lemoine
d57a35ffcb Fix stride related bug in Canvas immediate API 2014-07-10 14:21:56 +02:00
Paul Spencer
9dc17230c2 Merge pull request #2323 from pagameba/fix-addfeatures
ServerVector addFeaturesInternal fails when features lack an id
2014-07-10 08:08:54 -04:00
Paul Spencer
a02d21d4b5 Allow addFeaturesInternal to add multiple features lacking an id 2014-07-10 07:32:20 -04:00
Andreas Hocevar
9640a08c0e Merge pull request #1228 from ahocevar/new-proj4js
Use the new proj4.js
2014-07-10 13:31:17 +02:00
Éric Lemoine
a737cf0d99 Merge pull request #2326 from probins/osmxml
Change examples/vector-osm to use transformExtent
2014-07-10 13:20:19 +02:00
Éric Lemoine
7789bff3da Add explanations to wms-custom-proj example 2014-07-10 13:17:24 +02:00
Peter Robins
8e2a12bfc1 Change examples/vector-osm to use transformExtent 2014-07-10 11:07:39 +00:00
Éric Lemoine
4541019ff4 Merge pull request #2325 from elemoine/imagevector
Pass tolerance to ReplayGroup
2014-07-10 11:24:18 +02:00
Éric Lemoine
49b91998f9 Pass tolerance to ReplayGroup
The tolerance instead of the squared tolerance must be passed to the ReplayGroup constructor.
2014-07-10 09:52:13 +02:00
Andreas Hocevar
193adf4401 Move Swiss transform functions to the .js file 2014-07-09 21:24:42 +02:00
Andreas Hocevar
1ae82b054c Revert to only accept ol.proj.Projection as argument 2014-07-09 18:12:07 +02:00
Andreas Hocevar
1bb5705b55 Clean up after testing 2014-07-09 18:11:22 +02:00
Andreas Hocevar
8f1fdde26e Show both Proj4js and custom transform functions in examples 2014-07-09 18:09:23 +02:00
Éric Lemoine
4cf8383820 Avoid a type-cast 2014-07-09 17:51:24 +02:00
Andreas Hocevar
fc3ed93080 Use proj4.js from node_modules/ instead of copying it to build/ 2014-07-09 15:33:13 +02:00
Andreas Hocevar
0a01f8ef7e Simplify ol.proj.addCoordinateTransforms
Equivalent projections do not need to be handled here, and the forward
and inverse functions can be function arguments instead of being nested
in an object literal.
2014-07-09 15:33:13 +02:00
Andreas Hocevar
90c745006d Update to use the documented Proj4js 2.2.x API 2014-07-09 15:33:12 +02:00
Andreas Hocevar
a22d7e4d22 Allow Proj4js to be loaded after OpenLayers 2014-07-09 15:33:12 +02:00
Andreas Hocevar
20e903f8d9 Add proj4 to package.json 2014-07-09 15:32:54 +02:00
Paul Spencer
f1bdaed15a Merge pull request #2177 from pagameba/geometry-api
Add @todo api and describe ol.geom.Geometry funcs
2014-07-09 07:23:32 -04:00
Paul Spencer
4bcbda61c6 Merge pull request #2298 from probins/props
Document that options in layers and properties in features are set as object properties
2014-07-09 07:21:53 -04:00
Peter Robins
b396773183 Improve docs for tilegrid 2014-07-09 06:54:24 -04:00
Peter Robins
17d059f7bb Document that layer options are set as object properties 2014-07-09 06:40:28 -04:00
Peter Robins
9915bb873c Document that feature properties are set as object properties 2014-07-09 06:39:42 -04:00
Paul Spencer
befcc4ceea Merge pull request #2204 from probins/dragbox
Correct/improve dragbox docs
2014-07-08 19:40:55 -04:00
Andreas Hocevar
88ab1ac61a Doc changes suggested by @probins 2014-07-08 22:06:21 +02:00
Andreas Hocevar
8b2277cdda Use proj4.defs instead of proj4.Proj, to conform with the proj4js API 2014-07-08 22:06:21 +02:00
Andreas Hocevar
0c62469f50 Update example to show transparent proj4js integration 2014-07-08 22:06:21 +02:00
Andreas Hocevar
dfe92da58d Update example to show manual proj4js configuration 2014-07-08 22:06:21 +02:00
Andreas Hocevar
b5bdd0d4bb Update tests 2014-07-08 22:06:21 +02:00
Andreas Hocevar
8b89f5b689 Update API to work with custom transforms, including proj4js
All transparent proj4js handling is now in ol.proj.get, and a new
addCoordinateTransforms function makes it easy to configure custom
transform functions. ol.Proj4jsProjection is no longer needed.
2014-07-08 22:06:20 +02:00
Andreas Hocevar
dc09b0a27f Update externs and ol.HAVE_PROJ4JS for new proj4js API 2014-07-08 22:06:20 +02:00
Andreas Hocevar
971c1137bc Download and use new proj4js 2014-07-08 22:06:20 +02:00
Andreas Hocevar
d215696154 Merge pull request #2322 from ahocevar/view-projection
Make sure that projection is an ol.proj.Projection instance
2014-07-08 22:01:21 +02:00
Andreas Hocevar
38bf0b439a Merge pull request #2321 from ahocevar/cleanup-package-json
Remove transient jsdoc dependencies
2014-07-08 21:52:54 +02:00
Andreas Hocevar
82604ff60b Make sure that projection is an ol.proj.Projection instance 2014-07-08 21:41:08 +02:00
Andreas Hocevar
3a0d0c7290 Remove transient jsdoc dependencies
alpha9 has the dependencies fixed again, so no need to keep taffydb and
underscore around.
2014-07-08 21:38:16 +02:00
Tim Schaub
8e555fad5b Merge pull request #2312 from tschaub/test-deps
Move test dependencies out of the repo.
2014-07-07 07:04:42 -06:00
Paul Spencer
570a0c23a7 Merge pull request #2183 from pagameba/classdesc
Use @classdesc notation
2014-07-07 08:30:33 -04:00
Paul Spencer
8d991bd638 Add @todo API and describe ol.geom.Geometry funcs
The `clone()`, `getSimplifiedGeometry()` and `getType()` methods are all
base class methods documented in subclasses.  They should appear in
ol.geom.Geometry in the API docs as well.
2014-07-07 08:29:56 -04:00
Andreas Hocevar
9b1e9dbc8e Merge pull request #2317 from ahocevar/export-transform
Make transform exportable
2014-07-07 11:19:04 +02:00
Andreas Hocevar
1933d809e2 Export transform
ol.ObjectAccessor#transform is used in the bind-input example. Why the
example works without this export is a mystery to me. Either way, we
will want this in the docs.
2014-07-07 10:45:15 +02:00
Tim Schaub
5fdb380fb6 Merge pull request #2315 from tschaub/full-screen
Use goog.dom.fullscreen.
2014-07-06 17:18:44 -06:00
Tim Schaub
9c6cb9db6d Use goog.dom.fullscreen 2014-07-06 16:03:09 -06:00
Tim Schaub
26e6260446 Merge pull request #2313 from tschaub/transform-extent
Add ol.proj.transformExtent function.
2014-07-06 15:33:33 -06:00
Tim Schaub
d0301805c7 Doc flip 2014-07-06 15:26:04 -06:00
Tim Schaub
1f88015db0 Add ol.proj.transformExtent function 2014-07-06 13:22:47 -06:00
Tim Schaub
21878ebad3 Lint 2014-07-06 12:47:33 -06:00
Tim Schaub
7e8551a767 Unused extensions 2014-07-06 12:43:55 -06:00
Tim Schaub
93716fc7f0 Extend expect.js rather than modify the source 2014-07-06 12:40:03 -06:00
Tim Schaub
d8ca8e7341 Update test readme 2014-07-06 11:53:34 -06:00
Tim Schaub
264a01cfd4 Add jquery as a dev dependency 2014-07-06 11:47:58 -06:00
Tim Schaub
8a3f1a8f34 Add mocha and mocha-phantomjs as dev dependencies 2014-07-06 11:40:08 -06:00
Tim Schaub
70cb7a4a0a Add sinon as a dev dependency 2014-07-06 11:21:01 -06:00
Tim Schaub
6f398f93dd Merge pull request #2309 from tschaub/test
Add a task to run the tests once with PhantomJS.
2014-07-06 06:52:13 -06:00
Éric Lemoine
94ba9aeea9 Merge pull request #2296 from elemoine/settileurlfunction
Use inheritDoc for ol.source.XYZ#setTileUrlFunction
2014-07-06 13:21:17 +02:00
Éric Lemoine
4e0d48386b Use inheritDoc for ol.source.XYZ#setTileUrlFunction 2014-07-06 11:49:19 +02:00
Éric Lemoine
76584c3291 Merge pull request #2307 from elemoine/build
Build-related clean-ups
2014-07-06 09:16:11 +02:00
Tim Schaub
b452e04e08 Add a task to run the tests once with PhantomJS
The test.js task starts the development server and runs the tests in PhantomJS.  As mentioned in the readme, when running the tests continuously during development, it is more convenient to start the dev server and visit the root of the test directory in your browser.

Later we can bring in Karma to drive PhantomJS and other browsers, but this simple "run once" task is useful for the CI job.
2014-07-05 19:42:30 -04:00
Éric Lemoine
f18dbcdb97 Remove bin/closure
And use the depswriter.py script from Closure Library downloaded by closure-util.
2014-07-05 23:46:03 +02:00
Éric Lemoine
fa25f2a477 Remove examples/loader.js
That script was used when Plovr was used for running the examples.
2014-07-05 23:36:59 +02:00
Éric Lemoine
043cd0ff41 Remove test/ol.html
This file was used when Plovr was used for running the tests.
2014-07-05 23:34:02 +02:00
Tim Schaub
489096e40b Merge pull request #2305 from tschaub/todo
Replace @todo annotations.
2014-07-05 16:52:45 -04:00
Tim Schaub
1951c385a8 Merge pull request #2306 from tschaub/new
Remove old code.
2014-07-05 16:20:06 -04:00
Tim Schaub
5a24d022cf Extra annotations for build.py as well 2014-07-05 16:19:41 -04:00
Tim Schaub
d99a61545c Use @observable annotation instead of @todo observable 2014-07-05 16:16:44 -04:00
Tim Schaub
fd659d63e9 Remove @todo stability annotation (this has no effect) 2014-07-05 16:16:34 -04:00
Tim Schaub
10f4d0c3d7 Removing old code 2014-07-05 15:54:44 -04:00
Tim Schaub
8b29b52e95 Document olx.format.PolylineOptions
This was mistakenly annotated with `@todo stability` (which does nothing).
2014-07-05 15:43:03 -04:00
Tim Schaub
4cf5ab4620 Use @api annotation instead of @todo api 2014-07-05 15:41:14 -04:00
Éric Lemoine
297503e7c9 Merge pull request #2297 from elemoine/remove-plovr
Remove Plovr
2014-07-04 22:34:26 +02:00
Éric Lemoine
207e23099a Merge pull request #2300 from elemoine/geojson
GeoJSON format needs to implement readProjectionFromObject
2014-07-04 14:44:35 +02:00
Éric Lemoine
0666dee697 GeoJSON format needs to implement readProjectionFromObject 2014-07-04 13:51:27 +02:00
Éric Lemoine
e0a8bb045a Farewell Plovr 2014-07-04 10:51:18 +02:00
Éric Lemoine
c6138edbcb Remove the test.json Plovr config file 2014-07-04 10:51:18 +02:00
Éric Lemoine
52294519bc Remove the base.json Plovr config file 2014-07-04 10:51:18 +02:00
Éric Lemoine
07b02c2a55 Add a buildcfg/readme.md 2014-07-04 10:51:18 +02:00
Éric Lemoine
46149ff6f9 Remove ununsed serve-integration-test target 2014-07-04 10:51:18 +02:00
Éric Lemoine
a4e923cf4b Target integration-test renamed to ci 2014-07-04 10:51:17 +02:00
Éric Lemoine
d1820fbce5 Update .travis.yml 2014-07-04 10:51:17 +02:00
Éric Lemoine
1626399c08 Use serve.js as the test server 2014-07-04 10:51:17 +02:00
Frederic Junod
2064d08602 Refresh the compiler error list
Based on https://github.com/openlayers/closure-util/blob/master/compiler-options.txt
2014-07-04 10:51:17 +02:00
Éric Lemoine
1129e0d934 Get Closure Library from closure-util for host-examples 2014-07-04 10:51:17 +02:00
Frederic Junod
234dd91ff2 Remove some externs declarations
All these declarations are defined in recent versions of Closure Compiler.
2014-07-04 10:51:17 +02:00
Éric Lemoine
f54398eda3 compilation_level is now just ADVANCED and SIMPLE 2014-07-04 10:51:17 +02:00
Éric Lemoine
a157ecd788 Make compiler happy by replacing 0e6 by 0 2014-07-04 10:51:17 +02:00
Éric Lemoine
167d13b4f6 Use closure-util's Closure lib for the check-requires target 2014-07-04 10:51:17 +02:00
Éric Lemoine
8c4a55cc65 Use build.js for compiling the examples all at once 2014-07-04 09:15:23 +02:00
Éric Lemoine
35888d1dc6 Use build.js for compiling the examples 2014-07-04 09:15:23 +02:00
Éric Lemoine
0ae1cd7cf5 Fix a type issue in jquery-1.7 externs
See https://github.com/google/closure-compiler/issues/176
2014-07-04 09:15:23 +02:00
Éric Lemoine
152b434f1b Add jquery-1.7 externs 2014-07-04 09:15:23 +02:00
Éric Lemoine
992e0fa218 Use serve.js instead of the Plovr server 2014-07-04 09:15:23 +02:00
Éric Lemoine
f89abb53a9 Use build.js for ol-all.js 2014-07-04 09:15:23 +02:00
Éric Lemoine
4e8c9c5470 Use build.js for ol-whitespace.js 2014-07-04 09:15:23 +02:00
Éric Lemoine
3ea304f5bf Use build.js for ol-simple.js 2014-07-04 09:15:23 +02:00
Éric Lemoine
04e60a9d37 Use build.js for ol.js 2014-07-04 09:15:22 +02:00
Éric Lemoine
064f95f530 Remove the IE 11 fullscreen externs declarations
They are defined in recent versions of Closure Compiler.
2014-07-04 09:15:22 +02:00
Éric Lemoine
18462a2af3 Merge pull request #2229 from tsauerwein/stable
Add stable tags to interactions
2014-07-04 06:31:13 +02:00
Éric Lemoine
76e1ca67a4 Merge pull request #2269 from probins/select
Improve docs for interaction.Select
2014-07-03 17:07:03 +02:00
Marc Jansen
4fed441eda Merge pull request #2280 from probins/intro
Introduction tutorial
2014-07-03 16:53:55 +02:00
Éric Lemoine
067345a4b0 Merge pull request #2293 from elemoine/vector-wfs
Minor change to vector-wfs example
2014-07-03 14:55:13 +02:00
Éric Lemoine
6abba32707 Minor change to vector-wfs example
My linter complains that vectorSource is used before it is defined.
2014-07-03 14:53:49 +02:00
Éric Lemoine
d8cc019184 Merge pull request #2292 from elemoine/closure-util
Use closure-util 0.19.0
2014-07-03 14:45:03 +02:00
tsauerwein
b8ab6fd771 Add stable tags to interactions 2014-07-03 14:19:16 +02:00
Éric Lemoine
2e541b43d1 Use closure-util 0.19.0 2014-07-03 14:17:01 +02:00
Paul Spencer
abe953e4e5 Use @classdesc notation (continuing #2178) 2014-07-03 08:09:25 -04:00
Paul Spencer
b0a1444da0 Merge pull request #2290 from pagameba/typo
Fix spelling of GEOMETRY_RENDERERS_
2014-07-03 07:33:57 -04:00
Éric Lemoine
450d42a4cc Merge pull request #2276 from elemoine/select
Add "action type" select to select-features example
2014-07-03 12:36:01 +02:00
Peter Robins
90f2f96797 Introduction tutorial 2014-07-03 05:14:25 -04:00
Peter Robins
49aabda1b9 Improve docs for interaction.Select 2014-07-03 04:54:09 -04:00
Éric Lemoine
f8ba6758a2 Add "action type" select to select-features example
Making it possible to choose between three select interactions, one that works on "singleclick", one that works on "click", and one that works on "mousemove".
2014-07-03 09:24:23 +02:00
Éric Lemoine
ef1414c508 Minor apidoc change 2014-07-03 09:14:41 +02:00
Éric Lemoine
355ca67b86 Add ol.events.condition.click 2014-07-03 09:14:41 +02:00
Éric Lemoine
67c2e46c19 Add ol.events.condition.mouseMove 2014-07-03 09:14:41 +02:00
Paul Spencer
a93f7b8190 Fix spelling of GEOMETRY_RENDERERS_ 2014-07-02 21:54:53 -04:00
Marc Jansen
700a0b15b3 Merge pull request #2278 from probins/control
Document custom controls
2014-07-02 18:52:34 +02:00
Marc Jansen
fdf0525c71 Merge pull request #2286 from probins/defines
Improve docs for define tag
2014-07-02 18:45:27 +02:00
Frédéric Junod
17bb8d8ca1 Merge pull request #2288 from fredj/latest-closure-library
Mark the color argument to ol.color.transform non-nullable
2014-07-02 17:44:15 +02:00
Tim Schaub
927513e1f0 Merge pull request #2284 from tschaub/classes
Use `goog.dom.classlist` functions instead of the deprecated `goog.dom.classes` functions.
2014-07-02 10:18:28 -04:00
Éric Lemoine
fe776b0d1a Merge pull request #2287 from tsauerwein/geojson-write-geometry
Export ol.format.GeoJSON.writeGeometry()
2014-07-02 14:46:46 +02:00
Frederic Junod
54ea8dc52b Mark the color argument to ol.color.transform non-nullable
Inside this function goog.vec.Mat4.multVec3 is called and and its
arguments must not be null.
2014-07-02 14:43:29 +02:00
Peter Robins
2e1957c42c Improve docs for define tag 2014-07-02 08:22:23 -04:00
tsauerwein
97e59f0976 Export ol.format.GeoJSON.writeGeometry() 2014-07-02 13:48:51 +02:00
Éric Lemoine
3e49ea2ba0 Merge pull request #2285 from tsauerwein/vector-source-clear
Export ol.source.Vector.clear()
2014-07-02 12:10:46 +02:00
tsauerwein
5adb3a6a8e Export ol.source.Vector.clear() 2014-07-02 11:53:58 +02:00
Frédéric Junod
242787da45 Merge pull request #2283 from fredj/closure-util.json
Fix the closure-compiler and closure-library versions
2014-07-02 10:33:54 +02:00
Frederic Junod
6b230d3711 Fix the closure-library version
The version is the same as the one provided by plovr-81ed862.jar
2014-07-02 10:22:27 +02:00
Frederic Junod
d3234f1b6a Depends on closure-util version 0.18.0 2014-07-02 09:15:02 +02:00
Tim Schaub
4b57f7798f Use goog.dom.classlist functions
The goog.dom.classes functions have now been deprecated.  See 97e8a0c0fc
2014-07-01 14:09:28 -04:00
Tim Schaub
203df11c96 Merge pull request #2281 from tschaub/remove-libtess
Remove libtess.js.
2014-07-01 12:51:48 -04:00
Marc Jansen
a3e332c0c2 Merge pull request #2282 from marcjansen/coordinate-tests
Add more tests to ol.coordinate
2014-07-01 17:14:44 +02:00
Marc Jansen
70548b4704 Add tests for ol.coordinate.equals(). 2014-07-01 17:02:34 +02:00
Marc Jansen
00fd5caa92 Add tests for ol.coordinate.createStringXY(). 2014-07-01 17:02:34 +02:00
Marc Jansen
07b41f84d0 Add tests for ol.coordinate.add(). 2014-07-01 17:02:34 +02:00
Peter Robins
3bbf9ae720 Document custom controls 2014-07-01 09:57:26 -04:00
Tim Schaub
97985934e1 Remove libtess.js 2014-07-01 08:45:09 -04:00
Andreas Hocevar
60f283d5c0 Merge pull request #2279 from ahocevar/show-sketch-vertex
Show sketch vertex for all geometry types
2014-07-01 12:04:40 +02:00
Andreas Hocevar
29370a04aa Show sketch vertex for all geometry types 2014-07-01 11:52:21 +02:00
Peter Robins
c1c98b45b9 Correct/improve dragbox docs 2014-06-20 04:45:12 -04:00
421 changed files with 8628 additions and 39441 deletions

View File

@@ -3,9 +3,6 @@ before_install:
- "npm install -g npm && npm install"
before_script:
- "./build.py plovr"
- "./build.py serve-integration-test &"
- "rm src/ol/renderer/webgl/*shader.js"
- "sleep 3"
script: "./build.py integration-test"
script: "./build.py ci"

View File

@@ -4,18 +4,301 @@ Thanks for your interest in contributing to OpenLayers 3.
## Contributing Code
Our preferred means of receiving contributions is through [pull
requests](https://help.github.com/articles/using-pull-requests).
Our preferred means of receiving contributions is through [pull requests](https://help.github.com/articles/using-pull-requests). Make sure
that your pull request follows our pull request guidelines below before submitting it.
See the [Developer
Guide](https://github.com/openlayers/ol3/wiki/Developer-Guide) to get started
with OpenLayers 3 development. This guide provides information you should know
before creating pull requests.
This page describes what you need to know to contribute code to ol3 as a developer.
Note that, before accepting a contribution, we ask that you provide us
a Contributor License Agreement. If you are making your contribution as part of
work for your employer, please follow the guidelines on submitting a [Corporate
Contributor License Agreement](http://www.openlayers.org/ccla.txt). If you are
## Contributor License Agreement
Before accepting a contribution, we ask that you provide us a Contributor
License Agreement. If you are making your contribution as part of work for
your employer, please follow the guidelines on submitting a [Corporate
Contributor License Agreement](https://raw.github.com/openlayers/cla/master/ccla.txt). If you are
making your contribution as an individual, you can submit a digital [Individual
Contributor License
Agreement](https://docs.google.com/spreadsheet/viewform?formkey=dGNNVUJEMXF2dERTU0FXM3JjNVBQblE6MQ).
Contributor License Agreement](https://docs.google.com/spreadsheet/viewform?formkey=dGNNVUJEMXF2dERTU0FXM3JjNVBQblE6MQ).
## Setting up development environment
You will obviously start by
[forking](https://github.com/openlayers/ol3/fork_select) the ol3 repository.
### Travis CI
The Travis CI hook is enabled on the Github repository. This means every pull request
is run through a full test suite to ensure it compiles and passes the tests. Failing
pull requests will not be merged.
Although not mandatory, it is also recommended to set up Travis CI for your ol3 fork.
For that go to your ol3 fork's Service Hooks page and set up the Travis hook.
Then every time you push to your fork, the test suite will be run. This means
errors can be caught before creating a pull request. For those making
small or occasional contributions, this may be enough to check that your contributions
are ok; in this case, you do not need to install the build tools on your local environment
as described below.
### Development dependencies
The minimum requirements are:
* Git
* [Node.js](http://nodejs.org/)
* Python 2.6 or 2.7 with a couple of extra modules (see below)
* Java 7 (JRE and JDK)
The executables `git`, `java`, `jar`, and `python` should be in your `PATH`.
You can check your configuration by running:
$ ./build.py checkdeps
To install the Node.js dependencies run
$ npm install
To install the extra Python modules, run:
$ sudo pip install -r requirements.txt
or
$ cat requirements.txt | sudo xargs easy_install
depending on your OS and Python installation.
## Working with the build tool
As an ol3 developer you will need to use the `build.py` Python script. This is
the script to use to run the linter, the compiler, the tests, etc. Windows users
can use `build.cmd` which is a thin wrapper around `build.py`.
The `build.py` script is equivalent to a Makefile. It is actually based on
[pake](https://github.com/twpayne/pake/), which is a simple implementation of
`make` in Python.
The usage of the script is:
$ ./build.py <target>
where `<target>` is the name of the build target you want to execute. For
example:
$ ./build.py test
The main build targets are `serve`, `lint`, `build`, `test`, and `check`. The
latter is a meta-target that basically runs `lint`, `build`, and `test`.
The `serve` target starts a node-based web server, which we will refer to as the *dev server*. You'll need to start that server for running the examples and the tests in a browser. More information on that further down.
Other targets include `apidoc` and `ci`. The latter is the target used on Travis CI. See ol3's [Travis configuration file](https://github.com/openlayers/ol3/blob/master/.travis.yml).
## Running the `check` target
The `check` target is to be run before pushing code to GitHub and opening pull
requests. Branches that don't pass `check` won't pass the integration tests,
and have therefore no chance of being merged into `master`.
To run the `check` target:
$ ./build.py check
If you want to run the full suite of integration tests, see "Running the integration
tests" below.
## Running examples
To run the examples you first need to start the dev server:
$ ./build.py serve
Then, just point your browser <http://localhost:3000/examples> in your browser. For example <http://localhost:3000/examples/side-by-side.html>.
Run examples against the `ol.js` standalone build:
The examples can also be run against the `ol.js` standalone lib, just like the examples
[hosted](http://openlayers.github.com/ol3/master/examples/) on GitHub. Start by
executing the `host-examples` build target:
$ ./build.py host-examples
After running `host-examples` you can now open the examples index page in the browser, for example: <http://localhost/~elemoine/ol3/build/hosted/master/examples/>. (This assumes that the `hosted` directory is a web directory, served by Apache for example.)
Append `?mode=raw` to make the example work in full debug mode. In raw mode the OpenLayers and Closure Library scripts are loaded individually by the Closure Library's `base.js` script (which the example page loads and executes before any other script).
## Running tests
To run the tests in a browser start the dev server (`./build.py serve`) and open <http://localhost:3000/test/index.html> in the browser.
To run the tests on the console (headless testing with PhantomJS) use the `test` target:
$ ./build.py test
See also the test-specific [README](../blob/master/test/README.md).
## Running the integration tests
When you submit a pull request the [Travis continuous integration
server](https://travis-ci.org/) will run a full suite of tests, including
building all versions of the library and checking that all of the examples
work. You will receive an email with the results, and the status will be
displayed in the pull request.
To run the full suite of integration tests use the `ci` target:
$ ./build.py ci
Running the full suite of integration tests currently takes 5-10 minutes.
This makes sure that your commit won't break the build. It also runs JSDoc3 to
make sure that there are no invalid API doc directives.
## Adding examples
Adding functionality often implies adding one or several examples. This
section provides explanations related to adding examples.
The examples are located in the `examples` directory. Adding a new example
implies creating two files in this directory, an `.html` file and a `.js` file.
See `examples/simple.html` and `examples/simple.js` for instance.
The `.html` file needs to include a script tag with
`loader.js?id=<example_name>` as its `src`. For example, if the two files for
the example are `myexample.js` and `myexample.html` then the script tag's `src`
should be set to `myexample`.
You can use `simple.js` and `simple.html` as templates for new examples.
### Use of the `goog` namespace in examples
Short story: the ol3 examples should not use the `goog` namespace, except
for `goog.require`.
Longer story: we want that the ol3 examples work in multiple modes, with the
standalone lib (which has implications of the symbols and properties we
export), and compiled together with the ol3 library.
Compiling the examples together with the library makes it mandatory to declare dependencies with `goog.require` statements.
## Pull request guidelines
Your pull request must:
* Follow OpenLayers 3's coding style.
* Pass the integration tests run automatically by the Travis Continuous
Integration system.
* Address a single issue or add a single item of functionality.
* Contain a clean history of small, incremental, logically separate commits,
with no merge commits.
* Use clear commit messages.
* Be possible to merge automatically.
### The `check` build target
It is strongly recommended that you run
$ ./build.py check
before every commit. This will catch many problems quickly, and it is much
faster than waiting for the Travis CI integration tests to run.
The `check` build target runs a number of quick tests on your code. These
include:
* Lint
* Compile
* Tests
### Follow OpenLayers 3's coding style
OpenLayers 3 follows [Google's JavaScript Style
Guide](http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml).
This is checked using the [Closure
Linter](https://developers.google.com/closure/utilities/) in strict mode. You
can run the linter locally on your machine before committing using the `lint`
target to `build.py`:
$ ./build.py lint
In addition to fixing problems identified by the linter, please also follow the
style of the existing OpenLayers 3 code, which includes:
* Always wrap the body of `for`, `if`, and `while` statements in braces.
* Class methods should be in alphabetical order.
* `var` declarations should not span multiple lines. If you cannot fit all
the declarations in a single line, then start a new `var` declaration on a
new line. Within a single line, variables should be declared in
alphabetical order.
* Do not use assignments inside expressions.
### Pass the integration tests run automatically by the Travis CI system
The integration tests contain a number of automated checks to ensure that the
code follows the OpenLayers 3 style and does not break tests or examples. You
can run the integration tests locally using the `ci` target:
$ ./build.py ci
### Address a single issue or add a single item of functionality
Please submit separate pull requests for separate issues. This allows each to
be reviewed on its own merits.
### Contain a clean history of small, incremental, logically separate commits, with no merge commits
The commit history explains to the reviewer the series of modifications to the
code that you have made and breaks the overall contribution into a series of
easily-understandable chunks. Any individual commit should not add more than
one new class or one new function. Do not submit commits that change thousands
of lines or that contain more than one distinct logical change. Trivial
commits, e.g. to fix lint errors, should be merged into the commit that
introduced the error. See the [Atomic Commit Convention on Wikipedia](http://en.wikipedia.org/wiki/Atomic_commit#Atomic_Commit_Convention) for more detail.
`git apply --patch` and `git rebase` can help you create a clean commit
history.
[Reviewboard.org](http://www.reviewboard.org/docs/codebase/dev/git/clean-commits/)
and [Pro GIT](http://git-scm.com/book/en/Git-Tools-Rewriting-History) have
explain how to use them.
### Use clear commit messages
Commit messages should be short, begin with a verb in the imperative, and
contain no trailing punctuation. We follow
http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
for the formatting of commit messages.
Git commit message should look like:
Header line: explaining the commit in one line
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc etc.
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
74 characters or so. That way "git log" will show things
nicely even when it's indented.
Further paragraphs come after blank lines.
Please keep the header line short, no more than 50 characters.
### Be possible to merge automatically
Occasionally other changes to `master` might mean that your pull request cannot
be merged automatically. In this case you may need to rebase your branch on a
more recent `master`, resolve any conflicts, and `git push --force` to update
your branch so that it can be merged automatically.

View File

@@ -9,9 +9,6 @@
"source": {
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_",
"exclude": [
"src/googx/dom/fullscreen.js"
],
"include": [
"src",
"externs/oli.js",
@@ -23,7 +20,6 @@
"apidoc/plugins/inheritdoc",
"apidoc/plugins/interface",
"apidoc/plugins/typedefs",
"apidoc/plugins/todo",
"apidoc/plugins/events",
"apidoc/plugins/observable",
"apidoc/plugins/api"

View File

@@ -30,7 +30,7 @@ Interactions for [vector features](ol.Feature.html)
<br>[Formats](ol.format.Feature.html) for reading/writing vector data
<br>[ol.format.WMSCapabilities](ol.format.WMSCapabilities.html)</td></tr>
<tr><th>Projections</th><th>2-way bindings</th><th>Other components</th></tr>
<tr><td><p>All coordinates and extents need to be provided in view projection (default: [EPSG:3857](ol.proj.EPSG3857.html)). To transform, use [ol.proj.transform()](ol.proj.html#transform) and [ol.extent.applyTransform()](ol.extent.html#applyTransform).</p>
<tr><td><p>All coordinates and extents need to be provided in view projection (default: EPSG:3857). To transform, use [ol.proj.transform()](ol.proj.html#transform) and [ol.proj.transformExtent()](ol.proj.html#transformExtent).</p>
[ol.proj](ol.proj.html)</td>
<td><p>[Objects](ol.Object.html) can be kept in sync using the [bindTo()](ol.Object.html#bindTo) method.</p>
<p>A [DOM Input](ol.dom.Input.html) class is available to bind Object properties to HTML Input elements.</p></td>

View File

@@ -72,7 +72,6 @@ function includeAugments(doclet) {
}
var api = [];
var augments = {};
var classes = {};
exports.handlers = {

View File

@@ -19,7 +19,7 @@ exports.handlers = {
parseComplete: function(e) {
var doclets = e.doclets;
var eventClass, doclet, i, ii, j, jj, event, fires;
var doclet, i, ii, j, jj, event, fires;
for (i = 0, ii = doclets.length - 1; i < ii; ++i) {
doclet = doclets[i];
if (doclet.fires) {

View File

@@ -87,7 +87,7 @@ exports.handlers = {
for (l = candidates.length - 1; l >= 0; --l) {
candidate = candidates[l];
if (candidate && !candidate.inheritdoc) {
stability = candidate.stability || incompleteDoclet.stability
stability = candidate.stability || incompleteDoclet.stability;
if (stability) {
incompleteDoclet.stability = stability;
for (key in candidate) {

View File

@@ -1,4 +1,3 @@
var util = require('util');
exports.defineTags = function(dictionary) {
var classTag = dictionary.lookUp('class');

View File

@@ -44,7 +44,7 @@ exports.handlers = {
if (!cls.fires) {
cls.fires = [];
}
var event = 'ol.ObjectEvent#event:change:' + name.toLowerCase();
event = 'ol.ObjectEvent#event:change:' + name.toLowerCase();
if (cls.fires.indexOf(event) == -1) {
cls.fires.push(event);
}

View File

@@ -1,16 +0,0 @@
var util = require('util');
exports.defineTags = function(dictionary) {
dictionary.defineTag('todo', {
mustHaveValue: true,
canHaveType: true,
canHaveName: true,
onTagged: function(doclet, tag) {
var parts = tag.text.split(' ');
if (parts[0] === 'api') {
doclet.stability = parts.slice(1).join(' ') || 'experimental';
} else if (parts[0] === 'observable') {
doclet.observable = '';
}
}
});
};

View File

@@ -11,7 +11,7 @@ In the simplest case, a JSDoc block can look like this:
/**
* Add the given control to the map.
* @param {ol.control.Control} control Control.
* @todo api
* @api
*/
ol.Map.prototype.addControl = function(control) {
// ...
@@ -22,7 +22,7 @@ contain Markdown.
The second line tells the Closure compiler the type of the argument.
The third line (`@todo api`) marks the method as part of the api and thus exportable. The stability can be added as value, e.g. `@todo api stable`. Once the documentation story is fully settled, we will remove the `todo ` and just write `@api` or `@api stable`. Without such an api annotation, the method will not be documented in the generated API documentation. Symbols without an api annotation will also not be exportable (unless they are explicitly exported with a `goog.exportProperty` call).
The third line (`@api`) marks the method as part of the api and thus exportable. The stability can be added as value, e.g. `@api stable`. Without such an api annotation, the method will not be documented in the generated API documentation. Symbols without an api annotation will also not be exportable (unless they are explicitly exported with a `goog.exportProperty` call).
### Events
@@ -37,7 +37,7 @@ ol.MapBrowserEvent.EventType = {
* A true single click with no dragging and no double click. Note that this
* event is delayed by 250 ms to ensure that it is not a double click.
* @event ol.MapBrowserEvent#singleclick
* @todo api
* @api
*/
SINGLECLICK: 'singleclick',
// ...
@@ -52,7 +52,7 @@ oli.MapBrowserEvent;
/**
* @type {ol.Coordinate}
* @todo api
* @api
*/
oli.MapBrowserEvent.prototype.coordinate;

View File

@@ -79,14 +79,6 @@ function addSignatureTypes(f) {
f.signature = (f.signature || '') + '<span class="type-signature">'+(types.length? ' :'+types.join('|') : '')+' </span>';
}
function addAttribs(f) {
var attribs = helper.getAttribs(f);
if (attribs.length) {
f.attribs = '<span class="type-signature ' + (attribs[0] === 'static' ? 'static' : '') + '">' + htmlsafe(attribs.length ? attribs.join(',') : '') + ' </span>';
}
}
function shortenPaths(files, commonPrefix) {
// always use forward slashes
var regexp = new RegExp('\\\\', 'g');
@@ -198,11 +190,19 @@ function attachModuleSymbols(doclets, modules) {
*/
function buildNav(members) {
var nav = [];
if (members.namespaces.length) {
_.each(members.namespaces, function (v) {
// exclude 'olx' from sidebar
if (v.longname.indexOf('olx') !== 0) {
// merge namespaces and classes, then sort
var merged = members.namespaces.concat(members.classes);
merged.sort(function (a, b) {
if (a.longname > b.longname)
return 1;
if (a.longname < b.longname)
return -1;
return 0;
});
_.each(merged, function (v) {
// exclude 'olx' and interfaces from sidebar
if (v.longname.indexOf('olx') !== 0 && v.interface !== true) {
if (v.kind == 'namespace') {
nav.push({
type: 'namespace',
longname: v.longname,
@@ -225,13 +225,7 @@ function buildNav(members) {
})
});
}
});
}
if (members.classes.length) {
_.each(members.classes, function (v) {
// ignore interfaces
if (v.interface !== true) {
if (v.kind == 'class') {
nav.push({
type: 'class',
longname: v.longname,
@@ -255,9 +249,8 @@ function buildNav(members) {
})
});
}
});
}
}
});
return nav;
}
@@ -404,7 +397,6 @@ exports.publish = function(taffyData, opts, tutorials) {
if ( needsSignature(doclet) ) {
addSignatureParams(doclet);
addSignatureReturns(doclet);
addAttribs(doclet);
}
});
@@ -414,12 +406,10 @@ exports.publish = function(taffyData, opts, tutorials) {
if (doclet.kind === 'member') {
addSignatureTypes(doclet);
addAttribs(doclet);
}
if (doclet.kind === 'constant') {
addSignatureTypes(doclet);
addAttribs(doclet);
doclet.kind = 'member';
}
});

View File

@@ -15,7 +15,6 @@ var self = this;
<?js if (item.type === 'namespace' &&
(item.members.length + item.typedefs.length + item.methods.length +
item.events.length > 0)) { ?>
<span class="static">static</span>
<?js } ?>
</span>
<ul class="members itemMembers">

View File

@@ -1,202 +0,0 @@
#!/usr/bin/env python
#
# Copyright 2009 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Generates out a Closure deps.js file given a list of JavaScript sources.
Paths can be specified as arguments or (more commonly) specifying trees
with the flags (call with --help for descriptions).
Usage: depswriter.py [path/to/js1.js [path/to/js2.js] ...]
"""
import logging
import optparse
import os
import posixpath
import shlex
import sys
import source
import treescan
__author__ = 'nnaze@google.com (Nathan Naze)'
def MakeDepsFile(source_map):
"""Make a generated deps file.
Args:
source_map: A dict map of the source path to source.Source object.
Returns:
str, A generated deps file source.
"""
# Write in path alphabetical order
paths = sorted(source_map.keys())
lines = []
for path in paths:
js_source = source_map[path]
# We don't need to add entries that don't provide anything.
if js_source.provides:
lines.append(_GetDepsLine(path, js_source))
return ''.join(lines)
def _GetDepsLine(path, js_source):
"""Get a deps.js file string for a source."""
provides = sorted(js_source.provides)
requires = sorted(js_source.requires)
return 'goog.addDependency(\'%s\', %s, %s);\n' % (path, provides, requires)
def _GetOptionsParser():
"""Get the options parser."""
parser = optparse.OptionParser(__doc__)
parser.add_option('--output_file',
dest='output_file',
action='store',
help=('If specified, write output to this path instead of '
'writing to standard output.'))
parser.add_option('--root',
dest='roots',
default=[],
action='append',
help='A root directory to scan for JS source files. '
'Paths of JS files in generated deps file will be '
'relative to this path. This flag may be specified '
'multiple times.')
parser.add_option('--root_with_prefix',
dest='roots_with_prefix',
default=[],
action='append',
help='A root directory to scan for JS source files, plus '
'a prefix (if either contains a space, surround with '
'quotes). Paths in generated deps file will be relative '
'to the root, but preceded by the prefix. This flag '
'may be specified multiple times.')
parser.add_option('--path_with_depspath',
dest='paths_with_depspath',
default=[],
action='append',
help='A path to a source file and an alternate path to '
'the file in the generated deps file (if either contains '
'a space, surround with whitespace). This flag may be '
'specified multiple times.')
return parser
def _NormalizePathSeparators(path):
"""Replaces OS-specific path separators with POSIX-style slashes.
Args:
path: str, A file path.
Returns:
str, The path with any OS-specific path separators (such as backslash on
Windows) replaced with URL-compatible forward slashes. A no-op on systems
that use POSIX paths.
"""
return path.replace(os.sep, posixpath.sep)
def _GetRelativePathToSourceDict(root, prefix=''):
"""Scans a top root directory for .js sources.
Args:
root: str, Root directory.
prefix: str, Prefix for returned paths.
Returns:
dict, A map of relative paths (with prefix, if given), to source.Source
objects.
"""
# Remember and restore the cwd when we're done. We work from the root so
# that paths are relative from the root.
start_wd = os.getcwd()
os.chdir(root)
path_to_source = {}
for path in treescan.ScanTreeForJsFiles('.'):
prefixed_path = _NormalizePathSeparators(os.path.join(prefix, path))
path_to_source[prefixed_path] = source.Source(source.GetFileContents(path))
os.chdir(start_wd)
return path_to_source
def _GetPair(s):
"""Return a string as a shell-parsed tuple. Two values expected."""
try:
# shlex uses '\' as an escape character, so they must be escaped.
s = s.replace('\\', '\\\\')
first, second = shlex.split(s)
return (first, second)
except:
raise Exception('Unable to parse input line as a pair: %s' % s)
def main():
"""CLI frontend to MakeDepsFile."""
logging.basicConfig(format=(sys.argv[0] + ': %(message)s'),
level=logging.INFO)
options, args = _GetOptionsParser().parse_args()
path_to_source = {}
# Roots without prefixes
for root in options.roots:
path_to_source.update(_GetRelativePathToSourceDict(root))
# Roots with prefixes
for root_and_prefix in options.roots_with_prefix:
root, prefix = _GetPair(root_and_prefix)
path_to_source.update(_GetRelativePathToSourceDict(root, prefix=prefix))
# Source paths
for path in args:
path_to_source[path] = source.Source(source.GetFileContents(path))
# Source paths with alternate deps paths
for path_with_depspath in options.paths_with_depspath:
srcpath, depspath = _GetPair(path_with_depspath)
path_to_source[depspath] = source.Source(source.GetFileContents(srcpath))
# Make our output pipe.
if options.output_file:
out = open(options.output_file, 'w')
else:
out = sys.stdout
out.write('// This file was autogenerated by %s.\n' % sys.argv[0])
out.write('// Please do not edit.\n')
out.write(MakeDepsFile(path_to_source))
if __name__ == '__main__':
main()

View File

@@ -1,114 +0,0 @@
# Copyright 2009 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Scans a source JS file for its provided and required namespaces.
Simple class to scan a JavaScript file and express its dependencies.
"""
__author__ = 'nnaze@google.com'
import re
_BASE_REGEX_STRING = '^\s*goog\.%s\(\s*[\'"](.+)[\'"]\s*\)'
_PROVIDE_REGEX = re.compile(_BASE_REGEX_STRING % 'provide')
_REQUIRES_REGEX = re.compile(_BASE_REGEX_STRING % 'require')
# This line identifies base.js and should match the line in that file.
_GOOG_BASE_LINE = (
'var goog = goog || {}; // Identifies this file as the Closure base.')
class Source(object):
"""Scans a JavaScript source for its provided and required namespaces."""
# Matches a "/* ... */" comment.
# Note: We can't definitively distinguish a "/*" in a string literal without a
# state machine tokenizer. We'll assume that a line starting with whitespace
# and "/*" is a comment.
_COMMENT_REGEX = re.compile(
r"""
^\s* # Start of a new line and whitespace
/\* # Opening "/*"
.*? # Non greedy match of any characters (including newlines)
\*/ # Closing "*/""",
re.MULTILINE | re.DOTALL | re.VERBOSE)
def __init__(self, source):
"""Initialize a source.
Args:
source: str, The JavaScript source.
"""
self.provides = set()
self.requires = set()
self._source = source
self._ScanSource()
def __str__(self):
return 'Source %s' % self._path
def GetSource(self):
"""Get the source as a string."""
return self._source
@classmethod
def _StripComments(cls, source):
return cls._COMMENT_REGEX.sub('', source)
def _ScanSource(self):
"""Fill in provides and requires by scanning the source."""
source = self._StripComments(self.GetSource())
source_lines = source.splitlines()
for line in source_lines:
match = _PROVIDE_REGEX.match(line)
if match:
self.provides.add(match.group(1))
match = _REQUIRES_REGEX.match(line)
if match:
self.requires.add(match.group(1))
# Closure's base file implicitly provides 'goog'.
for line in source_lines:
if line == _GOOG_BASE_LINE:
if len(self.provides) or len(self.requires):
raise Exception(
'Base files should not provide or require namespaces.')
self.provides.add('goog')
def GetFileContents(path):
"""Get a file's contents as a string.
Args:
path: str, Path to file.
Returns:
str, Contents of file.
Raises:
IOError: An error occurred opening or reading the file.
"""
fileobj = open(path)
try:
return fileobj.read()
finally:
fileobj.close()

View File

@@ -1,78 +0,0 @@
#!/usr/bin/env python
#
# Copyright 2010 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Shared utility functions for scanning directory trees."""
import os
import re
__author__ = 'nnaze@google.com (Nathan Naze)'
# Matches a .js file path.
_JS_FILE_REGEX = re.compile(r'^.+\.js$')
def ScanTreeForJsFiles(root):
"""Scans a directory tree for JavaScript files.
Args:
root: str, Path to a root directory.
Returns:
An iterable of paths to JS files, relative to cwd.
"""
return ScanTree(root, path_filter=_JS_FILE_REGEX)
def ScanTree(root, path_filter=None, ignore_hidden=True):
"""Scans a directory tree for files.
Args:
root: str, Path to a root directory.
path_filter: A regular expression filter. If set, only paths matching
the path_filter are returned.
ignore_hidden: If True, do not follow or return hidden directories or files
(those starting with a '.' character).
Yields:
A string path to files, relative to cwd.
"""
def OnError(os_error):
raise os_error
for dirpath, dirnames, filenames in os.walk(root, onerror=OnError):
# os.walk allows us to modify dirnames to prevent decent into particular
# directories. Avoid hidden directories.
for dirname in dirnames:
if ignore_hidden and dirname.startswith('.'):
dirnames.remove(dirname)
for filename in filenames:
# nothing that starts with '.'
if ignore_hidden and filename.startswith('.'):
continue
fullpath = os.path.join(dirpath, filename)
if path_filter and not path_filter.match(fullpath):
continue
yield os.path.normpath(fullpath)

View File

@@ -5,9 +5,9 @@
* This loader is used for the hosted examples. It is used in place of the
* development loader (examples/loader.js).
*
* ol.js, ol-simple.js, ol-whitespace.js, and ol-deps.js are built
* by OL3's build.py script. They are located in the ../build/ directory,
* relatively to this script.
* The ol.js, ol-debug.js, and ol-deps.js scripts are built by OL3's
* build.py script. They are located in the ../build/ directory, relative to
* this script.
*
* The script must be named loader.js.
*
@@ -54,20 +54,11 @@
}
}
var oljs = 'ol.js', mode;
if ('mode' in pageParams) {
mode = pageParams.mode.toLowerCase();
if (mode == 'debug') {
mode = 'raw';
}
if (mode != 'advanced' && mode != 'raw') {
oljs = 'ol-' + mode + '.js';
}
}
var raw = pageParams.mode && pageParams.mode.toLowerCase() === 'raw';
var scriptId = encodeURIComponent(scriptParams.id);
if (mode != 'raw') {
document.write('<scr' + 'ipt type="text/javascript" src="../build/' + oljs + '"></scr' + 'ipt>');
if (!raw) {
document.write('<scr' + 'ipt type="text/javascript" src="../build/ol.js"></scr' + 'ipt>');
} else {
window.CLOSURE_NO_DEPS = true; // we've got our own deps file
document.write('<scr' + 'ipt type="text/javascript" src="../closure-library/closure/goog/base.js"></scr' + 'ipt>');

307
build.py
View File

@@ -16,10 +16,9 @@ from pake import ifind, main, output, rule, target, variables, virtual, which
if sys.platform == 'win32':
win = {
'CLEANCSS': './node_modules/.bin/cleancss',
'GIT': 'git.exe',
'GJSLINT': 'gjslint.exe',
'JAVA': 'java.exe',
'JAR': 'jar.exe',
'JSDOC': './node_modules/.bin/jsdoc',
'JSHINT': './node_modules/.bin/jshint',
'PYTHON': 'python.exe',
@@ -28,24 +27,6 @@ if sys.platform == 'win32':
sys_dir = os.environ.get('SYSTEMDRIVE')
program_files = os.environ.get('PROGRAMFILES')
java_home = os.environ.get('JAVA_HOME')
if not java_home:
# Following lines choose sensible defaults to guess JAVA_HOME in
# 32/64bit Program Files folder opting for the most current version.
search_term = os.path.join(sys_dir, os.sep, 'Program Files*', 'Java', 'jdk*')
found_jdks = sorted(glob.glob(search_term), key=lambda x: x[-8:])
if found_jdks:
java_home = found_jdks[-1]
if java_home:
if not which(win['JAVA']):
win['JAVA'] = os.path.join(java_home, 'bin', 'java.exe')
if not which(win['JAR']):
win['JAR'] = os.path.join(java_home, 'bin', 'jar.exe')
elif not which(win['JAVA']):
win['JAVA'] = os.path.join(program_files,
'Java', 'jre7', 'bin', 'java.exe')
if not which(win['GIT']):
win['GIT'] = os.path.join(program_files, 'Git', 'cmd', 'git.exe')
@@ -70,11 +51,10 @@ if sys.platform == 'win32':
setattr(variables, program, path)
else:
variables.CLEANCSS = './node_modules/.bin/cleancss'
variables.GIT = 'git'
variables.GJSLINT = 'gjslint'
variables.JSHINT = './node_modules/.bin/jshint'
variables.JAVA = 'java'
variables.JAR = 'jar'
variables.JSDOC = './node_modules/.bin/jsdoc'
variables.PYTHON = 'python'
variables.PHANTOMJS = './node_modules/.bin/phantomjs'
@@ -82,12 +62,10 @@ else:
variables.BRANCH = output(
'%(GIT)s', 'rev-parse', '--abbrev-ref', 'HEAD').strip()
EXECUTABLES = [variables.GIT, variables.GJSLINT, variables.JAVA, variables.JAR,
EXECUTABLES = [variables.CLEANCSS, variables.GIT, variables.GJSLINT,
variables.JSDOC, variables.JSHINT, variables.PYTHON,
variables.PHANTOMJS]
EXPORTS = 'build/exports.js'
EXAMPLES = [path
for path in ifind('examples')
if path.endswith('.html')
@@ -100,7 +78,6 @@ EXAMPLES_SRC = [path
if not path.startswith('examples/bootstrap')
if path != 'examples/Jugl.js'
if path != 'examples/jquery.min.js'
if path != 'examples/loader.js'
if path != 'examples/example-list.js']
EXAMPLES_JSON = ['build/' + example.replace('.html', '.json')
@@ -129,17 +106,6 @@ SRC = [path
if path.endswith('.js')
if path not in SHADER_SRC]
LIBTESS_JS_SRC = [path
for path in ifind('src/libtess.js')
if path.endswith('.js')]
PLOVR_JAR = 'build/plovr-81ed862.jar'
PLOVR_JAR_MD5 = '1c752daaf11ad6220b298e7d2ee2b87d'
PROJ4JS = 'build/proj4js/lib/proj4js-combined.js'
PROJ4JS_ZIP = 'build/proj4js-1.1.0.zip'
PROJ4JS_ZIP_MD5 = '17caad64cf6ebc6e6fe62f292b134897'
def report_sizes(t):
stringio = StringIO()
@@ -157,66 +123,36 @@ def report_sizes(t):
virtual('default', 'build')
virtual('integration-test', 'lint', 'jshint', 'build', 'build-all',
'test', 'build/examples/all.combined.js', 'check-examples', 'apidoc')
virtual('ci', 'lint', 'jshint', 'build', 'test',
'build/examples/all.combined.js', 'check-examples', 'apidoc')
virtual('build', 'build/ol.css', 'build/ol.js',
'build/ol-simple.js', 'build/ol-whitespace.js')
virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-debug.js')
virtual('check', 'lint', 'jshint', 'build/ol-all.js', 'test')
virtual('check', 'lint', 'jshint', 'test')
virtual('todo', 'fixme')
@target('build/ol.css', 'build/ol.js')
@target('build/ol.css', 'css/ol.css')
def build_ol_css(t):
t.touch()
t.output('%(CLEANCSS)s', 'css/ol.css')
@target('build/ol.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC, LIBTESS_JS_SRC,
'buildcfg/base.json', 'buildcfg/ol.json')
def build_ol_js(t):
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
PLOVR_JAR, 'build', 'buildcfg/ol.json')
@target('build/ol.js', SRC, SHADER_SRC, 'buildcfg/ol.json')
def build_ol_new_js(t):
t.run('node', 'tasks/build.js', 'buildcfg/ol.json', 'build/ol.js')
report_sizes(t)
@target('build/ol-simple.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC,
LIBTESS_JS_SRC, 'buildcfg/base.json', 'buildcfg/ol.json',
'buildcfg/ol-simple.json')
def build_ol_simple_js(t):
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
PLOVR_JAR, 'build', 'buildcfg/ol-simple.json')
@target('build/ol-debug.js', SRC, SHADER_SRC, 'buildcfg/ol-debug.json')
def build_ol_debug_js(t):
t.run('node', 'tasks/build.js', 'buildcfg/ol-debug.json', 'build/ol-debug.js')
report_sizes(t)
@target('build/ol-whitespace.js', PLOVR_JAR, SRC, EXPORTS,
SHADER_SRC, LIBTESS_JS_SRC, 'buildcfg/base.json', 'buildcfg/ol.json',
'buildcfg/ol-whitespace.json')
def build_ol_whitespace_js(t):
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
PLOVR_JAR, 'build', 'buildcfg/ol-whitespace.json')
report_sizes(t)
virtual('build-all', 'build/ol-all.js')
@target('build/ol-all.js', PLOVR_JAR, SRC, EXPORTS, SHADER_SRC, LIBTESS_JS_SRC,
'buildcfg/base.json', 'buildcfg/ol-all.json')
def build_ol_all_js(t):
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
PLOVR_JAR, 'build', 'buildcfg/ol-all.json')
@target(EXPORTS, SRC)
def build_exports_js(t):
t.run('node', 'tasks/generate-exports.js', EXPORTS)
for glsl_src in GLSL_SRC:
def shader_src_helper(glsl_src):
@target(glsl_src.replace('.glsl', 'shader.js'), glsl_src,
@@ -259,12 +195,11 @@ def examples_examples_list_js(t):
t.run('%(PYTHON)s', 'bin/exampleparser.py', 'examples', 'examples')
@target('build/examples/all.combined.js', 'build/examples/all.js', PLOVR_JAR,
SRC, SHADER_SRC, LIBTESS_JS_SRC,
'buildcfg/base.json', 'build/examples/all.json')
@target('build/examples/all.combined.js', 'build/examples/all.js',
SRC, SHADER_SRC, 'buildcfg/examples-all.json')
def build_examples_all_combined_js(t):
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
PLOVR_JAR, 'build', 'buildcfg/examples-all.json')
t.run('node', 'tasks/build.js', 'buildcfg/examples-all.json',
'build/examples/all.combined.js')
report_sizes(t)
@@ -282,77 +217,105 @@ def examples_star_json(name, match):
# Note that we use the proper way in buildcfg/examples-all.json, which
# is only used to check the examples code using the compiler.
content = json.dumps({
'id': match.group('id'),
'inherits': '../../buildcfg/base.json',
'inputs': [
'../examples/%(id)s.js' % match.groupdict()
"exports": [],
"src": ["src/**/*.js", "examples/%(id)s.js" % match.groupdict()],
"compile": {
"externs": [
"externs/bingmaps.js",
"externs/bootstrap.js",
"externs/closure-compiler.js",
"externs/example.js",
"externs/geojson.js",
"externs/jquery-1.7.js",
"externs/oli.js",
"externs/olx.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js",
"externs/vbarray.js"
],
'externs': [
'//jquery-1.7.js',
'../externs/bingmaps.js',
'../externs/bootstrap.js',
'../externs/closure-compiler.js',
'../externs/example.js',
'../externs/geojson.js',
'../externs/oli.js',
'../externs/olx.js',
'../externs/proj4js.js',
'../externs/tilejson.js',
'../externs/topojson.js',
'../externs/vbarray.js',
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.DEBUG=false"
],
"jscomp_error": [
"accessControls",
"ambiguousFunctionDecl",
"checkDebuggerStatement",
"checkEventfulObjectDisposal",
"checkProvides",
"checkRegExp",
"checkStructDictInheritance",
"checkTypes",
"checkVars",
"const",
"constantProperty",
"deprecated",
"duplicate",
"duplicateMessage",
"es3",
"externsValidation",
"fileoverviewTags",
"globalThis",
"internetExplorerChecks",
"invalidCasts",
"misplacedTypeAnnotation",
"missingProperties",
"nonStandardJsDocs",
"strictModuleDepCheck",
"suspiciousCode",
"typeInvalidation",
"tweakValidation",
"undefinedNames",
"undefinedVars",
"unknownDefines",
"uselessCode",
"violatedModuleDep",
"visibility"
],
"extra_annotation_name": [
"api", "observable"
],
"jscomp_off": [
"es5Strict"
],
"compilation_level": "ADVANCED",
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
"use_types_for_optimization": True,
"manage_closure_dependencies": True
}
})
with open(t.name, 'wb') as f:
f.write(content)
dependencies = [__file__, 'buildcfg/base.json']
return Target(name, action=action, dependencies=dependencies)
return Target(name, action=action, dependencies=[__file__])
@rule(r'\Abuild/examples/(?P<id>.*).combined.js\Z')
def examples_star_combined_js(name, match):
def action(t):
t.output('%(JAVA)s', '-server', '-XX:+TieredCompilation', '-jar',
PLOVR_JAR, 'build', 'build/examples/%(id)s.json' %
match.groupdict())
config = 'build/examples/%(id)s.json' % match.groupdict()
t.run('node', 'tasks/build.js', config, name)
report_sizes(t)
dependencies = [PLOVR_JAR, SRC, SHADER_SRC, LIBTESS_JS_SRC,
'buildcfg/base.json',
dependencies = [SRC, SHADER_SRC,
'examples/%(id)s.js' % match.groupdict(),
'build/examples/%(id)s.json' % match.groupdict()]
return Target(name, action=action, dependencies=dependencies)
@target('serve', PLOVR_JAR, 'test-deps', 'examples')
@target('serve', 'examples')
def serve(t):
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', 'buildcfg/ol.json',
'buildcfg/ol-all.json', EXAMPLES_JSON, 'buildcfg/test.json')
t.run('node', 'tasks/serve.js')
@target('serve-integration-test', PLOVR_JAR)
def serve_precommit(t):
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve',
'buildcfg/ol-all.json', 'buildcfg/test.json')
virtual('lint', 'build/lint-timestamp', 'build/check-requires-timestamp',
'build/check-whitespace-timestamp')
virtual('lint', 'build/lint-timestamp', 'build/lint-libtess.js-timestamp',
'build/check-requires-timestamp', 'build/check-whitespace-timestamp')
@target('build/lint-timestamp', SRC, EXPORTS, EXAMPLES_SRC, SPEC, precious=True)
@target('build/lint-timestamp', SRC, EXAMPLES_SRC, SPEC, precious=True)
def build_lint_src_timestamp(t):
t.run('%(GJSLINT)s',
'--jslint_error=all',
'--custom_jsdoc_tags=event,fires,todo,function,classdesc',
'--strict',
t.newer(t.dependencies))
t.touch()
@target('build/lint-libtess.js-timestamp', LIBTESS_JS_SRC, precious=True)
def build_lint_libtess_js_timestamp(t):
t.run('%(GJSLINT)s',
'--jslint_error=all',
'--disable=110',
'--custom_jsdoc_tags=event,fires,function,classdesc,api,observable',
'--strict',
t.newer(t.dependencies))
t.touch()
@@ -360,7 +323,7 @@ def build_lint_libtess_js_timestamp(t):
virtual('jshint', 'build/jshint-timestamp')
@target('build/jshint-timestamp', SRC, EXPORTS, EXAMPLES_SRC, SPEC,
@target('build/jshint-timestamp', SRC, EXAMPLES_SRC, SPEC,
precious=True)
def build_jshint_timestamp(t):
t.run(variables.JSHINT, '--verbose', t.newer(t.dependencies))
@@ -390,22 +353,21 @@ def _strip_comments(lines):
yield lineno, line
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC,
SHADER_SRC, LIBTESS_JS_SRC, SPEC)
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC, SHADER_SRC, SPEC)
def build_check_requires_timestamp(t):
from zipfile import ZipFile
unused_count = 0
all_provides = set()
zf = ZipFile(PLOVR_JAR)
for zi in zf.infolist():
if zi.filename.endswith('.js'):
if not zi.filename.startswith('closure/goog/'):
closure_lib_path = output('node', '-e',
'process.stdout.write(require("closure-util").getLibraryPath())')
for filename in ifind(closure_lib_path):
if filename.endswith('.js'):
if not re.match(r'.*/closure/goog/', filename):
continue
# Skip goog.i18n because it contains so many modules that it causes
# the generated regular expression to exceed Python's limits
if zi.filename.startswith('closure/goog/i18n/'):
if re.match(r'.*/closure/goog/i18n/', filename):
continue
for line in zf.open(zi, 'rU'):
for line in open(filename, 'rU'):
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
if m:
all_provides.add(m.group(1))
@@ -531,8 +493,8 @@ def build_check_requires_timestamp(t):
t.touch()
@target('build/check-whitespace-timestamp', SRC, EXPORTS, EXAMPLES_SRC,
SPEC, JSDOC_SRC, LIBTESS_JS_SRC, precious=True)
@target('build/check-whitespace-timestamp', SRC, EXAMPLES_SRC,
SPEC, JSDOC_SRC, precious=True)
def build_check_whitespace_timestamp(t):
CR_RE = re.compile(r'\r')
LEADING_WHITESPACE_RE = re.compile(r'\s+')
@@ -564,23 +526,11 @@ def build_check_whitespace_timestamp(t):
t.touch()
virtual('plovr', PLOVR_JAR)
@target(PLOVR_JAR, clean=False)
def plovr_jar(t):
t.info('downloading %r', t.name)
t.download('https://plovr.googlecode.com/files/' +
os.path.basename(PLOVR_JAR), md5=PLOVR_JAR_MD5)
t.info('downloaded %r', t.name)
virtual('apidoc', 'build/jsdoc-%(BRANCH)s-timestamp' % vars(variables))
@target('build/jsdoc-%(BRANCH)s-timestamp' % vars(variables), 'host-resources',
EXPORTS, SRC, SHADER_SRC,
ifind('apidoc/template'))
SRC, SHADER_SRC, ifind('apidoc/template'))
def jsdoc_BRANCH_timestamp(t):
t.run('%(JSDOC)s', 'apidoc/index.md', '-c', 'apidoc/conf.json',
'-d', 'build/hosted/%(BRANCH)s/apidoc')
@@ -631,6 +581,8 @@ def host_examples(t):
examples_dir = 'build/hosted/%(BRANCH)s/examples'
build_dir = 'build/hosted/%(BRANCH)s/build'
css_dir = 'build/hosted/%(BRANCH)s/css'
closure_lib_path = output('node', '-e',
'process.stdout.write(require("closure-util").getLibraryPath())')
t.rm_rf(examples_dir)
t.makedirs(examples_dir)
t.rm_rf(build_dir)
@@ -642,21 +594,17 @@ def host_examples(t):
split_example_file(example, examples_dir % vars(variables))
t.cp_r('examples/data', examples_dir + '/data')
t.cp('bin/loader_hosted_examples.js', examples_dir + '/loader.js')
t.cp('build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js',
build_dir)
t.cp('build/ol.js', 'build/ol-debug.js', build_dir)
t.cp('build/ol.css', css_dir)
t.cp('examples/index.html', 'examples/example-list.js',
'examples/example-list.xml', 'examples/Jugl.js',
'examples/jquery.min.js', examples_dir)
t.rm_rf('build/hosted/%(BRANCH)s/closure-library')
t.makedirs('build/hosted/%(BRANCH)s/closure-library')
with t.chdir('build/hosted/%(BRANCH)s/closure-library'):
t.run('%(JAR)s', 'xf', '../../../../' + PLOVR_JAR, 'closure')
t.run('%(JAR)s', 'xf', '../../../../' + PLOVR_JAR, 'third_party')
t.cp_r(closure_lib_path, 'build/hosted/%(BRANCH)s/closure-library')
t.rm_rf('build/hosted/%(BRANCH)s/ol')
t.makedirs('build/hosted/%(BRANCH)s/ol')
t.cp_r('src/ol', 'build/hosted/%(BRANCH)s/ol/ol')
t.run('%(PYTHON)s', 'bin/closure/depswriter.py',
t.run('%(PYTHON)s', closure_lib_path + '/closure/bin/build/depswriter.py',
'--root_with_prefix', 'src ../../../ol',
'--root', 'build/hosted/%(BRANCH)s/closure-library/closure/goog',
'--root_with_prefix', 'build/hosted/%(BRANCH)s/closure-library/'
@@ -675,29 +623,9 @@ def check_examples(t):
t.run('%(PHANTOMJS)s', 'bin/check-example.js', example)
@target(PROJ4JS, PROJ4JS_ZIP)
def proj4js(t):
from zipfile import ZipFile
zf = ZipFile(PROJ4JS_ZIP)
contents = zf.open('proj4js/lib/proj4js-combined.js').read()
with open(t.name, 'wb') as f:
f.write(contents)
@target(PROJ4JS_ZIP, clean=False)
def proj4js_zip(t):
t.info('downloading %r', t.name)
t.download('http://download.osgeo.org/proj4js/' +
os.path.basename(t.name), md5=PROJ4JS_ZIP_MD5)
t.info('downloaded %r', t.name)
virtual('test-deps', PROJ4JS, 'build/test/requireall.js')
@target('test', 'test-deps', phony=True)
@target('test', phony=True)
def test(t):
t.run('%(PHANTOMJS)s', 'test/mocha-phantomjs.js', 'test/ol.html')
t.run('node', 'tasks/test.js')
@target('fixme', phony=True)
@@ -758,7 +686,7 @@ There is one option:
-c - Cleans up the repository from previous builds.
The most common targets are:
serve - Serves files through plovr, usually on port 9810.
serve - Serves files, on port 3000.
lint - Runs gjslint on all sourcefiles to enforce specific syntax.
build - Builds singlefile versions of OpenLayers JavaScript and
CSS. This is also the default build target which runs when
@@ -771,18 +699,17 @@ The most common targets are:
Other less frequently used targets are:
apidoc - Builds the API-Documentation using JSDoc3.
integration-test - Builds all examples in various modes and usually takes a
ci - Builds all examples in various modes and usually takes a
long time to finish. This target calls the following
targets: lint, build, build-all, test, build-examples,
check-examples and apidoc.
check-examples and apidoc. This is the target run on
Travis CI.
reallyclean - Remove untracked files from the repository.
checkdeps - Checks whether all required development software is
installed on your machine.
fixme - Will print a list of parts of the code that are marked
with either TODO or FIXME.
todo - This is an alias for the fixme-target (see above).
plovr - Fetches the required plovr.jar. Usually called by other
targets that depend on plovr.
If no target is given, the build-target will be executed.

View File

@@ -1,115 +0,0 @@
{
"ambiguate-properties": true,
"checks": {
"accessControls": "ERROR",
"ambiguousFunctionDecl": "ERROR",
"checkDebuggerStatement": "WARNING",
"checkEventfulObjectDisposal": "ERROR",
"checkProvides": "ERROR",
"checkRegExp": "ERROR",
"checkStructDictInheritance": "ERROR",
"checkTypes": "ERROR",
"checkVars": "ERROR",
"const": "ERROR",
"constantProperty": "ERROR",
"deprecated": "ERROR",
"duplicate": "ERROR",
"duplicateMessage": "ERROR",
"es3": "ERROR",
"es5Strict": "ERROR",
"externsValidation": "ERROR",
"fileoverviewTags": "ERROR",
"globalThis": "ERROR",
"internetExplorerChecks": "ERROR",
"invalidCasts": "ERROR",
"misplacedTypeAnnotation": "ERROR",
"missingProperties": "ERROR",
"nonStandardJsDocs": "ERROR",
"strictModuleDepCheck": "ERROR",
"suspiciousCode": "ERROR",
"typeInvalidation": "ERROR",
"tweakValidation": "ERROR",
"undefinedNames": "ERROR",
"undefinedVars": "ERROR",
"unknownDefines": "ERROR",
"uselessCode": "ERROR",
"violatedModuleDep": "ERROR",
"visibility": "ERROR"
},
"define": {
"goog.dom.ASSUME_STANDARDS_MODE": true,
"goog.DEBUG": false
},
"disambiguate-properties": true,
"externs": [
"../externs/bingmaps.js",
"../externs/closure-compiler.js",
"../externs/geojson.js",
"../externs/oli.js",
"../externs/olx.js",
"../externs/proj4js.js",
"../externs/tilejson.js",
"../externs/topojson.js",
"../externs/vbarray.js"
],
"level": "VERBOSE",
"mode": "ADVANCED",
"name-suffixes-to-strip": [
"logger",
"logger_"
],
"paths": [
"../src"
],
"treat-warnings-as-errors": false,
"type-prefixes-to-strip": [
"goog.asserts",
"goog.debug.Console",
"goog.debug.DebugWindow",
"goog.debug.DevCss",
"goog.debug.DivConsole",
"goog.debug.EntryPointMonitor",
"goog.debug.ErrorHandler",
"goog.debug.ErrorReporter",
"goog.debug.FancyWindow",
"goog.debug.Formatter",
"goog.debug.FpsDisplay",
"goog.debug.GcDiagnostics",
"goog.debug.HtmlFormatter",
"goog.debug.LogBuffer",
"goog.debug.LogManager",
"goog.debug.LogRecord",
"goog.debug.Logger",
"goog.debug.RelativeTimeProvider",
"goog.debug.TextFormatter",
"goog.debug.Trace",
"goog.debug.catchErrors",
"goog.debug.deepExpose",
"goog.debug.enhanceError",
"goog.debug.entryPointRegistry",
"goog.debug.errorHandlerWeakDep",
"goog.debug.expose",
"goog.debug.exposeArray",
"goog.debug.exposeException",
"goog.debug.getFunctionName",
"goog.debug.getStacktrace",
"goog.debug.getStacktraceSimple",
"goog.debug.logRecordSerializer",
"goog.debug.makeWhitespaceVisible",
"goog.debug.normalizeErrorObject",
"goog.debug.reflect",
"goog.log"
]
}

View File

@@ -1,21 +1,70 @@
{
"exports": [],
"src": ["src/**/*.js", "build/examples/all.js"],
"compile": {
"externs": [
"//jquery-1.7.js",
"../externs/bingmaps.js",
"../externs/bootstrap.js",
"../externs/closure-compiler.js",
"../externs/example.js",
"../externs/geojson.js",
"../externs/oli.js",
"../externs/proj4js.js",
"../externs/tilejson.js",
"../externs/topojson.js",
"../externs/vbarray.js"
"externs/bingmaps.js",
"externs/bootstrap.js",
"externs/closure-compiler.js",
"externs/example.js",
"externs/geojson.js",
"externs/jquery-1.7.js",
"externs/oli.js",
"externs/olx.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js",
"externs/vbarray.js"
],
"id": "simple",
"inherits": "base.json",
"inputs": [
"../build/examples/all.js",
"../externs/olx.js"
]
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.DEBUG=false"
],
"jscomp_error": [
"accessControls",
"ambiguousFunctionDecl",
"checkEventfulObjectDisposal",
"checkRegExp",
"checkStructDictInheritance",
"checkTypes",
"checkVars",
"const",
"constantProperty",
"deprecated",
"duplicateMessage",
"es3",
"externsValidation",
"fileoverviewTags",
"globalThis",
"internetExplorerChecks",
"invalidCasts",
"misplacedTypeAnnotation",
"missingGetCssName",
"missingProperties",
"missingProvide",
"missingRequire",
"missingReturn",
"newCheckTypes",
"nonStandardJsDocs",
"suspiciousCode",
"strictModuleDepCheck",
"typeInvalidation",
"undefinedNames",
"undefinedVars",
"unknownDefines",
"uselessCode",
"visibility"
],
"extra_annotation_name": [
"api", "observable"
],
"jscomp_off": [
"es5Strict"
],
"compilation_level": "ADVANCED",
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
"use_types_for_optimization": true,
"manage_closure_dependencies": true
}
}

View File

@@ -0,0 +1,15 @@
/**
* Handle the api annotation.
* @param {Object} dictionary The tag dictionary.
*/
exports.defineTags = function(dictionary) {
dictionary.defineTag('api', {
onTagged: function(doclet, tag) {
doclet.api = tag.text || 'experimental';
}
});
};

View File

@@ -10,7 +10,7 @@
"includePattern": "\\.js$"
},
"plugins": [
"buildcfg/jsdoc/info/define-plugin",
"buildcfg/jsdoc/info/todo-plugin"
"buildcfg/jsdoc/info/api-plugin",
"buildcfg/jsdoc/info/define-plugin"
]
}

View File

@@ -48,7 +48,6 @@ exports.publish = function(data, opts) {
name: doc.longname,
kind: doc.kind,
description: doc.classdesc || doc.description,
extends: doc.augments,
path: path.join(doc.meta.path, doc.meta.filename)
});
}

View File

@@ -1,26 +0,0 @@
/**
* @fileoverview This plugin should go away when we get rid of Plovr and can
* use Closure Compiler's extra_annotation_name option. Until then, we hijack
* the todo tag to add doclet properties for other tags we eventually want to
* support. For example, the "todo api" tag can eventually be replaced with
* the "api" tag.
*/
/**
* Our hook to define new tags.
* @param {Object} dictionary The tag dictionary.
*/
exports.defineTags = function(dictionary) {
dictionary.defineTag('todo', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
var parts = tag.text.split(' ');
if (parts[0] === 'api') {
doclet.api = parts.slice(1).join(' ').trim();
}
}
});
};

View File

@@ -1,23 +0,0 @@
{
"id": "ol-all",
"externs": [
"../externs/bingmaps.js",
"../externs/closure-compiler.js",
"../externs/geojson.js",
"../externs/oli.js",
"../externs/olx.js",
"../externs/proj4js.js",
"../externs/tilejson.js",
"../externs/topojson.js",
"../externs/vbarray.js"
],
"inherits": "base.json",
"inputs": [
"../build/exports.js"
]
}

3
buildcfg/ol-debug.json Normal file
View File

@@ -0,0 +1,3 @@
{
"exports": ["*"]
}

View File

@@ -1,39 +0,0 @@
{
// If ambiguate-properties and disambiguate-properties are set to true
// we get function names like "ol_control_Control_prototype$setMap" in
// the compiled code when using the SIMPLE compilation. It looks like
// "ambiguate-properties" and "disambiguate-properties" are only
// appropriate for ADVANCED compilation.
"ambiguate-properties": false,
"disambiguate-properties": false,
"id": "ol-simple",
"externs": [
"../externs/bingmaps.js",
"../externs/closure-compiler.js",
"../externs/geojson.js",
"../externs/oli.js",
"../externs/olx.js",
"../externs/proj4js.js",
"../externs/tilejson.js",
"../externs/topojson.js",
"../externs/vbarray.js"
],
"inherits": "ol.json",
"inputs": [
"../build/exports.js"
],
"mode": "SIMPLE",
// Note: we can't have a (function(){%output%})() output wrapper with
// WHITESPACE and SIMPLE modes. See this link for explanations:
// https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
"output-wrapper": "%output%"
}

View File

@@ -1,42 +0,0 @@
{
"id": "ol-whitespace",
// If ambiguate-properties and disambiguate-properties are set to true
// we get function names like "ol_control_Control_prototype$setMap" in
// the compiled code when using the SIMPLE compilation. It looks like
// "ambiguate-properties" and "disambiguate-properties" are only
// appropriate for ADVANCED compilation. To be sure we also don't
// set them for WHITESPACE.
"ambiguate-properties": false,
"disambiguate-properties": false,
"externs": [
"../externs/bingmaps.js",
"../externs/closure-compiler.js",
"../externs/geojson.js",
"../externs/oli.js",
"../externs/olx.js",
"../externs/proj4js.js",
"../externs/tilejson.js",
"../externs/topojson.js",
"../externs/vbarray.js"
],
"inherits": "ol.json",
"inputs": [
"../build/exports.js"
],
"mode": "WHITESPACE",
"output-wrapper": [
"var CLOSURE_NO_DEPS = true;\n",
"%output%"
],
"pretty-print": true
}

View File

@@ -1,39 +1,65 @@
{
"id": "ol",
"css-allowed-unrecognized-properties": [
"user-select"
],
"css-inputs": [
"../css/ol.css"
],
"css-output-file": "../build/ol.css",
"externs": [
"../externs/bingmaps.js",
"../externs/closure-compiler.js",
"../externs/geojson.js",
"../externs/oli.js",
"../externs/olx.js",
"../externs/proj4js.js",
"../externs/tilejson.js",
"../externs/topojson.js",
"../externs/vbarray.js"
],
"inherits": "base.json",
"inputs": [
"../build/exports.js"
],
"output-wrapper": "// OpenLayers 3. see http://ol3js.org/\n(function(){%output%})();",
"paths": [
"../src"
]
"exports": ["*"],
"compile": {
"externs": [
"externs/bingmaps.js",
"externs/closure-compiler.js",
"externs/geojson.js",
"externs/oli.js",
"externs/olx.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js",
"externs/vbarray.js"
],
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.DEBUG=false"
],
"jscomp_error": [
"accessControls",
"ambiguousFunctionDecl",
"checkEventfulObjectDisposal",
"checkRegExp",
"checkStructDictInheritance",
"checkTypes",
"checkVars",
"const",
"constantProperty",
"deprecated",
"duplicateMessage",
"es3",
"externsValidation",
"fileoverviewTags",
"globalThis",
"internetExplorerChecks",
"invalidCasts",
"misplacedTypeAnnotation",
"missingGetCssName",
"missingProperties",
"missingProvide",
"missingRequire",
"missingReturn",
"newCheckTypes",
"nonStandardJsDocs",
"suspiciousCode",
"strictModuleDepCheck",
"typeInvalidation",
"undefinedNames",
"undefinedVars",
"unknownDefines",
"uselessCode",
"visibility"
],
"extra_annotation_name": [
"api", "observable"
],
"jscomp_off": [
"es5Strict"
],
"compilation_level": "ADVANCED",
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
"use_types_for_optimization": true,
"manage_closure_dependencies": true
}
}

3
buildcfg/readme.md Normal file
View File

@@ -0,0 +1,3 @@
# Build configs
This directory includes configuration files (json) for the build scripts in tasks/.

View File

@@ -1,16 +0,0 @@
{
"id": "test",
"inherits": "base.json",
"inputs": [
"../build/test/requireall.js"
],
"paths": [
"../src",
"../test"
]
}

3
closure-util.json Normal file
View File

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

View File

@@ -1,53 +1,3 @@
.ol-attribution {
position: absolute;
text-align: right;
bottom: 0;
right: 0;
padding: 6px;
color: #000000;
color: rgba(238,238,238,1);
background: rgba(0,60,136,0.3);
}
.ol-attribution a {
text-decoration: none;
color: #7b98bc;
color: rgba(255,255,255,1);
}
.ol-attribution ul {
margin: 0;
padding: 0;
font-size: 10px;
line-height: 12px;
}
.ol-attribution li {
display: inline;
list-style: none;
line-height: inherit;
}
.ol-attribution li:not(:last-child):after {
content: "\2003";
}
.ol-attribution-bing-tos {
float:right;
padding-top: 2px;
white-space: nowrap;
}
.ol-logo {
bottom: 0;
left: 0;
padding: 2px;
position: absolute;
}
.ol-logo ul {
margin: 0;
padding: 0;
}
.ol-logo ul li {
display: inline;
list-style: none;
}
.ol-mouse-position {
top: 8px;
@@ -226,11 +176,75 @@ button.ol-full-screen-true:after {
}
.ol-rotate .ol-has-tooltip:hover [role=tooltip],
.ol-rotate .ol-has-tooltip:focus [role=tooltip],
.ol-attribution .ol-has-tooltip:hover [role=tooltip],
.ol-attribution .ol-has-tooltip:focus [role=tooltip],
.ol-full-screen .ol-has-tooltip:hover [role=tooltip],
.ol-full-screen .ol-has-tooltip:focus [role=tooltip] {
right: 2.2em;
left: auto;
border-radius: 4px 0 0 4px;
border-left-width: 3px;
border-right-width: 0;
}
.ol-attribution {
text-align: right;
bottom: .5em;
right: .5em;
}
.ol-attribution ul {
margin: 0;
padding: 0 .5em;
font-size: .7rem;
line-height: 1.375em;
color: #000;
text-shadow: 0 0 2px #fff;
}
.ol-attribution li {
display: inline;
list-style: none;
line-height: inherit;
}
.ol-attribution li:not(:last-child):after {
content: " ";
}
.ol-attribution img {
max-height: 2em;
}
.ol-attribution ul, .ol-attribution button {
display: inline-block;
}
.ol-attribution:not(.ol-collapsed) button:hover [role=tooltip],
.ol-attribution.ol-collapsed ul {
display: none;
}
.ol-attribution.ol-logo-only ul {
display: block;
}
.ol-attribution:not(.ol-collapsed) {
background: rgba(255,255,255,0.8);
}
.ol-attribution.ol-uncollapsible {
bottom: 0;
right: 0;
border-radius: 4px 0 0;
height: 1.1em;
line-height: 1em;
}
.ol-attribution.ol-logo-only {
background: transparent;
bottom: .4em;
height: 1.1em;
line-height: 1em;
}
.ol-attribution.ol-uncollapsible img {
margin-top: -.2em;
max-height: 1.6em;
}
.ol-attribution.ol-logo-only button,
.ol-attribution.ol-uncollapsible button {
display: none;
}
.ol-zoomslider {

View File

@@ -5,4 +5,4 @@ layout: doc.hbs
# Tutorials
We'll be putting together a more comprehensive set of tutorials here. For now, you can take a look at the [basic concepts](concepts.html) tutorial. Stay tuned for more!
We'll be putting together a more comprehensive set of tutorials here. For now, you can take a look at the [introduction](introduction.html) and [basic concepts](concepts.html) tutorial. Stay tuned for more!

View File

@@ -0,0 +1,44 @@
---
title: Introduction
layout: doc.hbs
---
# Introduction
## Objectives
OpenLayers 3 (OL3) is a fundamental redesign of the OpenLayers web mapping library. Version 2 is widely used, but dates from the early days of Javascript development, and is increasingly showing its age. OL3 has been rewritten from the ground up to use modern design patterns.
The initial release aims to support much of the functionality provided by version 2, with support for a wide range of commercial and free tile sources, and the most popular open-source vector data formats. As with version 2, data can be in any projection. The initial release also adds some additional functionality, such as the ability to easily rotate or animate maps.
It is also designed such that major new features, such as displaying 3D maps, or using WebGL to quickly display large vector data sets, can be added in later releases.
## Closure Tools
OL3 is based on Google's Closure Tools. It makes heavy use of parts of the [__Closure Library__](https://developers.google.com/closure/library/). Using this to handle basics like DOM or event handling means the developers can concentrate on mapping functionality, and be sure that the underlying software is well-tested and cross-browser. Closure Library is specially designed to be optimized by the [__Closure Compiler__](https://developers.google.com/closure/compiler/). The 'advanced' optimizations that this provides offers a level of compression that far exceeds anything else available. OL3 has been designed to make full use of this.
## Public API
Using the advanced optimizations of the Closure Compiler means that properties and methods are renamed &ndash; `longMeaningfulName` might become `xB` &ndash; and so are effectively unusable in applications using the library. To be usable, they have to be explicitly `exported`. This means the exported names, those not renamed, effectively become the public API of the library. These __exportable__ properties and methods are marked in the source, and documented in the [API docs](../../apidoc). This is the officially supported API of the library. A build containing all these exportable names is known as a __full build__. A hosted version of this is available, which can be used by any application.
Although Closure library functions are widely used within OL3, none of them are exported. You will see references to them (they are all in the `goog` namespace) in the API docs, but these are for information only. You can use the Closure library in your own applications if you like, but this is not required.
## Custom Builds
Unlike in, say, Node, where a module's exports are fixed in the source, with Closure Compiler, exports can be defined at compile time. This makes it easy to create builds that are customized to the needs of a particular site or application: a __custom build__ only exports those properties and methods needed by the site or application. As the full build is large, and will probably become larger as new features are added to the API, it's recommended that sites create a custom build for production software.
## Renderers and Browser Support
The library currently includes three renderers: Canvas, DOM, and WebGL. All three support raster data from tile/image servers, but only the Canvas renderer currently supports vector data. This means that only those browsers that [support Canvas](http://caniuse.com/canvas) can handle vector data. In particular, this excludes Internet Explorer versions before 9, though there is some support for those in the DOM renderer. Clearly, the WebGL renderer can only be used on those devices and browsers supporting WebGL.
The library is intended for use on both desktop/laptop and mobile devices.
## Objects and Naming Conventions
OL3 uses a similar object hierarchy to the Closure library. There is a top-level `ol` namespace (basically, `var ol = {};`). Subdivisions of this are:
* further namespaces, such as `ol.layer`; these have a lower-case initial
* simple objects containing static properties and methods, such as `ol.animation`; these also have a lower-case initial
* types, which have an upper-case initial. These are mainly 'classes', which here means a constructor function with prototypal inheritance, such as `ol.Map` or `ol.layer.Vector` (the Vector class within the layer namespace). There are however other, simpler, types, such as `ol.Extent`, which is an array.
Class namespaces, such as `ol.layer` have a base class type with the same name, such as `ol.layer.Layer`. These are mainly abstract classes, from which the other subclasses inherit.
Source files are similarly organised, with a directory for each class namespace. Names are however all lower-case, and the subclasses repeat the superclass type in their name, for example, `ol/layer/vectorlayer.js`.
The naming structure means that there are sometimes 2 objects with the same name but different initial, such as `ol.feature`, a simple object with static functions to be used with features, and `ol.Feature`, a class used to instantiate new features. These two objects are however stored in the same file, in this case, `ol/feature.js`
OL3 follows the convention that the names of private properties and methods, that is, those that are not part of the API, end in an underscore. In general, instance properties are private and accessed using accessors.

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -12,6 +13,11 @@ var map = new ol.Map({
],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2

View File

@@ -1,6 +1,7 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.animation');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
goog.require('ol.source.OSM');
@@ -55,6 +56,11 @@ var map = new ol.Map({
],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: view
});

View File

@@ -8,7 +8,7 @@
<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>Style with rules example</title>
<title>Attributions example</title>
</head>
<body>
@@ -31,20 +31,21 @@
<div class="row-fluid">
<div class="span12">
<h4 id="title">Style with rules example</h4>
<p id="shortdesc">Draws features with rule based styles.</p>
<h4 id="title">Attributions example</h4>
<p id="shortdesc">Example of a attributions visibily change on map resize, to collapse them on small maps.</p>
<div id="docs">
<p>See the <a href="style-rules.js" target="_blank">style-rules.js source</a> to see how this is done.</p>
<p>See the <a href="attributions.js" target="_blank">attributions.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector, geojson, style</div>
<div id="tags">attributions, openstreetmap</div>
</div>
</div>
</div>
<script src="loader.js?id=style-rules" type="text/javascript"></script>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=attributions" type="text/javascript"></script>
</body>
</html>

33
examples/attributions.js Normal file
View File

@@ -0,0 +1,33 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.control.Attribution');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
var attribution = new ol.control.Attribution({
collapsible: false
});
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
controls: ol.control.defaults({ attribution: false }).extend([attribution]),
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
function checkSize() {
var small = map.getSize()[0] < 600;
attribution.setCollapsible(small);
attribution.setCollapsed(small);
}
$(window).on('resize', checkSize);
checkSize();

View File

@@ -1,6 +1,7 @@
goog.require('ol.BrowserFeature');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.dom.Input');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -29,6 +30,11 @@ var map = new ol.Map({
layers: [layer],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: view
});

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
goog.require('ol.source.OSM');
@@ -23,6 +24,11 @@ var map = new ol.Map({
],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: ol.proj.transform(
[-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'),

View File

@@ -21,10 +21,6 @@
top: 178px;
left: 158px;
}
div.ol-logo {
left: 150px;
bottom: 30px;
}
div.ol-attribution {
bottom: 30px;
right: 50px;

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.geom.Point');
goog.require('ol.geom.SimpleGeometry');
goog.require('ol.layer.Tile');
@@ -50,6 +51,11 @@ var map = new ol.Map({
vectorLayer
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: view
});

View File

@@ -62,7 +62,11 @@ ol.inherits(app.RotateNorthControl, ol.control.Control);
var map = new ol.Map({
controls: ol.control.defaults().extend([
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}).extend([
new app.RotateNorthControl()
]),
layers: [

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
goog.require('ol.DeviceOrientation');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.dom.Input');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
@@ -21,6 +22,11 @@ var map = new ol.Map({
],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: view
});

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -11,6 +12,11 @@ var map = new ol.Map({
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2
@@ -25,7 +31,7 @@ if ('download' in exportPNGElement) {
var canvas = event.context.canvas;
exportPNGElement.href = canvas.toDataURL('image/png');
});
map.render();
map.renderSync();
}, false);
} else {
var info = document.getElementById('no-download');

View File

@@ -1,6 +1,7 @@
goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.geom.Circle');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
@@ -144,7 +145,7 @@ var vectorSource = new ol.source.GeoJSON(
'type': 'MultiPolygon',
'coordinates': [
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6]]],
[[[-2e6, 6e6], [-2e6, 8e6], [0e6, 8e6], [0e6, 6e6]]],
[[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6], [0, 6e6]]],
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6]]]
]
}
@@ -156,7 +157,7 @@ var vectorSource = new ol.source.GeoJSON(
'geometries': [
{
'type': 'LineString',
'coordinates': [[-5e6, -5e6], [0e6, -5e6]]
'coordinates': [[-5e6, -5e6], [0, -5e6]]
},
{
'type': 'Point',
@@ -188,6 +189,11 @@ var map = new ol.Map({
vectorLayer
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2

View File

@@ -2,6 +2,7 @@ goog.require('ol.Geolocation');
goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.geom.LineString');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
@@ -21,6 +22,11 @@ var map = new ol.Map({
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: view
});

View File

@@ -3,6 +3,7 @@ goog.require('ol.FeatureOverlay');
goog.require('ol.Geolocation');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.dom.Input');
goog.require('ol.geom.Point');
goog.require('ol.layer.Tile');
@@ -21,6 +22,11 @@ var map = new ol.Map({
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: view
});

View File

@@ -10,9 +10,6 @@
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<style type="text/css">
div.ol-logo {
left: 65px;
}
div.fill {
width: 100%;
height: 100%;

View File

@@ -25,6 +25,12 @@
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
<div id="no-download" class="alert alert-error" style="display: none">
The "Export GPX" functionality requires a browser that supports the
<a href="http://caniuse.com/#feat=download">link download</a> attribute.
</div>
<a id="export-gpx" class="btn" download="map.gpx"><i class="icon-download"></i>Export GPX</a>
</div>
</div>
</div>

View File

@@ -1,7 +1,9 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.format.GPX');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.proj');
goog.require('ol.source.BingMaps');
goog.require('ol.source.GPX');
goog.require('ol.style.Circle');
@@ -9,6 +11,8 @@ goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var projection = ol.proj.get('EPSG:3857');
var raster = new ol.layer.Tile({
source: new ol.source.BingMaps({
imagerySet: 'Aerial',
@@ -45,7 +49,7 @@ var style = {
var vector = new ol.layer.Vector({
source: new ol.source.GPX({
projection: 'EPSG:3857',
projection: projection,
url: 'data/gpx/fells_loop.gpx'
}),
style: function(feature, resolution) {
@@ -89,3 +93,30 @@ $(map.getViewport()).on('mousemove', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});
var exportGPXElement = document.getElementById('export-gpx');
if ('download' in exportGPXElement) {
var vectorSource = /** @type {ol.source.Vector} */ (vector.getSource());
exportGPXElement.addEventListener('click', function(e) {
if (!exportGPXElement.href) {
var features = [];
vectorSource.forEachFeature(function(feature) {
var clone = feature.clone();
clone.getGeometry().transform(projection, 'EPSG:4326');
features.push(clone);
});
var node = new ol.format.GPX().writeFeatures(features);
var string = new XMLSerializer().serializeToString(
/** @type {Node} */ (node));
var base64 = exampleNS.strToBase64(string);
exportGPXElement.href =
'data:gpx+xml;base64,' + base64;
}
}, false);
} else {
var info = document.getElementById('no-download');
/**
* display error message
*/
info.style.display = '';
}

View File

@@ -8,7 +8,7 @@
<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>Synthetic data example</title>
<title>Graticule example</title>
</head>
<body>
@@ -31,20 +31,21 @@
<div class="row-fluid">
<div class="span12">
<h4 id="title">Synthetic data example</h4>
<p id="shortdesc">Synthetic data example.</p>
<h4 id="title">Graticule example</h4>
<p id="shortdesc">This example shows how to add a graticule overlay to a map.</p>
<div id="docs">
<p>See the <a href="synthetic-data.js" target="_blank">synthetic-data.js source</a> to see how this is done.</p>
<p>See the <a href="graticule.js" target="_blank">graticule.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector</div>
<div id="tags">graticule</div>
</div>
</div>
</div>
<script src="loader.js?id=synthetic-data" type="text/javascript"></script>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=graticule" type="text/javascript"></script>
</body>
</html>

25
examples/graticule.js Normal file
View File

@@ -0,0 +1,25 @@
goog.require('ol.Graticule');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
goog.require('ol.source.OSM');
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
renderer: 'canvas',
target: 'map',
view: new ol.View({
center: ol.proj.transform([4.8, 47.75], 'EPSG:4326', 'EPSG:3857'),
zoom: 5
})
});
// Create the graticule component
var graticule = new ol.Graticule();
graticule.setMap(map);

View File

@@ -3,6 +3,7 @@ goog.require('ol.Feature');
goog.require('ol.FeatureOverlay');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.geom.LineString');
goog.require('ol.geom.Point');
goog.require('ol.layer.Tile');
@@ -83,6 +84,11 @@ var map = new ol.Map({
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [703365.7089403362, 5714629.865071137],
zoom: 9

View File

@@ -1,6 +1,7 @@
goog.require('ol.BrowserFeature');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -20,6 +21,11 @@ if (!ol.BrowserFeature.HAS_WEBGL) {
layers: [osm],
renderer: 'webgl',
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -10,6 +11,11 @@ var osm = new ol.layer.Tile({
var map = new ol.Map({
layers: [osm],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.BingMaps');
goog.require('ol.source.OSM');
@@ -17,6 +18,11 @@ var bing = new ol.layer.Tile({
var map = new ol.Map({
layers: [osm, bing],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2

View File

@@ -1,64 +0,0 @@
/**
* Loader to add the plovr generated script to the document.
*
* The following default values may be overridden with query string
* parameters:
*
* * hostname - the current hostname (window.location.hostname)
* * port - 9810
* * mode - RAW
* * id - id param in loader.js query string; defaults to 'ol' if not set
*
* Usage:
*
* <script src="loader.js?id=myexample"></script>
*/
(function() {
var scripts = document.getElementsByTagName('script');
var params = {
hostname: window.location.hostname,
port: '9810',
mode: 'RAW',
id: 'ol'
};
if (window.location.protocol === 'file:' && !params.hostname) {
params.hostname = 'localhost';
}
var chunks, search, pair;
var src, index, id, i;
for (i = scripts.length - 1; i >= 0; --i) {
src = scripts[i].getAttribute('src');
if (~(index = src.indexOf('loader.js?'))) {
// script params
search = src.substr(index + 10);
chunks = search ? search.split('&') : [];
for (i = chunks.length - 1; i >= 0; --i) {
pair = chunks[i].split('=');
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
break;
}
}
// url params
search = window.location.search.substring(1);
chunks = search ? search.split('&') : [];
for (i = chunks.length - 1; i >= 0; --i) {
pair = chunks[i].split('=');
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
var host = params.hostname + ':' + params.port;
delete params.hostname;
delete params.port;
var pairs = [];
for (var key in params) {
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
}
var url = 'http://' + host + '/compile?' + pairs.join('&');
document.write('<script type="text/javascript" src="' + url + '"></script>');
}());

View File

@@ -1,6 +1,7 @@
goog.require('ol.Attribution');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -42,6 +43,11 @@ var map = new ol.Map({
openSeaMapLayer
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
maxZoom: 18,
center: [-244780.24508882355, 5986452.183179816],

View File

@@ -15,6 +15,7 @@ var bounds = [
var map = new ol.Map({
layers: [
new ol.layer.Image({
extent: bounds,
source: new ol.source.MapGuide({
projection: 'EPSG:4326',
url: agentUrl,
@@ -24,8 +25,7 @@ var map = new ol.Map({
MAPDEFINITION: mdf,
FORMAT: 'PNG'
},
ratio: 2,
extent: bounds
ratio: 2
})
})
],

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
goog.require('ol.source.TileJSON');
@@ -27,6 +28,11 @@ var map = new ol.Map({
],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [653600, 5723680],
zoom: 5

View File

@@ -127,8 +127,8 @@ var source = new ol.source.GeoJSON(
'coordinates': [
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
[-3e6, 6e6], [-5e6, 6e6]]],
[[[-2e6, 6e6], [-2e6, 8e6], [0e6, 8e6],
[0e6, 6e6], [-2e6, 6e6]]],
[[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6],
[0, 6e6], [-2e6, 6e6]]],
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
[3e6, 6e6], [1e6, 6e6]]]
]
@@ -141,7 +141,7 @@ var source = new ol.source.GeoJSON(
'geometries': [
{
'type': 'LineString',
'coordinates': [[-5e6, -5e6], [0e6, -5e6]]
'coordinates': [[-5e6, -5e6], [0, -5e6]]
},
{
'type': 'Point',

View File

@@ -19,7 +19,11 @@ var mousePositionControl = new ol.control.MousePosition({
});
var map = new ol.Map({
controls: ol.control.defaults().extend([mousePositionControl]),
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}).extend([mousePositionControl]),
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.extent');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
@@ -14,6 +15,11 @@ var map = new ol.Map({
],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2

View File

@@ -7,7 +7,11 @@ goog.require('ol.source.OSM');
var map = new ol.Map({
controls: ol.control.defaults().extend([
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}).extend([
new ol.control.ZoomToExtent({
extent: [
813079.7791264898, 5929220.284081122,

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -12,6 +13,11 @@ var map = new ol.Map({
],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [-25860000, 4130000],
rotation: Math.PI / 6,

View File

@@ -10,7 +10,11 @@ goog.require('ol.source.OSM');
var scaleLineControl = new ol.control.ScaleLine();
var map = new ol.Map({
controls: ol.control.defaults().extend([
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}).extend([
scaleLineControl
]),
layers: [

View File

@@ -33,7 +33,17 @@
<div class="span12">
<h4 id="title">Select features example</h4>
<p id="shortdesc">Example of using the Select interaction. Select features by clicking polygons. Hold the Shift-key to toggle the feature in the selection.</p>
<p id="shortdesc">Example of using the Select interaction. Choose between <code>Single-click</code>, <code>Click</code> and <code>Hover</code> as the event type for selection in the combobox below. When using <code>Single-click</code> or <code>Click</code> you can hold do <code>Shift</code> key to toggle the feature in the selection.</p>
<p>Note: when <code>Single-click</code> is used double-clicks won't select features. This in contrast to <code>Click</code>, where a double-click will both select the feature and zoom the map (because of the <code>DoubleClickZoom</code> interaction). Note that <code>Single-click</code> is less responsive than <code>Click</code> because of the delay it uses to detect double-clicks.</p>
<form class="form-inline">
<label>Action type &nbsp;</label>
<select id="type">
<option value="none" selected>None</option>
<option value="singleclick">Single-click</option>
<option value="click">Click</option>
<option value="mousemove">Hover</option>
</select>
</form>
<div id="docs">
<p>See the <a href="select-features.js" target="_blank">select-features.js source</a> to see how this is done.</p>
</div>

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.events.condition');
goog.require('ol.interaction');
goog.require('ol.interaction.Select');
goog.require('ol.layer.Tile');
@@ -18,10 +19,7 @@ var vector = new ol.layer.Vector({
})
});
var select = new ol.interaction.Select();
var map = new ol.Map({
interactions: ol.interaction.defaults().extend([select]),
layers: [raster, vector],
target: 'map',
view: new ol.View({
@@ -29,3 +27,46 @@ var map = new ol.Map({
zoom: 2
})
});
var select = null; // ref to currently selected interaction
// select interaction working on "singleclick"
var selectSingleClick = new ol.interaction.Select();
// select interaction working on "click"
var selectClick = new ol.interaction.Select({
condition: ol.events.condition.click
});
// select interaction working on "mousemove"
var selectMouseMove = new ol.interaction.Select({
condition: ol.events.condition.mouseMove
});
var selectElement = document.getElementById('type');
var changeInteraction = function() {
if (select !== null) {
map.removeInteraction(select);
}
var value = selectElement.value;
if (value == 'singleclick') {
select = selectSingleClick;
} else if (value == 'click') {
select = selectClick;
} else if (value == 'mousemove') {
select = selectMouseMove;
} else {
select = null;
}
if (select !== null) {
map.addInteraction(select);
}
};
/**
* onchange callback on the select element.
*/
selectElement.onchange = changeInteraction;
changeInteraction();

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -10,6 +11,11 @@ var map = new ol.Map({
source: new ol.source.OSM()
})
],
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
view: new ol.View({

View File

@@ -8,7 +8,7 @@
<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 from capabilities example</title>
<title>Sphere Mollweide example</title>
</head>
<body>
@@ -31,20 +31,22 @@
<div class="row-fluid">
<div class="span12">
<h4 id="title">WMTS from capabilities example</h4>
<p id="shortdesc">Example of a WMTS source built from a WMTS getCapabilities response.</p>
<h4 id="title">Sphere Mollweide example</h4>
<p id="shortdesc">Example of a Sphere Mollweide map with a Graticule component.</p>
<div id="docs">
<p>See the <a href="wmts-from-capabilities.js" target="_blank">wmts-from-capabilities.js source</a> to see how this is done.</p>
<p>See the <a href="sphere-mollweide.js" target="_blank">sphere-mollweide.js source</a> to see how this is done.</p>
</div>
<div id="tags">wmts</div>
<div id="tags">graticule, Mollweide, projection, proj4js</div>
</div>
</div>
</div>
<script src="loader.js?id=wmts-from-capabilities" type="text/javascript"></script>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
<script src="loader.js?id=sphere-mollweide" type="text/javascript"></script>
</body>
</html>

View File

@@ -0,0 +1,42 @@
goog.require('ol.Graticule');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Vector');
goog.require('ol.proj');
goog.require('ol.source.GeoJSON');
proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' +
'+b=6371000 +units=m +no_defs');
// Configure the Sphere Mollweide projection object with an extent,
// and a world extent. These are required for the Graticule.
var sphereMollweideProjection = ol.proj.get('ESRI:53009');
sphereMollweideProjection.setExtent([
-9009954.605703328, -9009954.605703328,
9009954.605703328, 9009954.605703328]);
sphereMollweideProjection.setWorldExtent([-179, -90, 179, 90]);
var map = new ol.Map({
keyboardEventTarget: document,
layers: [
new ol.layer.Vector({
source: new ol.source.GeoJSON({
projection: sphereMollweideProjection,
url: 'data/geojson/countries-110m.geojson'
})
})
],
renderer: 'canvas',
target: 'map',
view: new ol.View({
center: [0, 0],
projection: sphereMollweideProjection,
resolutions: [65536, 32768, 16384, 8192, 4096, 2048],
zoom: 0
})
});
var graticule = new ol.Graticule({
map: map
});

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
@@ -11,6 +12,11 @@ var map = new ol.Map({
})
],
renderer: exampleNS.getRendererFromQueryString(),
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2

View File

@@ -1,5 +1,6 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.format.OSMXML');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
@@ -90,8 +91,8 @@ var styles = {
var vectorSource = new ol.source.ServerVector({
format: new ol.format.OSMXML(),
loader: function(extent, resolution, projection) {
var transform = ol.proj.getTransform(projection, 'EPSG:4326');
var epsg4326Extent = transform(extent, []);
var epsg4326Extent =
ol.proj.transformExtent(extent, projection, 'EPSG:4326');
var url = 'http://overpass-api.de/api/xapi?map?bbox=' +
epsg4326Extent.join(',');
$.ajax(url).then(function(response) {
@@ -131,6 +132,11 @@ var raster = new ol.layer.Tile({
var map = new ol.Map({
layers: [raster, vector],
target: document.getElementById('map'),
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [739218, 5906096],
maxZoom: 19,

View File

@@ -10,10 +10,6 @@ goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.tilegrid.XYZ');
var loadFeatures = function(response) {
vectorSource.addFeatures(vectorSource.readFeatures(response));
};
var vectorSource = new ol.source.ServerVector({
format: new ol.format.GeoJSON(),
loader: function(extent, resolution, projection) {
@@ -32,6 +28,10 @@ var vectorSource = new ol.source.ServerVector({
projection: 'EPSG:3857'
});
var loadFeatures = function(response) {
vectorSource.addFeatures(vectorSource.readFeatures(response));
};
var vector = new ol.layer.Vector({
source: vectorSource,
style: new ol.style.Style({

View File

@@ -8,7 +8,7 @@
<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>Tiled WMS with Proj4js projection example</title>
<title>Tiled WMS with custom projection example</title>
</head>
<body>
@@ -31,21 +31,18 @@
<div class="row-fluid">
<div class="span12">
<h4 id="title">Tiled WMS with Proj4js projection example</h4>
<h4 id="title">Tiled WMS with custom projection example</h4>
<p id="shortdesc">Example of two tiled WMS layers (Pixelmap 1:1'000'000 and national parks) using the projection EPSG:21781.</p>
<div id="docs">
<p>See the <a href="wms-custom-proj.js" target="_blank">wms-custom-proj.js source</a> to see how this is done.</p>
</div>
<div id="tags">wms, tile, tilelayer, proj4js, projection</div>
<div id="tags">wms, tile, tilelayer, projection</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/defs/EPSG21781.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=wms-custom-proj" type="text/javascript"></script>

View File

@@ -5,17 +5,46 @@ goog.require('ol.control');
goog.require('ol.control.ScaleLine');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.source.TileWMS');
var projection = ol.proj.configureProj4jsProjection({
// By default OpenLayers does not know about the EPSG:21781 (Swiss) projection.
// So we create a projection instance for EPSG:21781 and pass it to
// ol.proj.addProjection to make it available to the library.
var projection = new ol.proj.Projection({
code: 'EPSG:21781',
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
// The extent is used to determine zoom level 0. Recommended values for a
// projection's validity extent can be found at http://epsg.io/.
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864],
units: 'm'
});
ol.proj.addProjection(projection);
// We also declare EPSG:21781/EPSG:4326 transform functions. These functions
// are necessary for the ScaleLine control and when calling ol.proj.transform
// for setting the view's initial center (see below).
ol.proj.addCoordinateTransforms('EPSG:4326', projection,
function(coordinate) {
return [
WGStoCHy(coordinate[1], coordinate[0]),
WGStoCHx(coordinate[1], coordinate[0])
];
},
function(coordinate) {
return [
CHtoWGSlng(coordinate[0], coordinate[1]),
CHtoWGSlat(coordinate[0], coordinate[1])
];
});
var extent = [420000, 30000, 900000, 350000];
var layers = [
new ol.layer.Tile({
extent: extent,
source: new ol.source.TileWMS({
url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
@@ -29,11 +58,11 @@ var layers = [
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
'FORMAT': 'image/jpeg'
},
extent: extent,
serverType: 'mapserver'
})
}),
new ol.layer.Tile({
extent: extent,
source: new ol.source.TileWMS({
url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
@@ -44,7 +73,6 @@ var layers = [
'National parks / geo.admin.ch</a>'
})],
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
extent: extent,
serverType: 'mapserver'
})
})
@@ -61,8 +89,160 @@ var map = new ol.Map({
target: 'map',
view: new ol.View({
projection: projection,
center: [660000, 190000],
center: ol.proj.transform([8.23, 46.86], 'EPSG:4326', 'EPSG:21781'),
extent: extent,
zoom: 2
})
});
/*
* Swiss projection transform functions downloaded from
* http://www.swisstopo.admin.ch/internet/swisstopo/en/home/products/software/products/skripts.html
*/
// Convert WGS lat/long (° dec) to CH y
function WGStoCHy(lat, lng) {
// Converts degrees dec to sex
lat = DECtoSEX(lat);
lng = DECtoSEX(lng);
// Converts degrees to seconds (sex)
lat = DEGtoSEC(lat);
lng = DEGtoSEC(lng);
// Axiliary values (% Bern)
var lat_aux = (lat - 169028.66) / 10000;
var lng_aux = (lng - 26782.5) / 10000;
// Process Y
var y = 600072.37 +
211455.93 * lng_aux -
10938.51 * lng_aux * lat_aux -
0.36 * lng_aux * Math.pow(lat_aux, 2) -
44.54 * Math.pow(lng_aux, 3);
return y;
}
// Convert WGS lat/long (° dec) to CH x
function WGStoCHx(lat, lng) {
// Converts degrees dec to sex
lat = DECtoSEX(lat);
lng = DECtoSEX(lng);
// Converts degrees to seconds (sex)
lat = DEGtoSEC(lat);
lng = DEGtoSEC(lng);
// Axiliary values (% Bern)
var lat_aux = (lat - 169028.66) / 10000;
var lng_aux = (lng - 26782.5) / 10000;
// Process X
var x = 200147.07 +
308807.95 * lat_aux +
3745.25 * Math.pow(lng_aux, 2) +
76.63 * Math.pow(lat_aux, 2) -
194.56 * Math.pow(lng_aux, 2) * lat_aux +
119.79 * Math.pow(lat_aux, 3);
return x;
}
// Convert CH y/x to WGS lat
function CHtoWGSlat(y, x) {
// Converts militar to civil and to unit = 1000km
// Axiliary values (% Bern)
var y_aux = (y - 600000) / 1000000;
var x_aux = (x - 200000) / 1000000;
// Process lat
var lat = 16.9023892 +
3.238272 * x_aux -
0.270978 * Math.pow(y_aux, 2) -
0.002528 * Math.pow(x_aux, 2) -
0.0447 * Math.pow(y_aux, 2) * x_aux -
0.0140 * Math.pow(x_aux, 3);
// Unit 10000" to 1 " and converts seconds to degrees (dec)
lat = lat * 100 / 36;
return lat;
}
// Convert CH y/x to WGS long
function CHtoWGSlng(y, x) {
// Converts militar to civil and to unit = 1000km
// Axiliary values (% Bern)
var y_aux = (y - 600000) / 1000000;
var x_aux = (x - 200000) / 1000000;
// Process long
var lng = 2.6779094 +
4.728982 * y_aux +
0.791484 * y_aux * x_aux +
0.1306 * y_aux * Math.pow(x_aux, 2) -
0.0436 * Math.pow(y_aux, 3);
// Unit 10000" to 1 " and converts seconds to degrees (dec)
lng = lng * 100 / 36;
return lng;
}
// Convert SEX DMS angle to DEC
function SEXtoDEC(angle) {
// Extract DMS
var deg = parseInt(angle, 10);
var min = parseInt((angle - deg) * 100, 10);
var sec = (((angle - deg) * 100) - min) * 100;
// Result in degrees sex (dd.mmss)
return deg + (sec / 60 + min) / 60;
}
// Convert DEC angle to SEX DMS
function DECtoSEX(angle) {
// Extract DMS
var deg = parseInt(angle, 10);
var min = parseInt((angle - deg) * 60, 10);
var sec = (((angle - deg) * 60) - min) * 60;
// Result in degrees sex (dd.mmss)
return deg + min / 100 + sec / 10000;
}
// Convert Degrees angle to seconds
function DEGtoSEC(angle) {
// Extract DMS
var deg = parseInt(angle, 10);
var min = parseInt((angle - deg) * 100, 10);
var sec = (((angle - deg) * 100) - min) * 100;
// Avoid rounding problems with seconds=0
var parts = String(angle).split('.');
if (parts.length == 2 && parts[1].length == 2) {
min = Number(parts[1]);
sec = 0;
}
// Result in degrees sex (dd.mmss)
return sec + min * 60 + deg * 3600;
}

View File

@@ -8,7 +8,7 @@
<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>Single image WMS with custom projection example</title>
<title>Single image WMS with Proj4js projection example</title>
</head>
<body>
@@ -31,13 +31,13 @@
<div class="row-fluid">
<div class="span12">
<h4 id="title">Single image WMS with custom projection example</h4>
<h4 id="title">Single image WMS with Proj4js projection example</h4>
<p id="shortdesc">Example of two single image WMS layers.</p>
<div id="docs">
<p>Pixelmap 1:1'000'000 with National Parks overlay using the projection EPSG:21781.</p>
<p>See the <a href="wms-image-custom-proj.js" target="_blank">wms-image-custom-proj.js source</a> to see how this is done.</p>
</div>
<div id="tags">wms, single image, projection</div>
<div id="tags">wms, single image, proj4js, projection</div>
</div>
</div>
@@ -45,8 +45,8 @@
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/defs/EPSG21781.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
<script src="http://epsg.io/21781.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=wms-image-custom-proj" type="text/javascript"></script>

View File

@@ -1,19 +1,30 @@
goog.require('ol.Attribution');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.control.ScaleLine');
goog.require('ol.layer.Image');
goog.require('ol.proj');
goog.require('ol.source.ImageWMS');
var projection = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781',
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
});
// Transparent Proj4js support: ol.proj.get() creates and returns a projection
// known to Proj4js if it is unknown to OpenLayers, and registers functions to
// transform between all registered projections.
// EPSG:21781 is known to Proj4js because its definition was loaded in the html.
// Note that we are getting the projection object here to set the extent. If
// you do not need this, you do not have to use ol.proj.get(); simply use the
// string code in the view projection below and the transforms will be
// registered transparently.
var projection = ol.proj.get('EPSG:21781');
// The extent is used to determine zoom level 0. Recommended values for a
// projection's validity extent can be found at http://epsg.io/.
projection.setExtent([485869.5728, 76443.1884, 837076.5648, 299941.7864]);
var extent = [420000, 30000, 900000, 350000];
var layers = [
new ol.layer.Image({
extent: extent,
source: new ol.source.ImageWMS({
url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
@@ -27,11 +38,11 @@ var layers = [
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
'FORMAT': 'image/jpeg'
},
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver'),
extent: extent
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver')
})
}),
new ol.layer.Image({
extent: extent,
source: new ol.source.ImageWMS({
url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
@@ -42,19 +53,21 @@ var layers = [
'National parks / geo.admin.ch</a>'
})],
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver'),
extent: extent
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver')
})
})
];
var map = new ol.Map({
controls: ol.control.defaults().extend([
new ol.control.ScaleLine()
]),
layers: layers,
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
view: new ol.View({
projection: projection,
center: [660000, 190000],
center: ol.proj.transform([8.23, 46.86], 'EPSG:4326', 'EPSG:21781'),
extent: extent,
zoom: 2
})

View File

@@ -11,11 +11,11 @@ var layers = [
source: new ol.source.MapQuest({layer: 'sat'})
}),
new ol.layer.Image({
extent: [-13884991, 2870341, -7455066, 6338219],
source: new ol.source.ImageWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
params: {'LAYERS': 'topp:states'},
serverType: 'geoserver',
extent: [-13884991, 2870341, -7455066, 6338219]
serverType: 'geoserver'
})
})
];

View File

@@ -42,8 +42,10 @@ var layers = [
];
// A minimal projection object is configured with only the SRS code and the map
// units. No client side coordinate transforms are possible with such a
// projection object.
// units. No client-side coordinate transforms are possible with such a
// projection object. Requesting tiles only needs the code together with a
// tile grid of Cartesian coordinates; it does not matter how those
// coordinates relate to latitude or longitude.
var projection = new ol.proj.Projection({
code: 'EPSG:21781',
units: 'm'

View File

@@ -10,10 +10,10 @@ var layers = [
source: new ol.source.MapQuest({layer: 'sat'})
}),
new ol.layer.Tile({
extent: [-13884991, 2870341, -7455066, 6338219],
source: new ol.source.TileWMS(/** @type {olx.source.TileWMSOptions} */ ({
url: 'http://demo.opengeo.org/geoserver/wms',
params: {'LAYERS': 'topp:states', 'TILED': true},
extent: [-13884991, 2870341, -7455066, 6338219],
serverType: 'geoserver'
}))
})

View File

@@ -9,6 +9,11 @@
<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 HiDPI example</title>
<style>
.map {
background: white;
}
</style>
</head>
<body>

View File

@@ -23,7 +23,6 @@ var urls = [
var hiDPI = ol.BrowserFeature.DEVICE_PIXEL_RATIO > 1;
var source = new ol.source.WMTS({
extent: [977844.377599999, 5837774.6617, 1915609.8654, 6295560.8122],
projection: 'EPSG:3857',
layer: hiDPI ? 'bmaphidpi' : 'geolandbasemap',
tilePixelRatio: hiDPI ? 2 : 1,
@@ -64,6 +63,7 @@ var source = new ol.source.WMTS({
var map = new ol.Map({
layers: [
new ol.layer.Tile({
extent: [977844.377599999, 5837774.6617, 1915609.8654, 6295560.8122],
source: source
})
],

View File

@@ -1,6 +1,7 @@
goog.require('ol.Attribution');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.extent');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
@@ -34,6 +35,7 @@ var map = new ol.Map({
}),
new ol.layer.Tile({
opacity: 0.7,
extent: projectionExtent,
source: new ol.source.WMTS({
attributions: [attribution],
url: 'http://services.arcgisonline.com/arcgis/rest/' +
@@ -47,12 +49,16 @@ var map = new ol.Map({
resolutions: resolutions,
matrixIds: matrixIds
}),
extent: projectionExtent,
style: 'default'
})
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [-11158582, 4813697],
zoom: 4

View File

@@ -8,12 +8,7 @@
<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>IGN WMTS example</title>
<style>
.ol-logo ul li {
margin-right: 3px;
}
</style>
<title>XYZ Retina tiles example</title>
</head>
<body>
@@ -36,24 +31,22 @@
<div class="row-fluid">
<div class="span12">
<h4 id="title">IGN WMTS example</h4>
<p id="shortdesc">Demonstrates displaying IGN (France) WMTS layers.</p>
<h4 id="title">XYZ with Retina tiles example</h4>
<p id="shortdesc">Example of Retina / HiDPI mercator tiles (512x512px) available as XYZ.</p>
<div id="docs">
<p>In this example two IGN WMTS layers are displayed: <em>Ortho imagery and Cadastral parcels.</em>.
For more information on IGN's WMTS service see the
<a href="http://professionnels.ign.fr/api-sig">IGN Géoportail API web page</a> (french).</p>
<p>See the <a href="wmts-ign.js" target="_blank">wmts-ign.js source</a> to see how this is done.</p>
<p>The ol.source.XYZ must contain <code>tilePixelRatio</code> parameter. The tiles were prepared from a GeoTIFF file with <a href="http://www.maptiler.com/">MapTiler</a>.</p>
<p>See the <a href="xyz-retina.js" target="_blank">xyz-retina.js source</a> for details on how this is done.</p>
</div>
<div id="tags">french, ign, geoportail, wmts</div>
<div id="tags">retina, hidpi, xyz, maptiler, @2x, devicePixelRatio</div>
</div>
</div>
</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
<script src="loader.js?id=wmts-ign" type="text/javascript"></script>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=xyz-retina" type="text/javascript"></script>
</body>
</html>

41
examples/xyz-retina.js Normal file
View File

@@ -0,0 +1,41 @@
goog.require('ol.Attribution');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
goog.require('ol.source.OSM');
goog.require('ol.source.XYZ');
var attribution = new ol.Attribution({
html: 'Tiles rendered with <a href="http://www.maptiler.com/"> &copy; USGS'
});
var mapMinZoom = 1;
var mapMaxZoom = 15;
var mapExtent = [-112.261791, 35.983744, -112.113981, 36.132062];
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Tile({
source: new ol.source.XYZ({
url: 'http://tileserver.maptiler.com/grandcanyon@2x/{z}/{x}/{y}.png',
tilePixelRatio: 2, // THIS IS IMPORTANT
maxExtent: ol.proj.transformExtent(
mapExtent, 'EPSG:4326', 'EPSG:3857'),
minZoom: mapMinZoom,
maxZoom: mapMaxZoom
})
})
],
view: new ol.View({
projection: 'EPSG:3857',
center: ol.proj.transform([-112.18688965, 36.057944835],
'EPSG:4326', 'EPSG:3857'),
zoom: 12
})
});

View File

@@ -1,6 +1,7 @@
goog.require('ol.Attribution');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.control');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
goog.require('ol.source.XYZ');
@@ -13,6 +14,11 @@ var attribution = new ol.Attribution({
var map = new ol.Map({
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
layers: [
new ol.layer.Tile({
source: new ol.source.OSM({

View File

@@ -8,63 +8,6 @@
* @externs
*/
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1060
/** @type {Date} */
HTMLInputElement.prototype.valueAsDate;
/** @type {number} */
HTMLInputElement.prototype.valueAsNumber;
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1084
/** @type {?number} */
DeviceRotationRate.prototype.alpha;
/** @type {?number} */
DeviceRotationRate.prototype.beta;
/** @type {?number} */
DeviceRotationRate.prototype.gamma;
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1088
/** @type {?number} */
DeviceOrientationEvent.prototype.webkitCompassAccuracy;
/** @type {?number} */
DeviceOrientationEvent.prototype.webkitCompassHeading;
// IE 11 fullscreen API
// http://msdn.microsoft.com/en-us/library/ie/dn265028(v=vs.85).aspx
/** @return {void} */
Element.prototype.msRequestFullscreen = function() {};
/** @return {void} */
Element.prototype.msExitFullscreen = function() {};
/** @type {boolean} */
Document.prototype.msFullscreenEnabled;
/** @type {Element} */
Document.prototype.msFullscreenElement;
/** @type {number} */
Touch.prototype.force;

2296
externs/jquery-1.7.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,92 +1,22 @@
/**
* @externs
* @see http://trac.osgeo.org/proj4js/
* @see http://proj4js.org/
*/
/**
* @type {Object}
* @param {...*} var_args
* @return {undefined|Array.<number>|Object.<{
* forward: function(Array.<number>): Array.<number>,
* inverse: function(Array.<number>): Array.<number>}>}
*/
var Proj4js = {};
var proj4 = function(var_args) {};
/**
* @type {Object.<string, string>}
* @param {string} name
* @param {(string|Object)=} opt_def
* @return {undefined|Object.<string, Object.<{axis: string, units: string,
* to_meter: number}>>}
*/
Proj4js.defs;
/**
* @type {function(string)}
*/
Proj4js.reportError;
/**
* @constructor
* @param {number} x
* @param {number} y
*/
Proj4js.Point = function(x, y) {};
/**
* @type {number}
*/
Proj4js.Point.prototype.x;
/**
* @type {number}
*/
Proj4js.Point.prototype.y;
/**
* @constructor
* @param {string} srsCode
* @param {Function=} opt_callback
*/
Proj4js.Proj = function(srsCode, opt_callback) {};
/**
* @type {string}
*/
Proj4js.Proj.prototype.axis;
/**
* @type {string}
*/
Proj4js.Proj.prototype.title;
/**
* @type {string}
*/
Proj4js.Proj.prototype.units;
/**
* @type {string}
*/
Proj4js.Proj.prototype.srsCode;
/**
* @type {number}
*/
Proj4js.Proj.prototype.to_meter;
/**
* @nosideeffects
* @param {Proj4js.Proj} source
* @param {Proj4js.Proj} dest
* @param {Proj4js.Point|{x:number, y:number}} point
* @return {Proj4js.Point}
*/
Proj4js.transform = function(source, dest, point) {return null;};
proj4.defs = function(name, opt_def) {};

View File

@@ -32,7 +32,7 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) {
/**
* @type {ol.Coordinate}
* @todo api
* @api
*/
this.coordinate = map.getEventCoordinate(this.originalEvent);
@@ -73,7 +73,7 @@ ol.control.Control = function(options) {
/**
* Application subclasses may override this.
* @param {ol.Map} map Map.
* @todo api
* @api
*/
ol.control.Control.prototype.setMap = function(map) {
// ...
@@ -88,7 +88,7 @@ Object literals cannot be exported like classes. To make sure that their propert
/**
* @typedef {{element: (Element|undefined),
* target: (Element|string|undefined)}}
* @todo api
* @api
*/
olx.control.ControlOptions;

View File

@@ -1,134 +0,0 @@
goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.control');
goog.require('ol.expr');
goog.require('ol.geom.LineString');
goog.require('ol.geom.Point');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Rule');
goog.require('ol.style.Shape');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.style.Text');
var style = new ol.style.Style({rules: [
new ol.style.Rule({
filter: 'where == "outer"',
symbolizers: [
new ol.style.Stroke({
color: ol.expr.parse('color'),
width: 4,
opacity: 1,
zIndex: 1
})
]
}),
new ol.style.Rule({
filter: 'where == "inner"',
symbolizers: [
new ol.style.Stroke({
color: '#013',
width: 4,
opacity: 1
}),
new ol.style.Stroke({
color: ol.expr.parse('color'),
width: 2,
opacity: 1
})
]
}),
new ol.style.Rule({
filter: 'geometryType("Point")',
symbolizers: [
new ol.style.Shape({
size: 40,
fill: new ol.style.Fill({color: '#013'})
}),
new ol.style.Text({
color: '#bada55',
text: ol.expr.parse('label'),
fontFamily: 'Calibri,sans-serif',
fontSize: 14
})
]
})
]});
var vector = new ol.layer.Vector({
style: style,
source: new ol.source.Vector({
features: [
new ol.Feature({
color: '#BADA55',
where: 'inner',
geometry: new ol.geom.LineString(
[[-10000000, -10000000], [10000000, 10000000]])
}),
new ol.Feature({
color: '#BADA55',
where: 'inner',
geometry: new ol.geom.LineString(
[[-10000000, 10000000], [10000000, -10000000]])
}),
new ol.Feature({
color: '#013',
where: 'outer',
geometry: new ol.geom.LineString(
[[-10000000, -10000000], [-10000000, 10000000]])
}),
new ol.Feature({
color: '#013',
where: 'outer',
geometry: new ol.geom.LineString(
[[-10000000, 10000000], [10000000, 10000000]])
}),
new ol.Feature({
color: '#013',
where: 'outer',
geometry: new ol.geom.LineString(
[[10000000, 10000000], [10000000, -10000000]])
}),
new ol.Feature({
color: '#013',
where: 'outer',
geometry: new ol.geom.LineString(
[[10000000, -10000000], [-10000000, -10000000]])
}),
new ol.Feature({
label: 'South',
geometry: new ol.geom.Point([0, -6000000])
}),
new ol.Feature({
label: 'West',
geometry: new ol.geom.Point([-6000000, 0])
}),
new ol.Feature({
label: 'North',
geometry: new ol.geom.Point([0, 6000000])
}),
new ol.Feature({
label: 'East',
geometry: new ol.geom.Point([6000000, 0])
})
]
})
});
var map = new ol.Map({
layers: [vector],
controls: ol.control.defaults({
attribution: false
}),
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 1
})
});

View File

@@ -1,80 +0,0 @@
goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.expr');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.proj');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Rule');
goog.require('ol.style.Shape');
goog.require('ol.style.ShapeType');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
});
// build up some GeoJSON features
var count = 20000;
var features = new Array(count);
var e = 18000000;
for (var i = 0; i < count; ++i) {
features[i] = {
type: 'Feature',
properties: {
i: i,
size: i % 2 ? 10 : 20
},
geometry: {
type: 'Point',
coordinates: [
2 * e * Math.random() - e, 2 * e * Math.random() - e
]
}
};
}
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
projection: ol.proj.get('EPSG:3857'),
parser: new ol.parser.GeoJSON(),
data: {
type: 'FeatureCollection',
features: features
}
}),
style: new ol.style.Style({rules: [
new ol.style.Rule({
symbolizers: [
new ol.style.Shape({
type: ol.style.ShapeType.CIRCLE,
size: ol.expr.parse('size'),
stroke: new ol.style.Stroke({color: '#666666'}),
fill: new ol.style.Fill({color: '#bada55'})
})
]
})
]})
});
var popup = new ol.Overlay({
element: document.getElementById('popup')
});
var map = new ol.Map({
layers: [vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 2
}),
overlays: [popup]
});

View File

@@ -1,56 +0,0 @@
<!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>Vector layer with styling from SLD example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./">OpenLayers 3 Examples</a>
<ul class="nav pull-right">
<li><iframe class="github-watch-button" src="http://ghbtns.com/github-btn.html?user=openlayers&repo=ol3&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" height="20" width="90"></iframe></li>
<li><a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-hashtags="openlayers">&nbsp;</a></li>
<li><div class="g-plusone-wrapper"><div class="g-plusone" data-size="medium" data-annotation="none"></div></div></li>
</ul>
</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="span4">
<h4 id="title">Vector layer example</h4>
<p id="shortdesc">Example of a countries vector layer with country labels at higher zoom levels, styling info coming from SLD.</p>
<div id="docs">
<p>See the <a href="vector-layer-sld.js" target="_blank">vector-layer-sld.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector, geojson, style, SLD, Styled Layer Descriptor</div>
</div>
</div>
</div>
<script src="loader.js?id=vector-layer-sld" type="text/javascript"></script>
<script src="../resources/social-links.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,54 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.control');
goog.require('ol.control.ScaleLine');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.parser.ogc.SLD');
goog.require('ol.source.MapQuest');
goog.require('ol.source.Vector');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'sat'})
});
var xhr = new XMLHttpRequest();
xhr.open('GET', 'data/countries.sld', true);
/**
* onload handler for the XHR request.
*/
xhr.onload = function() {
if (xhr.status == 200) {
var map = new ol.Map({
controls: ol.control.defaults().extend([
new ol.control.ScaleLine()
]),
layers: [raster],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 1
})
});
var units = map.getView().getView2D().getProjection().getUnits();
var sld = new ol.parser.ogc.SLD().read(xhr.responseText, {
units: units
});
var style = sld.namedLayers['countries'].userStyles[0];
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.GeoJSON(),
url: 'data/countries.geojson'
}),
style: style
});
map.getLayers().push(vector);
}
};
xhr.send();

View File

@@ -1,49 +0,0 @@
<!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 Capabilities 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 Capabilities parsing example</h4>
<p id="shortdesc">Example of parsing a WMTS Capabilities document.</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, WMTSCapabilities</div>
</div>
<div class="span8">
<pre id="log"></pre>
</div>
</div>
</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js" type="text/javascript"></script>
<script src="loader.js?id=wmts-capabilities" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

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