Merge branch 'master' of github.com:openlayers/ol3 into vector
This commit is contained in:
@@ -4,7 +4,7 @@ before_install:
|
||||
|
||||
before_script:
|
||||
- "./build.py plovr"
|
||||
- "./build.py serve-precommit &"
|
||||
- "./build.py serve-integration-test &"
|
||||
- "sleep 3"
|
||||
|
||||
script: "./build.py JSDOC=jsdoc/jsdoc precommit"
|
||||
script: "./build.py JSDOC=jsdoc/jsdoc integration-test"
|
||||
|
||||
57
AUTHORS.md
Normal file
57
AUTHORS.md
Normal file
@@ -0,0 +1,57 @@
|
||||
OpenLayers contributors:
|
||||
|
||||
* Antoine Abt
|
||||
* Mike Adair
|
||||
* Jeff Adams
|
||||
* Seb Benthall
|
||||
* Bruno Binet
|
||||
* Stéphane Brunner
|
||||
* Howard Butler
|
||||
* Bertil Chaupis
|
||||
* John Cole
|
||||
* Tim Coulter
|
||||
* Robert Coup
|
||||
* Jeff Dege
|
||||
* Roald de Wit
|
||||
* Schuyler Erle
|
||||
* Christian López Espínola
|
||||
* John Frank
|
||||
* Sean Gilles
|
||||
* Pierre Giraud
|
||||
* Ivan Grcic
|
||||
* Andreas Hocevar
|
||||
* Marc Jansen
|
||||
* Ian Johnson
|
||||
* Frédéric Junod
|
||||
* Eric Lemoine
|
||||
* Philip Lindsay
|
||||
* Martijn van Oosterhout
|
||||
* David Overstrom
|
||||
* Tom Payne
|
||||
* Corey Puffault
|
||||
* Peter William Robins
|
||||
* Gregers Rygg
|
||||
* Tim Schaub
|
||||
* Christopher Schmidt
|
||||
* Cameron Shorter
|
||||
* Pedro Simonetti
|
||||
* Paul Spencer
|
||||
* Paul Smith
|
||||
* Glen Stampoultzis
|
||||
* James Stembridge
|
||||
* Erik Uzureau
|
||||
* Bart van den Eijnden
|
||||
* Ivan Willig
|
||||
* Thomas Wood
|
||||
* Bill Woodall
|
||||
* Steve Woodbridge
|
||||
* David Zwarg
|
||||
|
||||
Some portions of OpenLayers are used under the Apache 2.0 license, available
|
||||
in doc/licenses/APACHE-2.0.txt.
|
||||
|
||||
Some portions of OpenLayers are used under the MIT license, availabie in
|
||||
doc/licenses/MIT-LICENSE.txt.
|
||||
|
||||
Some portions of OpenLayers are Copyright 2001 Robert Penner, and are used
|
||||
under the BSD license, available in doc/licenses/BSD-LICENSE.txt
|
||||
@@ -50,7 +50,8 @@ Use the following to run the tests:
|
||||
|
||||
$ ./build.py test
|
||||
|
||||
This command assumes that the `phantomjs` command is on your PATH.
|
||||
This command assumes that the `phantomjs` command is on your PATH and that the
|
||||
polvr web server is running (`./build.py serve`).
|
||||
|
||||
### The `precommit` target
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
Copyright 2005-2013 OpenLayers Contributors. All rights reserved. See
|
||||
authors.txt for full list.
|
||||
AUTHORS.md for full list.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
@@ -67,7 +67,7 @@ Run the plovr web server (see above), and either open the `test/ol.html` file
|
||||
in the browser (e.g. <http://localhost:8000/test/ol.html>), or run `./build.py test`
|
||||
on the console (headless testing with PhantomJS, make sure to install it first from http://phantomjs.org/download.html).
|
||||
|
||||
See also the test-specific [readme](https://github.com/openlayers/ol3/tree/master/test).
|
||||
See also the test-specific [README](test/README.md).
|
||||
|
||||
## Run the linter
|
||||
|
||||
@@ -77,9 +77,33 @@ Then:
|
||||
|
||||
$ ./build.py lint
|
||||
|
||||
## Run the precommit hook before pushing a commit:
|
||||
## Run the check hook before pushing a commit
|
||||
|
||||
$ ./build.py precommit
|
||||
$ ./build.py check
|
||||
|
||||
The check hook does a few quick tests to make sure that the basics still work. This includes:
|
||||
|
||||
* Running the linter
|
||||
* Building the library
|
||||
* Running the tests
|
||||
|
||||
|
||||
## Continuous 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. If you want to run the integration tests
|
||||
locally, then you'll need to make sure that Plovr is running if it isn't
|
||||
already, and then start the tests:
|
||||
|
||||
$ ./build.py integration-test
|
||||
|
||||
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.
|
||||
|
||||
## Add examples
|
||||
|
||||
57
authors.txt
57
authors.txt
@@ -1,57 +0,0 @@
|
||||
OpenLayers contributors:
|
||||
|
||||
Antoine Abt
|
||||
Mike Adair
|
||||
Jeff Adams
|
||||
Seb Benthall
|
||||
Bruno Binet
|
||||
Stéphane Brunner
|
||||
Howard Butler
|
||||
Bertil Chaupis
|
||||
John Cole
|
||||
Tim Coulter
|
||||
Robert Coup
|
||||
Jeff Dege
|
||||
Roald de Wit
|
||||
Schuyler Erle
|
||||
Christian López Espínola
|
||||
John Frank
|
||||
Sean Gilles
|
||||
Pierre Giraud
|
||||
Ivan Grcic
|
||||
Andreas Hocevar
|
||||
Marc Jansen
|
||||
Ian Johnson
|
||||
Frédéric Junod
|
||||
Eric Lemoine
|
||||
Philip Lindsay
|
||||
Martijn van Oosterhout
|
||||
David Overstrom
|
||||
Tom Payne
|
||||
Corey Puffault
|
||||
Peter William Robins
|
||||
Gregers Rygg
|
||||
Tim Schaub
|
||||
Christopher Schmidt
|
||||
Cameron Shorter
|
||||
Pedro Simonetti
|
||||
Paul Spencer
|
||||
Paul Smith
|
||||
Glen Stampoultzis
|
||||
James Stembridge
|
||||
Erik Uzureau
|
||||
Bart van den Eijnden
|
||||
Ivan Willig
|
||||
Thomas Wood
|
||||
Bill Woodall
|
||||
Steve Woodbridge
|
||||
David Zwarg
|
||||
|
||||
Some portions of OpenLayers are used under the Apache 2.0 license, available
|
||||
in doc/licenses/APACHE-2.0.txt.
|
||||
|
||||
Some portions of OpenLayers are used under the MIT license, availabie in
|
||||
doc/licenses/MIT-LICENSE.txt.
|
||||
|
||||
Some portions of OpenLayers are Copyright 2001 Robert Penner, and are used
|
||||
under the BSD license, available in doc/licenses/BSD-LICENSE.txt
|
||||
31
build.py
31
build.py
@@ -63,6 +63,7 @@ EXAMPLES_SRC = [path
|
||||
if not path.startswith('examples/bootstrap')
|
||||
if not path.startswith('examples/font-awesome')
|
||||
if path != 'examples/Jugl.js'
|
||||
if path != 'examples/jquery.min.js'
|
||||
if path != 'examples/example-list.js']
|
||||
|
||||
INTERNAL_SRC = [
|
||||
@@ -95,15 +96,18 @@ def report_sizes(t):
|
||||
t.info(' compressed: %d bytes', len(stringio.getvalue()))
|
||||
|
||||
|
||||
virtual('all', 'build-all', 'build', 'examples', 'precommit')
|
||||
virtual('default', 'build')
|
||||
|
||||
|
||||
virtual('precommit', 'lint', 'build-all', 'test', 'build', 'build-examples', 'check-examples', 'doc')
|
||||
virtual('integration-test', 'lint', 'build', 'build-all', 'test', 'build-examples', 'check-examples', 'doc')
|
||||
|
||||
|
||||
virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js')
|
||||
|
||||
|
||||
virtual('check', 'lint', 'build/ol.css', 'build/ol.js', 'test')
|
||||
|
||||
|
||||
virtual('todo', 'fixme')
|
||||
|
||||
|
||||
@@ -206,6 +210,15 @@ def examples_star_json(name, match):
|
||||
'examples/%(id)s.js' % match.groupdict(),
|
||||
'build/src/internal/src/types.js',
|
||||
],
|
||||
'externs': [
|
||||
'//json.js',
|
||||
'//jquery-1.7.js',
|
||||
'externs/bingmaps.js',
|
||||
'externs/bootstrap.js',
|
||||
'externs/geojson.js',
|
||||
'externs/proj4js.js',
|
||||
'externs/tilejson.js',
|
||||
],
|
||||
})
|
||||
with open(t.name, 'w') as f:
|
||||
f.write(content)
|
||||
@@ -227,7 +240,7 @@ def serve(t):
|
||||
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', 'build/ol.json', 'build/ol-all.json', EXAMPLES_JSON, 'test/test.json')
|
||||
|
||||
|
||||
@target('serve-precommit', PLOVR_JAR, INTERNAL_SRC)
|
||||
@target('serve-integration-test', PLOVR_JAR, INTERNAL_SRC)
|
||||
def serve_precommit(t):
|
||||
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', 'build/ol-all.json', 'test/test.json')
|
||||
|
||||
@@ -410,7 +423,7 @@ def hostexamples(t):
|
||||
'build/ol.css', build_dir)
|
||||
t.cp('examples/example-list.html', examples_dir + '/index.html')
|
||||
t.cp('examples/example-list.js', 'examples/example-list.xml',
|
||||
'examples/Jugl.js', examples_dir)
|
||||
'examples/Jugl.js', 'examples/jquery.min.js', examples_dir)
|
||||
t.rm_rf('build/gh-pages/%(BRANCH)s/closure-library')
|
||||
t.makedirs('build/gh-pages/%(BRANCH)s/closure-library')
|
||||
with t.chdir('build/gh-pages/%(BRANCH)s/closure-library'):
|
||||
@@ -476,7 +489,7 @@ else:
|
||||
|
||||
@target('fixme', phony=True)
|
||||
def find_fixme(t):
|
||||
regex = re.compile(".(FIXME|TODO).")
|
||||
regex = re.compile('FIXME|TODO')
|
||||
matches = dict()
|
||||
totalcount = 0
|
||||
for filename in SRC:
|
||||
@@ -485,16 +498,16 @@ def find_fixme(t):
|
||||
if regex.search(line):
|
||||
if (filename not in matches):
|
||||
matches[filename] = list()
|
||||
matches[filename].append("#" + str(lineno + 1).ljust(10) + line.strip())
|
||||
matches[filename].append('#%-10d %s' % (lineno + 1, line.strip()))
|
||||
totalcount += 1
|
||||
f.close()
|
||||
|
||||
for filename in matches:
|
||||
print " ", filename, "has", len(matches[filename]), "matches:"
|
||||
print ' %s has %d matches:' % (filename, len(matches[filename]))
|
||||
for match in matches[filename]:
|
||||
print " ", match
|
||||
print ' %s' % (match,)
|
||||
print
|
||||
print "A total number of", totalcount, "TODO/FIXME was found"
|
||||
print 'A total of %d TODO/FIXME(s) were found' % (totalcount,)
|
||||
|
||||
|
||||
@target('reallyclean')
|
||||
|
||||
@@ -56,8 +56,8 @@ rotateRight.addEventListener('click', function() {
|
||||
var panToLondon = document.getElementById('pan-to-london');
|
||||
panToLondon.addEventListener('click', function() {
|
||||
var pan = ol.animation.pan({
|
||||
source: map.getView().getView2D().getCenter(),
|
||||
duration: 2000
|
||||
duration: 2000,
|
||||
source: map.getView().getView2D().getCenter()
|
||||
});
|
||||
map.addPreRenderFunction(pan);
|
||||
map.getView().getView2D().setCenter(london);
|
||||
@@ -66,9 +66,9 @@ panToLondon.addEventListener('click', function() {
|
||||
var elasticToMoscow = document.getElementById('elastic-to-moscow');
|
||||
elasticToMoscow.addEventListener('click', function() {
|
||||
var pan = ol.animation.pan({
|
||||
source: map.getView().getView2D().getCenter(),
|
||||
duration: 2000,
|
||||
easing: ol.easing.elastic
|
||||
easing: ol.easing.elastic,
|
||||
source: map.getView().getView2D().getCenter()
|
||||
});
|
||||
map.addPreRenderFunction(pan);
|
||||
map.getView().getView2D().setCenter(moscow);
|
||||
@@ -77,9 +77,9 @@ elasticToMoscow.addEventListener('click', function() {
|
||||
var bounceToInstanbul = document.getElementById('bounce-to-instanbul');
|
||||
bounceToInstanbul.addEventListener('click', function() {
|
||||
var pan = ol.animation.pan({
|
||||
source: map.getView().getView2D().getCenter(),
|
||||
duration: 2000,
|
||||
easing: ol.easing.bounce
|
||||
easing: ol.easing.bounce,
|
||||
source: map.getView().getView2D().getCenter()
|
||||
});
|
||||
map.addPreRenderFunction(pan);
|
||||
map.getView().getView2D().setCenter(instanbul);
|
||||
|
||||
@@ -42,7 +42,7 @@ domMap.bindTo('layers', webglMap);
|
||||
domMap.bindTo('view', webglMap);
|
||||
|
||||
var canvasMap = new ol.Map({
|
||||
renderer: ol.RendererHint.DOM,
|
||||
renderer: ol.RendererHint.CANVAS,
|
||||
target: 'canvasMap'
|
||||
});
|
||||
canvasMap.bindTo('layers', webglMap);
|
||||
|
||||
61
examples/geolocation.html
Normal file
61
examples/geolocation.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!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="bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="examples.css" type="text/css">
|
||||
<link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<style>
|
||||
.icon-flag {
|
||||
font-size: 22px;
|
||||
text-shadow: 2px 2px 3px #013;
|
||||
}
|
||||
</style>
|
||||
<title>Geolocation example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="example-list.html">OpenLayers 3 Examples</a>
|
||||
<ul class="nav pull-right">
|
||||
<li><a href="https://github.com/openlayers/ol3"><i class="icon-github"></i></a></li>
|
||||
<li><a href="https://twitter.com/openlayers"><i class="icon-twitter"></i></a></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">Geolocation example</h4>
|
||||
<p id="shortdesc">Example of a geolocation map.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="geolocation.js" target="_blank">geolocation.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<button id="locate"><i class="icon-screenshot"></i> locate</button>
|
||||
<div id="tags">geolocation, openstreetmap</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="jquery.min.js" type="text/javascript"></script>
|
||||
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=geolocation" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
43
examples/geolocation.js
Normal file
43
examples/geolocation.js
Normal file
@@ -0,0 +1,43 @@
|
||||
goog.require('ol.AnchoredElement');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Geolocation');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.OpenStreetMap');
|
||||
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.OpenStreetMap()
|
||||
})
|
||||
],
|
||||
renderers: ol.RendererHints.createFromQueryData(),
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: new ol.Coordinate(0, 0),
|
||||
zoom: 2
|
||||
})
|
||||
});
|
||||
|
||||
var geolocation = new ol.Geolocation();
|
||||
geolocation.bindTo('projection', map.getView());
|
||||
|
||||
var marker = new ol.AnchoredElement({
|
||||
map: map,
|
||||
element: /** @type {Element} */ ($('<i/>').addClass('icon-flag').get(0))
|
||||
});
|
||||
// bind the marker position to the device location.
|
||||
marker.bindTo('position', geolocation);
|
||||
|
||||
geolocation.addEventListener('accuracy_changed', function() {
|
||||
$(marker.getElement()).tooltip({
|
||||
title: this.getAccuracy() + 'm from this point'
|
||||
});
|
||||
});
|
||||
|
||||
$('#locate').click(function() {
|
||||
geolocation.setTracking(true);
|
||||
});
|
||||
@@ -3,11 +3,15 @@ goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.MapQuestOpenAerial');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.BingMaps');
|
||||
|
||||
|
||||
var layer = new ol.layer.TileLayer({
|
||||
source: new ol.source.MapQuestOpenAerial()
|
||||
source: new ol.source.BingMaps({
|
||||
key: 'AgtFlPYDnymLEe9zJ5PCkghbNiFZE9aAtTy3mPaEnEBXqLHtFuTcKoZ-miMC3w7R',
|
||||
style: 'Aerial'
|
||||
})
|
||||
});
|
||||
|
||||
var map = new ol.Map({
|
||||
@@ -15,8 +19,9 @@ var map = new ol.Map({
|
||||
renderer: ol.RendererHint.WEBGL,
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: new ol.Coordinate(0, 0),
|
||||
zoom: 2
|
||||
center: ol.projection.transform(
|
||||
new ol.Coordinate(-9.375, 51.483333), 'EPSG:4326', 'EPSG:3857'),
|
||||
zoom: 15
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
4
examples/jquery.min.js
vendored
Normal file
4
examples/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
52
examples/rotation.html
Normal file
52
examples/rotation.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!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="bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="examples.css" type="text/css">
|
||||
<link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>Rotation example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="example-list.html">OpenLayers 3 Examples</a>
|
||||
<ul class="nav pull-right">
|
||||
<li><a href="https://github.com/openlayers/ol3"><i class="icon-github"></i></a></li>
|
||||
<li><a href="https://twitter.com/openlayers"><i class="icon-twitter"></i></a></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">Rotation example</h4>
|
||||
<p id="shortdesc">Example of a rotated map. Use <code>Alt</code>+<code>Shift</code>+drag to rotate the map.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="rotation.js" target="_blank">rotation.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">rotation, openstreetmap</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="loader.js?id=rotation" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
22
examples/rotation.js
Normal file
22
examples/rotation.js
Normal file
@@ -0,0 +1,22 @@
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.OpenStreetMap');
|
||||
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.OpenStreetMap()
|
||||
})
|
||||
],
|
||||
renderers: ol.RendererHints.createFromQueryData(),
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: new ol.Coordinate(-25860000, 4130000),
|
||||
rotation: Math.PI / 6,
|
||||
zoom: 10
|
||||
})
|
||||
});
|
||||
52
examples/semi-transparent-layer.html
Normal file
52
examples/semi-transparent-layer.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!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="bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="examples.css" type="text/css">
|
||||
<link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>Semi-transparent layer example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="example-list.html">OpenLayers 3 Examples</a>
|
||||
<ul class="nav pull-right">
|
||||
<li><a href="https://github.com/openlayers/ol3"><i class="icon-github"></i></a></li>
|
||||
<li><a href="https://twitter.com/openlayers"><i class="icon-twitter"></i></a></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">Semi-transparent layer example</h4>
|
||||
<p id="shortdesc">Example of a map with a semi-transparent layer.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="semi-transparent-layer.js" target="_blank">semi-transparent-layer.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">transparent, mapquest, tilejson</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="loader.js?id=semi-transparent-layer" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
29
examples/semi-transparent-layer.js
Normal file
29
examples/semi-transparent-layer.js
Normal file
@@ -0,0 +1,29 @@
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.MapQuestOpenAerial');
|
||||
goog.require('ol.source.TileJSON');
|
||||
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.MapQuestOpenAerial()
|
||||
}),
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.TileJSON({
|
||||
uri: 'http://api.tiles.mapbox.com/v3/mapbox.va-quake-aug.jsonp'
|
||||
})
|
||||
})
|
||||
],
|
||||
renderers: ol.RendererHints.createFromQueryData(),
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: ol.projection.transform(
|
||||
new ol.Coordinate(-77.93255, 37.9555), 'EPSG:4326', 'EPSG:3857'),
|
||||
zoom: 5
|
||||
})
|
||||
});
|
||||
21
externs/bootstrap.js
vendored
Normal file
21
externs/bootstrap.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @fileoverview Externs for bootstrap.js
|
||||
*
|
||||
* @see http://twitter.github.com/bootstrap/javascript.html
|
||||
* @externs
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {String|Object.<string,*>=} option
|
||||
* @return {!jQuery}
|
||||
*/
|
||||
jQuery.prototype.popover = function(option) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {String|Object.<string,*>=} option
|
||||
* @return {!jQuery}
|
||||
*/
|
||||
jQuery.prototype.tooltip = function(option) {};
|
||||
@@ -74,13 +74,18 @@
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.doubleClickZoom boolean|undefined
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.dragPan boolean|undefined
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.keyboard boolean|undefined
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.keyboardPanOffset number|undefined
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.mouseWheelZoom boolean|undefined
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.shiftDragZoom boolean|undefined
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.touchPan boolean|undefined
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.touchRotate boolean|undefined
|
||||
@exportObjectLiteralProperty ol.interaction.DefaultOptions.touchZoom boolean|undefined
|
||||
|
||||
@exportObjectLiteral ol.interaction.KeyboardPanOptions
|
||||
@exportObjectLiteralProperty ol.interaction.KeyboardPanOptions.pixelDelta number|undefined
|
||||
|
||||
@exportObjectLiteral ol.interaction.KeyboardZoomOptions
|
||||
@exportObjectLiteralProperty ol.interaction.KeyboardZoomOptions.delta number|undefined
|
||||
|
||||
@exportObjectLiteral ol.layer.LayerOptions
|
||||
@exportObjectLiteralProperty ol.layer.LayerOptions.brightness number|undefined
|
||||
@exportObjectLiteralProperty ol.layer.LayerOptions.contrast number|undefined
|
||||
@@ -136,6 +141,9 @@
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.url string|undefined
|
||||
|
||||
@exportObjectLiteral ol.source.TileJSONOptions
|
||||
@exportObjectLiteralProperty ol.source.TileJSONOptions.uri string
|
||||
|
||||
@exportObjectLiteral ol.source.TiledWMSOptions
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.attributions Array.<ol.Attribution>|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.params Object
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
goog.provide('ol.animation');
|
||||
|
||||
goog.require('goog.fx.easing');
|
||||
goog.require('ol.PreRenderFunction');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.easing');
|
||||
@@ -48,7 +47,7 @@ ol.animation.pan = function(options) {
|
||||
var sourceY = source.y;
|
||||
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
||||
var easing = goog.isDef(options.easing) ?
|
||||
options.easing : goog.fx.easing.inAndOut;
|
||||
options.easing : ol.easing.inAndOut;
|
||||
return function(map, frameState) {
|
||||
if (frameState.time < start) {
|
||||
frameState.animate = true;
|
||||
@@ -79,7 +78,7 @@ ol.animation.rotate = function(options) {
|
||||
var start = goog.isDef(options.start) ? options.start : goog.now();
|
||||
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
||||
var easing = goog.isDef(options.easing) ?
|
||||
options.easing : goog.fx.easing.inAndOut;
|
||||
options.easing : ol.easing.inAndOut;
|
||||
|
||||
return function(map, frameState) {
|
||||
if (frameState.time < start) {
|
||||
@@ -110,7 +109,7 @@ ol.animation.zoom = function(options) {
|
||||
var start = goog.isDef(options.start) ? options.start : goog.now();
|
||||
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
||||
var easing = goog.isDef(options.easing) ?
|
||||
options.easing : ol.easing.linear;
|
||||
options.easing : ol.easing.inAndOut;
|
||||
return function(map, frameState) {
|
||||
if (frameState.time < start) {
|
||||
frameState.animate = true;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
@exportSymbol ol.easing
|
||||
@exportProperty ol.easing.bounce
|
||||
@exportProperty ol.easing.easeIn
|
||||
@exportProperty ol.easing.easeOut
|
||||
@exportProperty ol.easing.elastic
|
||||
@exportProperty ol.easing.inAndOut
|
||||
@exportProperty ol.easing.linear
|
||||
@exportProperty ol.easing.upAndDown
|
||||
@exportProperty ol.easing.elastic
|
||||
@exportProperty ol.easing.bounce
|
||||
|
||||
@@ -1,36 +1,6 @@
|
||||
goog.provide('ol.easing');
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.linear = function(t) {
|
||||
return t;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.upAndDown = function(t) {
|
||||
if (t < 0.5) {
|
||||
return goog.fx.easing.inAndOut(2 * t);
|
||||
} else {
|
||||
return 1 - goog.fx.easing.inAndOut(2 * (t - 0.5));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* from https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael.js
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.elastic = function(t) {
|
||||
return Math.pow(2, -10 * t) * Math.sin((t - 0.075) * (2 * Math.PI) / 0.3) + 1;
|
||||
};
|
||||
goog.require('goog.fx.easing');
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,3 +28,56 @@ ol.easing.bounce = function(t) {
|
||||
}
|
||||
return l;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.easeIn = goog.fx.easing.easeIn;
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.easeOut = goog.fx.easing.easeOut;
|
||||
|
||||
|
||||
/**
|
||||
* from https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael.js
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.elastic = function(t) {
|
||||
return Math.pow(2, -10 * t) * Math.sin((t - 0.075) * (2 * Math.PI) / 0.3) + 1;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.inAndOut = goog.fx.easing.inAndOut;
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.linear = function(t) {
|
||||
return t;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} t Input between 0 and 1.
|
||||
* @return {number} Output between 0 and 1.
|
||||
*/
|
||||
ol.easing.upAndDown = function(t) {
|
||||
if (t < 0.5) {
|
||||
return ol.easing.inAndOut(2 * t);
|
||||
} else {
|
||||
return 1 - ol.easing.inAndOut(2 * (t - 0.5));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,7 +22,9 @@ ol.GeolocationProperty = {
|
||||
HEADING: 'heading',
|
||||
POSITION: 'position',
|
||||
PROJECTION: 'projection',
|
||||
SPEED: 'speed'
|
||||
SPEED: 'speed',
|
||||
TRACKING: 'tracking',
|
||||
TRACKING_OPTIONS: 'trackingOptions'
|
||||
};
|
||||
|
||||
|
||||
@@ -30,9 +32,8 @@ ol.GeolocationProperty = {
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.Object}
|
||||
* @param {GeolocationPositionOptions=} opt_positionOptions PositionOptions.
|
||||
*/
|
||||
ol.Geolocation = function(opt_positionOptions) {
|
||||
ol.Geolocation = function() {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
@@ -43,20 +44,20 @@ ol.Geolocation = function(opt_positionOptions) {
|
||||
*/
|
||||
this.position_ = null;
|
||||
|
||||
if (ol.Geolocation.SUPPORTED) {
|
||||
goog.events.listen(
|
||||
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
|
||||
this.handleProjectionChanged_, false, this);
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.watchId_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.watchId_ = navigator.geolocation.watchPosition(
|
||||
goog.bind(this.positionChange_, this),
|
||||
goog.bind(this.positionError_, this),
|
||||
opt_positionOptions);
|
||||
}
|
||||
this.setTracking(false);
|
||||
|
||||
goog.events.listen(
|
||||
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
|
||||
this.handleProjectionChanged_, false, this);
|
||||
goog.events.listen(
|
||||
this, ol.Object.getChangedEventType(ol.GeolocationProperty.TRACKING),
|
||||
this.handleTrackingChanged_, false, this);
|
||||
};
|
||||
goog.inherits(ol.Geolocation, ol.Object);
|
||||
|
||||
@@ -65,7 +66,7 @@ goog.inherits(ol.Geolocation, ol.Object);
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.Geolocation.prototype.disposeInternal = function() {
|
||||
navigator.geolocation.clearWatch(this.watchId_);
|
||||
this.setTracking(false);
|
||||
goog.base(this, 'disposeInternal');
|
||||
};
|
||||
|
||||
@@ -88,6 +89,25 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.Geolocation.prototype.handleTrackingChanged_ = function() {
|
||||
if (ol.Geolocation.SUPPORTED) {
|
||||
var tracking = this.getTracking();
|
||||
if (tracking && !goog.isDef(this.watchId_)) {
|
||||
this.watchId_ = navigator.geolocation.watchPosition(
|
||||
goog.bind(this.positionChange_, this),
|
||||
goog.bind(this.positionError_, this),
|
||||
this.getTrackingOptions());
|
||||
} else if (!tracking && goog.isDef(this.watchId_)) {
|
||||
navigator.geolocation.clearWatch(this.watchId_);
|
||||
this.watchId_ = undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {boolean} Is supported.
|
||||
@@ -220,6 +240,32 @@ goog.exportProperty(
|
||||
ol.Geolocation.prototype.getSpeed);
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean|undefined} tracking.
|
||||
*/
|
||||
ol.Geolocation.prototype.getTracking = function() {
|
||||
return /** @type {boolean} */ (
|
||||
this.get(ol.GeolocationProperty.TRACKING));
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Geolocation.prototype,
|
||||
'getTracking',
|
||||
ol.Geolocation.prototype.getTracking);
|
||||
|
||||
|
||||
/**
|
||||
* @return {GeolocationPositionOptions|undefined} tracking options.
|
||||
*/
|
||||
ol.Geolocation.prototype.getTrackingOptions = function() {
|
||||
return /** @type {GeolocationPositionOptions} */ (
|
||||
this.get(ol.GeolocationProperty.TRACKING_OPTIONS));
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Geolocation.prototype,
|
||||
'getTrackingOptions',
|
||||
ol.Geolocation.prototype.getTrackingOptions);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Projection} projection Projection.
|
||||
*/
|
||||
@@ -232,6 +278,30 @@ goog.exportProperty(
|
||||
ol.Geolocation.prototype.setProjection);
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} tracking Enable or disable tracking.
|
||||
*/
|
||||
ol.Geolocation.prototype.setTracking = function(tracking) {
|
||||
this.set(ol.GeolocationProperty.TRACKING, tracking);
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Geolocation.prototype,
|
||||
'setTracking',
|
||||
ol.Geolocation.prototype.setTracking);
|
||||
|
||||
|
||||
/**
|
||||
* @param {GeolocationPositionOptions} options Tracking options.
|
||||
*/
|
||||
ol.Geolocation.prototype.setTrackingOptions = function(options) {
|
||||
this.set(ol.GeolocationProperty.TRACKING_OPTIONS, options);
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Geolocation.prototype,
|
||||
'setTrackingOptions',
|
||||
ol.Geolocation.prototype.setTrackingOptions);
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Array.<number>} input Input coordinate values.
|
||||
|
||||
@@ -13,12 +13,13 @@ goog.require('ol.TileState');
|
||||
* @constructor
|
||||
* @extends {ol.Tile}
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileState} state State.
|
||||
* @param {string} src Image source URI.
|
||||
* @param {?string} crossOrigin Cross origin.
|
||||
*/
|
||||
ol.ImageTile = function(tileCoord, src, crossOrigin) {
|
||||
ol.ImageTile = function(tileCoord, state, src, crossOrigin) {
|
||||
|
||||
goog.base(this, tileCoord);
|
||||
goog.base(this, tileCoord, state);
|
||||
|
||||
/**
|
||||
* Image URI
|
||||
|
||||
@@ -72,10 +72,8 @@ ol.interaction.defaults = function(opt_options, opt_interactions) {
|
||||
|
||||
var keyboard = goog.isDef(options.keyboard) ?
|
||||
options.keyboard : true;
|
||||
var keyboardPanOffset = goog.isDef(options.keyboardPanOffset) ?
|
||||
options.keyboardPanOffset : 80;
|
||||
if (keyboard) {
|
||||
interactions.push(new ol.interaction.KeyboardPan(keyboardPanOffset));
|
||||
interactions.push(new ol.interaction.KeyboardPan());
|
||||
interactions.push(new ol.interaction.KeyboardZoom());
|
||||
}
|
||||
|
||||
|
||||
@@ -9,21 +9,29 @@ goog.require('ol.View2D');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Pan duration.
|
||||
*/
|
||||
ol.interaction.KEYBOARD_PAN_DURATION = 100;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @param {number} pixelDelta Pixel delta.
|
||||
* @param {ol.interaction.KeyboardPanOptions=} opt_options Options.
|
||||
*/
|
||||
ol.interaction.KeyboardPan = function(pixelDelta) {
|
||||
ol.interaction.KeyboardPan = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.pixelDelta_ = pixelDelta;
|
||||
this.delta_ = goog.isDef(options.delta) ? options.delta : 128;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction);
|
||||
@@ -47,22 +55,21 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(view instanceof ol.View2D);
|
||||
var resolution = view.getResolution();
|
||||
var delta;
|
||||
var mapUnitsDelta = resolution * this.pixelDelta_;
|
||||
var rotation = view.getRotation();
|
||||
var mapUnitsDelta = resolution * this.delta_;
|
||||
var deltaX = 0, deltaY = 0;
|
||||
if (keyCode == goog.events.KeyCodes.DOWN) {
|
||||
delta = new ol.Coordinate(0, -mapUnitsDelta);
|
||||
deltaY = -mapUnitsDelta;
|
||||
} else if (keyCode == goog.events.KeyCodes.LEFT) {
|
||||
delta = new ol.Coordinate(-mapUnitsDelta, 0);
|
||||
deltaX = -mapUnitsDelta;
|
||||
} else if (keyCode == goog.events.KeyCodes.RIGHT) {
|
||||
delta = new ol.Coordinate(mapUnitsDelta, 0);
|
||||
deltaX = mapUnitsDelta;
|
||||
} else {
|
||||
goog.asserts.assert(keyCode == goog.events.KeyCodes.UP);
|
||||
delta = new ol.Coordinate(0, mapUnitsDelta);
|
||||
deltaY = mapUnitsDelta;
|
||||
}
|
||||
var oldCenter = view.getCenter();
|
||||
var newCenter = new ol.Coordinate(
|
||||
oldCenter.x + delta.x, oldCenter.y + delta.y);
|
||||
view.setCenter(newCenter);
|
||||
var delta = new ol.Coordinate(deltaX, deltaY);
|
||||
delta.rotate(rotation);
|
||||
view.pan(map, delta, ol.interaction.KEYBOARD_PAN_DURATION);
|
||||
keyEvent.preventDefault();
|
||||
mapBrowserEvent.preventDefault();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,21 @@ ol.interaction.KEYBOARD_ZOOM_DURATION = 100;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {ol.interaction.KeyboardZoomOptions=} opt_options Options.
|
||||
* @extends {ol.interaction.Interaction}
|
||||
*/
|
||||
ol.interaction.KeyboardZoom = function() {
|
||||
ol.interaction.KeyboardZoom = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.delta_ = goog.isDef(options.delta) ? options.delta : 1;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction);
|
||||
|
||||
@@ -35,7 +46,7 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
||||
var charCode = keyEvent.charCode;
|
||||
if (charCode == '+'.charCodeAt(0) || charCode == '-'.charCodeAt(0)) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var delta = (charCode == '+'.charCodeAt(0)) ? 4 : -4;
|
||||
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
||||
map.requestRenderFrame();
|
||||
// FIXME works for View2D only
|
||||
var view = map.getView();
|
||||
|
||||
@@ -242,6 +242,12 @@ ol.Map = function(mapOptions) {
|
||||
goog.events.listen(this.viewportSizeMonitor_, goog.events.EventType.RESIZE,
|
||||
this.handleBrowserWindowResize, false, this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Coordinate}
|
||||
*/
|
||||
this.focus_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.PreRenderFunction>}
|
||||
@@ -487,9 +493,10 @@ ol.Map.prototype.getTilePriority = function(tile, tileSourceKey, tileCenter) {
|
||||
if (!frameState.wantedTiles[tileSourceKey][coordKey]) {
|
||||
return ol.TileQueue.DROP;
|
||||
}
|
||||
var center = frameState.view2DState.center;
|
||||
var deltaX = tileCenter.x - center.x;
|
||||
var deltaY = tileCenter.y - center.y;
|
||||
var focus = goog.isNull(this.focus_) ?
|
||||
frameState.view2DState.center : this.focus_;
|
||||
var deltaX = tileCenter.x - focus.x;
|
||||
var deltaY = tileCenter.y - focus.y;
|
||||
return deltaX * deltaX + deltaY * deltaY;
|
||||
};
|
||||
|
||||
@@ -502,6 +509,11 @@ ol.Map.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
|
||||
var type = opt_type || browserEvent.type;
|
||||
var mapBrowserEvent = new ol.MapBrowserEvent(type, this, browserEvent);
|
||||
this.handleMapBrowserEvent(mapBrowserEvent);
|
||||
if (type == goog.events.EventType.MOUSEOUT) {
|
||||
this.focus_ = null;
|
||||
} else {
|
||||
this.focus_ = mapBrowserEvent.getCoordinate();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -152,10 +152,6 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
|
||||
tileCoord = new ol.TileCoord(z, x, y);
|
||||
tile = tileSource.getTile(tileCoord, tileGrid, projection);
|
||||
if (goog.isNull(tile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.IDLE) {
|
||||
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
|
||||
@@ -163,7 +159,8 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
|
||||
} else if (tileState == ol.TileState.LOADING) {
|
||||
this.listenToTileChange(tile);
|
||||
} else if (tileState == ol.TileState.LOADED) {
|
||||
} else if (tileState == ol.TileState.LOADED ||
|
||||
tileState == ol.TileState.EMPTY) {
|
||||
tilesToDrawByZ[z][tileCoord.toString()] = tile;
|
||||
continue;
|
||||
} else if (tileState == ol.TileState.ERROR) {
|
||||
@@ -198,10 +195,13 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
if (this.renderedTiles_[index] != tile) {
|
||||
x = tileSize.width * (tile.tileCoord.x - tileRange.minX);
|
||||
y = tileSize.height * (tileRange.maxY - tile.tileCoord.y);
|
||||
if (!opaque) {
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.EMPTY || !opaque) {
|
||||
context.clearRect(x, y, tileSize.width, tileSize.height);
|
||||
}
|
||||
context.drawImage(tile.getImage(), x, y);
|
||||
if (tileState == ol.TileState.LOADED) {
|
||||
context.drawImage(tile.getImage(), x, y);
|
||||
}
|
||||
this.renderedTiles_[index] = tile;
|
||||
}
|
||||
}
|
||||
@@ -214,10 +214,13 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
y = (origin.y - tileExtent.maxY) / tileResolution;
|
||||
width = scale * tileSize.width;
|
||||
height = scale * tileSize.height;
|
||||
if (!opaque) {
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.EMPTY || !opaque) {
|
||||
context.clearRect(x, y, width, height);
|
||||
}
|
||||
context.drawImage(tile.getImage(), x, y, width, height);
|
||||
if (tileState == ol.TileState.LOADED) {
|
||||
context.drawImage(tile.getImage(), x, y, width, height);
|
||||
}
|
||||
interimTileRange =
|
||||
tileGrid.getTileRangeForExtentAndZ(tileExtent, z);
|
||||
minX = Math.max(interimTileRange.minX, tileRange.minX);
|
||||
|
||||
@@ -110,10 +110,6 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
|
||||
tileCoord = new ol.TileCoord(z, x, y);
|
||||
tile = tileSource.getTile(tileCoord, tileGrid, projection);
|
||||
if (goog.isNull(tile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.IDLE) {
|
||||
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
|
||||
@@ -124,7 +120,8 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
} else if (tileState == ol.TileState.LOADED) {
|
||||
tilesToDrawByZ[z][tileCoord.toString()] = tile;
|
||||
continue;
|
||||
} else if (tileState == ol.TileState.ERROR) {
|
||||
} else if (tileState == ol.TileState.ERROR ||
|
||||
tileState == ol.TileState.EMPTY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ ol.renderer.webgl.Map = function(container, map) {
|
||||
goog.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.LOST,
|
||||
this.handleWebGLContextLost, false, this);
|
||||
goog.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.RESTORED,
|
||||
this.handleWebGLContextResourced, false, this);
|
||||
this.handleWebGLContextRestored, false, this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -433,9 +433,9 @@ ol.renderer.webgl.Map.prototype.handleWebGLContextLost = function(event) {
|
||||
/**
|
||||
* @protected
|
||||
*/
|
||||
ol.renderer.webgl.Map.prototype.handleWebGLContextResourced = function() {
|
||||
ol.renderer.webgl.Map.prototype.handleWebGLContextRestored = function() {
|
||||
if (goog.DEBUG) {
|
||||
this.logger.info('WebGLContextResourced');
|
||||
this.logger.info('WebGLContextRestored');
|
||||
}
|
||||
this.initializeGL_();
|
||||
this.getMap().render();
|
||||
|
||||
@@ -385,10 +385,6 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
|
||||
tileCoord = new ol.TileCoord(z, x, y);
|
||||
tile = tileSource.getTile(tileCoord, tileGrid, projection);
|
||||
if (goog.isNull(tile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.IDLE) {
|
||||
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
|
||||
@@ -407,7 +403,8 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
priority = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||
tilesToLoad.enqueue(priority, tile);
|
||||
}
|
||||
} else if (tileState == ol.TileState.ERROR) {
|
||||
} else if (tileState == ol.TileState.ERROR ||
|
||||
tileState == ol.TileState.EMPTY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportSymbol ol.source.BingMaps
|
||||
@exportClass ol.source.BingMaps ol.source.BingMapsOptions
|
||||
|
||||
@@ -19,9 +19,7 @@ goog.require('ol.tilegrid.TileGrid');
|
||||
*/
|
||||
ol.DebugTile_ = function(tileCoord, tileGrid) {
|
||||
|
||||
goog.base(this, tileCoord);
|
||||
|
||||
this.state = ol.TileState.LOADED;
|
||||
goog.base(this, tileCoord, ol.TileState.LOADED);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -127,7 +125,7 @@ ol.source.DebugTileSource.prototype.expireCache = function(usedTiles) {
|
||||
ol.source.DebugTileSource.prototype.getTile = function(tileCoord) {
|
||||
var key = tileCoord.toString();
|
||||
if (this.tileCache_.containsKey(key)) {
|
||||
return /** @type {ol.DebugTile_} */ (this.tileCache_.get(key));
|
||||
return /** @type {!ol.DebugTile_} */ (this.tileCache_.get(key));
|
||||
} else {
|
||||
var tile = new ol.DebugTile_(tileCoord, this.tileGrid);
|
||||
this.tileCache_.set(key, tile);
|
||||
|
||||
@@ -7,6 +7,7 @@ goog.require('ol.ImageTile');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCache');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.TileUrlFunctionType');
|
||||
goog.require('ol.source.TileSource');
|
||||
@@ -89,18 +90,17 @@ ol.source.ImageTileSource.prototype.getTile =
|
||||
function(tileCoord, tileGrid, projection) {
|
||||
var key = tileCoord.toString();
|
||||
if (this.tileCache_.containsKey(key)) {
|
||||
return /** @type {ol.Tile} */ (this.tileCache_.get(key));
|
||||
return /** @type {!ol.Tile} */ (this.tileCache_.get(key));
|
||||
} else {
|
||||
goog.asserts.assert(tileGrid);
|
||||
goog.asserts.assert(projection);
|
||||
var tileUrl = this.tileUrlFunction(tileCoord, tileGrid, projection);
|
||||
var tile;
|
||||
if (goog.isDef(tileUrl)) {
|
||||
tile = new ol.ImageTile(tileCoord, tileUrl, this.crossOrigin_);
|
||||
this.tileCache_.set(key, tile);
|
||||
} else {
|
||||
tile = null;
|
||||
}
|
||||
var tile = new ol.ImageTile(
|
||||
tileCoord,
|
||||
goog.isDef(tileUrl) ? ol.TileState.IDLE : ol.TileState.EMPTY,
|
||||
goog.isDef(tileUrl) ? tileUrl : '',
|
||||
this.crossOrigin_);
|
||||
this.tileCache_.set(key, tile);
|
||||
return tile;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportSymbol ol.source.SingleImageWMS
|
||||
@exportClass ol.source.SingleImageWMS ol.source.SingleImageWMSOptions
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportSymbol ol.source.Stamen
|
||||
@exportClass ol.source.Stamen ol.source.StamenOptions
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportSymbol ol.source.StaticImage
|
||||
@exportClass ol.source.StaticImage ol.source.StaticImageOptions
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportSymbol ol.source.TiledWMS
|
||||
@exportClass ol.source.TiledWMS ol.source.TiledWMSOptions
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportSymbol ol.source.TileJSON
|
||||
@exportClass ol.source.TileJSON ol.source.TileJSONOptions
|
||||
|
||||
@@ -21,12 +21,6 @@ goog.require('ol.source.ImageTileSource');
|
||||
goog.require('ol.tilegrid.XYZ');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{uri: string}}
|
||||
*/
|
||||
ol.source.TileJSONOptions;
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<TileJSON>}
|
||||
|
||||
@@ -125,7 +125,7 @@ ol.source.TileSource.prototype.getResolutions = function() {
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.tilegrid.TileGrid=} opt_tileGrid Tile grid.
|
||||
* @param {ol.Projection=} opt_projection Projection.
|
||||
* @return {ol.Tile} Tile.
|
||||
* @return {!ol.Tile} Tile.
|
||||
*/
|
||||
ol.source.TileSource.prototype.getTile = goog.abstractMethod;
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ ol.TileState = {
|
||||
IDLE: 0,
|
||||
LOADING: 1,
|
||||
LOADED: 2,
|
||||
ERROR: 3
|
||||
ERROR: 3,
|
||||
EMPTY: 4
|
||||
};
|
||||
|
||||
|
||||
@@ -25,8 +26,9 @@ ol.TileState = {
|
||||
* @constructor
|
||||
* @extends {goog.events.EventTarget}
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileState} state State.
|
||||
*/
|
||||
ol.Tile = function(tileCoord) {
|
||||
ol.Tile = function(tileCoord, state) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
@@ -39,7 +41,7 @@ ol.Tile = function(tileCoord) {
|
||||
* @protected
|
||||
* @type {ol.TileState}
|
||||
*/
|
||||
this.state = ol.TileState.IDLE;
|
||||
this.state = state;
|
||||
|
||||
};
|
||||
goog.inherits(ol.Tile, goog.events.EventTarget);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
goog.provide('ol.View2D');
|
||||
goog.provide('ol.View2DProperty');
|
||||
|
||||
goog.require('goog.fx.easing');
|
||||
goog.require('ol.Constraints');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
@@ -16,6 +15,7 @@ goog.require('ol.RotationConstraint');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.animation');
|
||||
goog.require('ol.easing');
|
||||
goog.require('ol.projection');
|
||||
|
||||
|
||||
@@ -255,6 +255,28 @@ goog.exportProperty(
|
||||
ol.View2D.prototype.setRotation);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {ol.Coordinate} delta Delta.
|
||||
* @param {number=} opt_duration Duration.
|
||||
*/
|
||||
ol.View2D.prototype.pan = function(map, delta, opt_duration) {
|
||||
var currentCenter = this.getCenter();
|
||||
if (goog.isDef(currentCenter)) {
|
||||
if (goog.isDef(opt_duration)) {
|
||||
map.requestRenderFrame();
|
||||
map.addPreRenderFunction(ol.animation.pan({
|
||||
source: currentCenter,
|
||||
duration: opt_duration,
|
||||
easing: ol.easing.linear
|
||||
}));
|
||||
}
|
||||
this.setCenter(new ol.Coordinate(
|
||||
currentCenter.x + delta.x, currentCenter.y + delta.y));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {number|undefined} rotation Rotation.
|
||||
@@ -285,13 +307,13 @@ ol.View2D.prototype.rotateWithoutConstraints =
|
||||
map.addPreRenderFunction(ol.animation.rotate({
|
||||
rotation: currentRotation,
|
||||
duration: opt_duration,
|
||||
easing: goog.fx.easing.easeOut
|
||||
easing: ol.easing.easeOut
|
||||
}));
|
||||
if (goog.isDef(opt_anchor)) {
|
||||
map.addPreRenderFunction(ol.animation.pan({
|
||||
source: currentCenter,
|
||||
duration: opt_duration,
|
||||
easing: goog.fx.easing.easeOut
|
||||
easing: ol.easing.easeOut
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -359,13 +381,13 @@ ol.View2D.prototype.zoomWithoutConstraints =
|
||||
map.addPreRenderFunction(ol.animation.zoom({
|
||||
resolution: currentResolution,
|
||||
duration: opt_duration,
|
||||
easing: goog.fx.easing.easeOut
|
||||
easing: ol.easing.easeOut
|
||||
}));
|
||||
if (goog.isDef(opt_anchor)) {
|
||||
map.addPreRenderFunction(ol.animation.pan({
|
||||
source: currentCenter,
|
||||
duration: opt_duration,
|
||||
easing: goog.fx.easing.easeOut
|
||||
easing: ol.easing.easeOut
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,11 @@ With PhantomJS installed, and assuming phantomjs is in the PATH:
|
||||
|
||||
(Works with PhantomJS 1.6.1, untested with other versions.)
|
||||
|
||||
This command can also be run by doing `make test` at the root of ol3.
|
||||
This command can also be run by doing `./build.py test` at the root of ol3.
|
||||
|
||||
Make sure that the polvr web server is running (`./build.py serve`), otherwise
|
||||
you will most likely see something like `0 specs, 0 failures in 0.001s.`.
|
||||
|
||||
Tip for TDD'ers: to make PhantomJS run the test suite continuously each time
|
||||
a spec file is changed you can use nosier (http://pypi.python.org/pypi/nosier)
|
||||
and do `nosier -p test -p src "make test"`.
|
||||
and do `nosier -p test -p src "./build.py test"`.
|
||||
@@ -220,12 +220,9 @@ goog.inherits(ol.test.source.MockTileSource, ol.source.TileSource);
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.test.source.MockTileSource.prototype.getTile = function(tileCoord) {
|
||||
var tile = new ol.Tile(tileCoord);
|
||||
var key = tileCoord.toString();
|
||||
if (this.loaded_[key]) {
|
||||
tile.state = ol.TileState.LOADED;
|
||||
}
|
||||
return tile;
|
||||
var tileState = this.loaded_[key] ? ol.TileState.LOADED : ol.TileState.IDLE;
|
||||
return new ol.Tile(tileCoord, tileState);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user