Merge branch 'master' of github.com:openlayers/ol3 into vector

This commit is contained in:
ahocevar
2013-02-13 12:30:16 +01:00
30 changed files with 436 additions and 198 deletions
+2
View File
@@ -9,6 +9,8 @@
/build/ol.js /build/ol.js
/build/ol-all.js /build/ol-all.js
/build/src /build/src
/build/phantomjs-*-windows
/build/phantomjs-*-windows.zip
/examples/*.json /examples/*.json
/examples/*.combined.js /examples/*.combined.js
/examples/example-list.js /examples/example-list.js
Executable
+2
View File
@@ -0,0 +1,2 @@
@echo off
%SystemDrive%\Python27\python.exe build.py %*
+54 -14
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
from cStringIO import StringIO from cStringIO import StringIO
import glob
import gzip import gzip
import json import json
import os import os
import os.path
import re import re
import shutil import shutil
import sys import sys
@@ -13,19 +13,23 @@ from pake import Target, ifind, main, output, rule, target, variables, virtual
if sys.platform == 'win32': if sys.platform == 'win32':
variables.GIT = 'C:/Program Files/Git/bin/git.exe' ProgramFiles = os.environ.get('ProgramFiles', 'C:\\Program Files')
variables.GJSLINT = 'gjslint' # FIXME ProgramFiles_X86 = os.environ.get('ProgramFiles(X86)', 'C:\\Program Files')
variables.JAVA = 'C:/Program Files/Java/jre7/bin/java.exe' Python27 = os.environ.get('SystemDrive', 'C:') + '\\Python27'
variables.GIT = os.path.join(ProgramFiles_X86, 'Git', 'bin', 'git.exe')
variables.GJSLINT = os.path.join(Python27, 'Scripts', 'gjslint.exe')
variables.JAVA = os.path.join(ProgramFiles, 'Java', 'jre7', 'bin', 'java.exe')
variables.JSDOC = 'jsdoc' # FIXME variables.JSDOC = 'jsdoc' # FIXME
variables.PHANTOMJS = 'phantomjs' # FIXME variables.PYTHON = os.path.join(Python27, 'python.exe')
variables.PYTHON = 'C:/Python27/python.exe' PHANTOMJS_WINDOWS_ZIP = 'build/phantomjs-1.8.1-windows.zip'
PHANTOMJS = 'build/phantomjs-1.8.1-windows/phantomjs.exe'
else: else:
variables.GIT = 'git' variables.GIT = 'git'
variables.GJSLINT = 'gjslint' variables.GJSLINT = 'gjslint'
variables.JAVA = 'java' variables.JAVA = 'java'
variables.JSDOC = 'jsdoc' variables.JSDOC = 'jsdoc'
variables.PHANTOMJS = 'phantomjs'
variables.PYTHON = 'python' variables.PYTHON = 'python'
PHANTOMJS = 'phantomjs'
variables.BRANCH = output('%(GIT)s', 'rev-parse', '--abbrev-ref', 'HEAD').strip() variables.BRANCH = output('%(GIT)s', 'rev-parse', '--abbrev-ref', 'HEAD').strip()
@@ -40,9 +44,14 @@ EXTERNAL_SRC = [
'build/src/external/src/types.js'] 'build/src/external/src/types.js']
EXAMPLES = [path EXAMPLES = [path
for path in glob.glob('examples/*.html') for path in ifind('examples')
if not path.startswith('examples/standalone/')
if path.endswith('.html')
if path != 'examples/example-list.html'] if path != 'examples/example-list.html']
EXAMPLES_JSON = [example.replace('.html', '.json')
for example in EXAMPLES]
EXAMPLES_SRC = [path EXAMPLES_SRC = [path
for path in ifind('examples') for path in ifind('examples')
if path.endswith('.js') if path.endswith('.js')
@@ -76,7 +85,7 @@ def report_sizes(t):
t.info(' compressed: %d bytes', len(stringio.getvalue())) t.info(' compressed: %d bytes', len(stringio.getvalue()))
virtual('all', 'build-all', 'build', 'examples') virtual('all', 'build-all', 'build', 'examples', 'precommit')
virtual('precommit', 'lint', 'build-all', 'test', 'build', 'build-examples', 'doc') virtual('precommit', 'lint', 'build-all', 'test', 'build', 'build-examples', 'doc')
@@ -152,7 +161,12 @@ def build_src_internal_types_js(t):
virtual('build-examples', 'examples', (path.replace('.html', '.combined.js') for path in EXAMPLES)) virtual('build-examples', 'examples', (path.replace('.html', '.combined.js') for path in EXAMPLES))
virtual('examples', 'examples/example-list.js', (path.replace('.html', '.json') for path in EXAMPLES)) virtual('examples', 'examples/example-list.xml', (path.replace('.html', '.json') for path in EXAMPLES))
@target('examples/example-list.xml', 'examples/example-list.js')
def examples_examples_list_xml(t):
t.touch() # already generated by bin/exampleparser.py
@target('examples/example-list.js', 'bin/exampleparser.py', EXAMPLES) @target('examples/example-list.js', 'bin/exampleparser.py', EXAMPLES)
@@ -188,12 +202,12 @@ def examples_star_combined_js(name, match):
@target('serve', PLOVR_JAR, INTERNAL_SRC, 'test/requireall.js', 'examples') @target('serve', PLOVR_JAR, INTERNAL_SRC, 'test/requireall.js', 'examples')
def serve(t): def serve(t):
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', glob.glob('build/*.json'), glob.glob('examples/*.json'), glob.glob('test/*.json')) 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-precommit', PLOVR_JAR, INTERNAL_SRC)
def serve_precommit(t): def serve_precommit(t):
t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', 'build/ol-all.json') t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', 'build/ol-all.json', 'test/test.json')
virtual('lint', 'build/lint-src-timestamp', 'build/lint-spec-timestamp', 'build/check-requires-timestamp') virtual('lint', 'build/lint-src-timestamp', 'build/lint-spec-timestamp', 'build/check-requires-timestamp')
@@ -321,9 +335,23 @@ def hostexamples(t):
t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/') t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/')
@target('test', INTERNAL_SRC, 'test/requireall.js', phony=True) @target('test', PHANTOMJS, INTERNAL_SRC, 'test/requireall.js', phony=True)
def test(t): def test(t):
t.run('%(PHANTOMJS)s', 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html') t.run(PHANTOMJS, 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html')
if sys.platform == 'win32':
@target(PHANTOMJS, PHANTOMJS_WINDOWS_ZIP, clean=False)
def phantom_js(t):
from zipfile import ZipFile
ZipFile(PHANTOMJS_WINDOWS_ZIP).extractall('build')
@target(PHANTOMJS_WINDOWS_ZIP, clean=False)
def phantomjs_windows_zip(t):
t.download('http://phantomjs.googlecode.com/files/' + os.path.basename(t.name))
else:
virtual(PHANTOMJS)
@target('fixme', phony=True) @target('fixme', phony=True)
@@ -348,5 +376,17 @@ def find_fixme(t):
print print
print "A total number of", totalcount, "TODO/FIXME was found" print "A total number of", totalcount, "TODO/FIXME was found"
@target('reallyclean')
def reallyclean(t):
"""Removes untracked files and folders from previous builds."""
# -X => only clean up files that are usually ignored e.g.
# through .gitignore
# -d => also consider directories for deletion
# -f => if git configuration variable clean.requireForce != false,
# git clean will refuse to run unless given -f or -n.
t.run('%(GIT)s', 'clean', '-X', '-d', '-f', '.')
if __name__ == '__main__': if __name__ == '__main__':
main() main()
+7
View File
@@ -21,6 +21,12 @@
padding: 0 0.5em 0.5em 0.5em; padding: 0 0.5em 0.5em 0.5em;
border-radius: 4px; border-radius: 4px;
} }
#geolocation {
background-color: white;
border: 1px solid #222;
border-radius: 10px 10px 10px 0;
padding: 3px;
}
@media only screen and (max-width: 600px) { @media only screen and (max-width: 600px) {
#text { #text {
display: none; display: none;
@@ -31,6 +37,7 @@
</head> </head>
<body> <body>
<div id="map"> <div id="map">
<div id="geolocation" style="display: none">you are here</div>
<div id="text"> <div id="text">
<h1 id="title">Full-screen example</h1> <h1 id="title">Full-screen example</h1>
<div id="shortdesc">Example of a full-screen map.</div> <div id="shortdesc">Example of a full-screen map.</div>
+14
View File
@@ -1,8 +1,11 @@
goog.require('goog.debug.Console'); goog.require('goog.debug.Console');
goog.require('goog.debug.Logger'); goog.require('goog.debug.Logger');
goog.require('goog.debug.Logger.Level'); goog.require('goog.debug.Logger.Level');
goog.require('goog.style');
goog.require('ol.AnchoredElement');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.Geolocation');
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
@@ -28,3 +31,14 @@ var map = new ol.Map({
zoom: 0 zoom: 0
}) })
}); });
var geolocation = new ol.Geolocation();
geolocation.bindTo('projection', map.getView());
var element = document.getElementById('geolocation');
var marker = new ol.AnchoredElement({
map: map,
element: element
});
marker.bindTo('position', geolocation);
goog.style.showElement(element, true);
+38 -35
View File
@@ -42,12 +42,13 @@ var domMap = new ol.Map({
view: view view: view
}); });
domMap.getControls().push(new ol.control.MousePosition({ var domMousePosition = new ol.control.MousePosition({
coordinateFormat: ol.Coordinate.toStringHDMS, coordinateFormat: ol.Coordinate.toStringHDMS,
projection: ol.Projection.getFromCode('EPSG:4326'), projection: ol.Projection.getFromCode('EPSG:4326'),
target: document.getElementById('domMousePosition'), target: document.getElementById('domMousePosition'),
undefinedHTML: '&nbsp;' undefinedHTML: '&nbsp;'
})); });
domMousePosition.setMap(domMap);
var webglMap = new ol.Map({ var webglMap = new ol.Map({
renderer: ol.RendererHint.WEBGL, renderer: ol.RendererHint.WEBGL,
@@ -58,12 +59,13 @@ if (webglMap !== null) {
webglMap.bindTo('view', domMap); webglMap.bindTo('view', domMap);
} }
webglMap.getControls().push(new ol.control.MousePosition({ var webglMousePosition = new ol.control.MousePosition({
coordinateFormat: ol.Coordinate.toStringHDMS, coordinateFormat: ol.Coordinate.toStringHDMS,
projection: ol.Projection.getFromCode('EPSG:4326'), projection: ol.Projection.getFromCode('EPSG:4326'),
target: document.getElementById('webglMousePosition'), target: document.getElementById('webglMousePosition'),
undefinedHTML: '&nbsp;' undefinedHTML: '&nbsp;'
})); });
webglMousePosition.setMap(webglMap);
var canvasMap = new ol.Map({ var canvasMap = new ol.Map({
renderer: ol.RendererHint.CANVAS, renderer: ol.RendererHint.CANVAS,
@@ -74,12 +76,13 @@ if (canvasMap !== null) {
canvasMap.bindTo('view', domMap); canvasMap.bindTo('view', domMap);
} }
canvasMap.getControls().push(new ol.control.MousePosition({ var canvasMousePosition = new ol.control.MousePosition({
coordinateFormat: ol.Coordinate.toStringHDMS, coordinateFormat: ol.Coordinate.toStringHDMS,
projection: ol.Projection.getFromCode('EPSG:4326'), projection: ol.Projection.getFromCode('EPSG:4326'),
target: document.getElementById('canvasMousePosition'), target: document.getElementById('canvasMousePosition'),
undefinedHtml: '&nbsp;' undefinedHtml: '&nbsp;'
})); });
canvasMousePosition.setMap(canvasMap);
var keyboardInteraction = new ol.interaction.Keyboard(); var keyboardInteraction = new ol.interaction.Keyboard();
keyboardInteraction.addCallback('0', function() { keyboardInteraction.addCallback('0', function() {
@@ -110,7 +113,7 @@ keyboardInteraction.addCallback('H', function() {
layer.setHue(layer.getHue() + (Math.PI / 5)); layer.setHue(layer.getHue() + (Math.PI / 5));
}); });
keyboardInteraction.addCallback('j', function() { keyboardInteraction.addCallback('j', function() {
var bounce = ol.animation.createBounce({ var bounce = ol.animation.bounce({
resolution: 2 * view.getResolution() resolution: 2 * view.getResolution()
}); });
domMap.addPreRenderFunction(bounce); domMap.addPreRenderFunction(bounce);
@@ -118,69 +121,69 @@ keyboardInteraction.addCallback('j', function() {
canvasMap.addPreRenderFunction(bounce); canvasMap.addPreRenderFunction(bounce);
}); });
keyboardInteraction.addCallback('l', function() { keyboardInteraction.addCallback('l', function() {
var panFrom = ol.animation.createPanFrom({ var pan = ol.animation.pan({
source: view.getCenter(), source: view.getCenter(),
easing: ol.easing.elastic easing: ol.easing.elastic
}); });
domMap.addPreRenderFunction(panFrom); domMap.addPreRenderFunction(pan);
webglMap.addPreRenderFunction(panFrom); webglMap.addPreRenderFunction(pan);
canvasMap.addPreRenderFunction(panFrom); canvasMap.addPreRenderFunction(pan);
view.setCenter(LONDON); view.setCenter(LONDON);
}); });
keyboardInteraction.addCallback('L', function() { keyboardInteraction.addCallback('L', function() {
var start = goog.now(); var start = goog.now();
var duration = 5000; var duration = 5000;
var bounce = ol.animation.createBounce({ var bounce = ol.animation.bounce({
resolution: 2 * view.getResolution(), resolution: 2 * view.getResolution(),
start: start, start: start,
duration: duration duration: duration
}); });
var panFrom = ol.animation.createPanFrom({ var pan = ol.animation.pan({
source: view.getCenter(), source: view.getCenter(),
start: start, start: start,
duration: duration duration: duration
}); });
var spin = ol.animation.createSpin({ var rotate = ol.animation.rotate({
turns: 2, rotation: 4 * Math.PI,
start: start, start: start,
duration: duration duration: duration
}); });
var preRenderFunctions = [bounce, panFrom, spin]; var preRenderFunctions = [bounce, pan, rotate];
domMap.addPreRenderFunctions(preRenderFunctions); domMap.addPreRenderFunctions(preRenderFunctions);
webglMap.addPreRenderFunctions(preRenderFunctions); webglMap.addPreRenderFunctions(preRenderFunctions);
canvasMap.addPreRenderFunctions(preRenderFunctions); canvasMap.addPreRenderFunctions(preRenderFunctions);
view.setCenter(LONDON); view.setCenter(LONDON);
}); });
keyboardInteraction.addCallback('m', function() { keyboardInteraction.addCallback('m', function() {
var panFrom = ol.animation.createPanFrom({ var pan = ol.animation.pan({
source: view.getCenter(), source: view.getCenter(),
duration: 1000, duration: 1000,
easing: ol.easing.bounce easing: ol.easing.bounce
}); });
domMap.addPreRenderFunction(panFrom); domMap.addPreRenderFunction(pan);
webglMap.addPreRenderFunction(panFrom); webglMap.addPreRenderFunction(pan);
canvasMap.addPreRenderFunction(panFrom); canvasMap.addPreRenderFunction(pan);
view.setCenter(MOSCOW); view.setCenter(MOSCOW);
}); });
keyboardInteraction.addCallback('M', function() { keyboardInteraction.addCallback('M', function() {
var start = goog.now(); var start = goog.now();
var duration = 5000; var duration = 5000;
var bounce = ol.animation.createBounce({ var bounce = ol.animation.bounce({
resolution: 2 * view.getResolution(), resolution: 2 * view.getResolution(),
start: start, start: start,
duration: duration duration: duration
}); });
var panFrom = ol.animation.createPanFrom({ var pan = ol.animation.pan({
source: view.getCenter(), source: view.getCenter(),
start: start, start: start,
duration: duration duration: duration
}); });
var spin = ol.animation.createSpin({ var rotate = ol.animation.rotate({
turns: -2, rotation: -4 * Math.PI,
start: start, start: start,
duration: duration duration: duration
}); });
var preRenderFunctions = [bounce, panFrom, spin]; var preRenderFunctions = [bounce, pan, rotate];
domMap.addPreRenderFunctions(preRenderFunctions); domMap.addPreRenderFunctions(preRenderFunctions);
webglMap.addPreRenderFunctions(preRenderFunctions); webglMap.addPreRenderFunctions(preRenderFunctions);
canvasMap.addPreRenderFunctions(preRenderFunctions); canvasMap.addPreRenderFunctions(preRenderFunctions);
@@ -206,21 +209,21 @@ keyboardInteraction.addCallback('vV', function() {
layer.setVisible(!layer.getVisible()); layer.setVisible(!layer.getVisible());
}); });
keyboardInteraction.addCallback('x', function() { keyboardInteraction.addCallback('x', function() {
var spin = ol.animation.createSpin({ var rotate = ol.animation.rotate({
turns: 2, rotation: 4 * Math.PI,
duration: 2000 duration: 2000
}); });
domMap.addPreRenderFunction(spin); domMap.addPreRenderFunction(rotate);
webglMap.addPreRenderFunction(spin); webglMap.addPreRenderFunction(rotate);
canvasMap.addPreRenderFunction(spin); canvasMap.addPreRenderFunction(rotate);
}); });
keyboardInteraction.addCallback('X', function() { keyboardInteraction.addCallback('X', function() {
var spin = ol.animation.createSpin({ var rotate = ol.animation.rotate({
turns: -2, rotation: -4 * Math.PI,
duration: 2000 duration: 2000
}); });
domMap.addPreRenderFunction(spin); domMap.addPreRenderFunction(rotate);
webglMap.addPreRenderFunction(spin); webglMap.addPreRenderFunction(rotate);
canvasMap.addPreRenderFunction(spin); canvasMap.addPreRenderFunction(rotate);
}); });
domMap.getInteractions().push(keyboardInteraction); domMap.getInteractions().push(keyboardInteraction);
+4 -1
View File
@@ -288,7 +288,10 @@ def ifind(*paths):
for path in paths: for path in paths:
for dirpath, dirnames, names in os.walk(path): for dirpath, dirnames, names in os.walk(path):
for name in names: for name in names:
yield os.path.join(dirpath, name) if sys.platform == 'win32':
yield '/'.join(dirpath.split('\\') + [name])
else:
yield os.path.join(dirpath, name)
def main(argv=sys.argv): def main(argv=sys.argv):
+4
View File
@@ -13,12 +13,16 @@ Run build.py:
$ ./build.py $ ./build.py
Windows users should run `build` instead.
## Run examples locally ## Run examples locally
Run the [Plovr](http://plovr.com/) web server with: Run the [Plovr](http://plovr.com/) web server with:
$ ./build.py serve $ ./build.py serve
Windows users should run `build serve` instead.
Then, either open one of the example html files from the `examples` directory directly in your browser, or start a simple webserver, for example: Then, either open one of the example html files from the `examples` directory directly in your browser, or start a simple webserver, for example:
$ python -mSimpleHTTPServer $ python -mSimpleHTTPServer
+17 -16
View File
@@ -1,5 +1,5 @@
@exportObjectLiteral ol.MapOptions @exportObjectLiteral ol.MapOptions
@exportObjectLiteralProperty ol.MapOptions.controls ol.Collection|undefined @exportObjectLiteralProperty ol.MapOptions.attributionControl boolean|undefined
@exportObjectLiteralProperty ol.MapOptions.doubleClickZoom boolean|undefined @exportObjectLiteralProperty ol.MapOptions.doubleClickZoom boolean|undefined
@exportObjectLiteralProperty ol.MapOptions.dragPan boolean|undefined @exportObjectLiteralProperty ol.MapOptions.dragPan boolean|undefined
@exportObjectLiteralProperty ol.MapOptions.interactions ol.Collection|undefined @exportObjectLiteralProperty ol.MapOptions.interactions ol.Collection|undefined
@@ -13,6 +13,7 @@
@exportObjectLiteralProperty ol.MapOptions.shiftDragZoom boolean|undefined @exportObjectLiteralProperty ol.MapOptions.shiftDragZoom boolean|undefined
@exportObjectLiteralProperty ol.MapOptions.target Element|string @exportObjectLiteralProperty ol.MapOptions.target Element|string
@exportObjectLiteralProperty ol.MapOptions.view ol.IView|undefined @exportObjectLiteralProperty ol.MapOptions.view ol.IView|undefined
@exportObjectLiteralProperty ol.MapOptions.zoomControl boolean|undefined
@exportObjectLiteralProperty ol.MapOptions.zoomDelta number|undefined @exportObjectLiteralProperty ol.MapOptions.zoomDelta number|undefined
@exportObjectLiteral ol.View2DOptions @exportObjectLiteral ol.View2DOptions
@@ -32,23 +33,23 @@
@exportObjectLiteralProperty ol.animation.BounceOptions.duration number|undefined @exportObjectLiteralProperty ol.animation.BounceOptions.duration number|undefined
@exportObjectLiteralProperty ol.animation.BounceOptions.easing function(number):number|undefined @exportObjectLiteralProperty ol.animation.BounceOptions.easing function(number):number|undefined
@exportObjectLiteral ol.animation.PanFromOptions @exportObjectLiteral ol.animation.PanOptions
@exportObjectLiteralProperty ol.animation.PanFromOptions.source ol.Coordinate @exportObjectLiteralProperty ol.animation.PanOptions.source ol.Coordinate
@exportObjectLiteralProperty ol.animation.PanFromOptions.start number|undefined @exportObjectLiteralProperty ol.animation.PanOptions.start number|undefined
@exportObjectLiteralProperty ol.animation.PanFromOptions.duration number|undefined @exportObjectLiteralProperty ol.animation.PanOptions.duration number|undefined
@exportObjectLiteralProperty ol.animation.PanFromOptions.easing function(number):number|undefined @exportObjectLiteralProperty ol.animation.PanOptions.easing function(number):number|undefined
@exportObjectLiteral ol.animation.SpinOptions @exportObjectLiteral ol.animation.RotateOptions
@exportObjectLiteralProperty ol.animation.SpinOptions.turns number @exportObjectLiteralProperty ol.animation.RotateOptions.rotation number
@exportObjectLiteralProperty ol.animation.SpinOptions.start number|undefined @exportObjectLiteralProperty ol.animation.RotateOptions.start number|undefined
@exportObjectLiteralProperty ol.animation.SpinOptions.duration number|undefined @exportObjectLiteralProperty ol.animation.RotateOptions.duration number|undefined
@exportObjectLiteralProperty ol.animation.SpinOptions.easing function(number):number|undefined @exportObjectLiteralProperty ol.animation.RotateOptions.easing function(number):number|undefined
@exportObjectLiteral ol.animation.ZoomFromOptions @exportObjectLiteral ol.animation.ZoomOptions
@exportObjectLiteralProperty ol.animation.ZoomFromOptions.resolution number @exportObjectLiteralProperty ol.animation.ZoomOptions.resolution number
@exportObjectLiteralProperty ol.animation.ZoomFromOptions.start number|undefined @exportObjectLiteralProperty ol.animation.ZoomOptions.start number|undefined
@exportObjectLiteralProperty ol.animation.ZoomFromOptions.duration number|undefined @exportObjectLiteralProperty ol.animation.ZoomOptions.duration number|undefined
@exportObjectLiteralProperty ol.animation.ZoomFromOptions.easing function(number):number|undefined @exportObjectLiteralProperty ol.animation.ZoomOptions.easing function(number):number|undefined
@exportObjectLiteral ol.control.AttributionOptions @exportObjectLiteral ol.control.AttributionOptions
@exportObjectLiteralProperty ol.control.AttributionOptions.map ol.Map|undefined @exportObjectLiteralProperty ol.control.AttributionOptions.map ol.Map|undefined
+3 -3
View File
@@ -1,4 +1,4 @@
@exportSymbol ol.animation @exportSymbol ol.animation
@exportProperty ol.animation.createBounce @exportProperty ol.animation.bounce
@exportProperty ol.animation.createPanFrom @exportProperty ol.animation.pan
@exportProperty ol.animation.createSpin @exportProperty ol.animation.rotate
+12 -10
View File
@@ -12,7 +12,7 @@ goog.require('ol.easing');
* @param {ol.animation.BounceOptions} options Options. * @param {ol.animation.BounceOptions} options Options.
* @return {ol.PreRenderFunction} Pre-render function. * @return {ol.PreRenderFunction} Pre-render function.
*/ */
ol.animation.createBounce = function(options) { ol.animation.bounce = function(options) {
var resolution = options.resolution; var resolution = options.resolution;
var start = goog.isDef(options.start) ? options.start : goog.now(); var start = goog.isDef(options.start) ? options.start : goog.now();
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = goog.isDef(options.duration) ? options.duration : 1000;
@@ -38,10 +38,10 @@ ol.animation.createBounce = function(options) {
/** /**
* @param {ol.animation.PanFromOptions} options Options. * @param {ol.animation.PanOptions} options Options.
* @return {ol.PreRenderFunction} Pre-render function. * @return {ol.PreRenderFunction} Pre-render function.
*/ */
ol.animation.createPanFrom = function(options) { ol.animation.pan = function(options) {
var source = options.source; var source = options.source;
var start = goog.isDef(options.start) ? options.start : goog.now(); var start = goog.isDef(options.start) ? options.start : goog.now();
var sourceX = source.x; var sourceX = source.x;
@@ -71,15 +71,15 @@ ol.animation.createPanFrom = function(options) {
/** /**
* @param {ol.animation.SpinOptions} options Options. * @param {ol.animation.RotateOptions} options Options.
* @return {ol.PreRenderFunction} Pre-render function. * @return {ol.PreRenderFunction} Pre-render function.
*/ */
ol.animation.createSpin = function(options) { ol.animation.rotate = function(options) {
var sourceRotation = options.rotation;
var start = goog.isDef(options.start) ? options.start : goog.now(); var start = goog.isDef(options.start) ? options.start : goog.now();
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = goog.isDef(options.duration) ? options.duration : 1000;
var easing = goog.isDef(options.easing) ? var easing = goog.isDef(options.easing) ?
options.easing : goog.fx.easing.inAndOut; options.easing : goog.fx.easing.inAndOut;
var deltaTheta = 2 * options.turns * Math.PI;
return function(map, frameState) { return function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
@@ -87,9 +87,11 @@ ol.animation.createSpin = function(options) {
frameState.viewHints[ol.ViewHint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else if (frameState.time < start + duration) { } else if (frameState.time < start + duration) {
var delta = easing((frameState.time - start) / duration); var delta = 1 - easing((frameState.time - start) / duration);
var deltaRotation =
sourceRotation - frameState.view2DState.rotation;
frameState.animate = true; frameState.animate = true;
frameState.view2DState.rotation += delta * deltaTheta; frameState.view2DState.rotation += delta * deltaRotation;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
return true; return true;
} else { } else {
@@ -100,10 +102,10 @@ ol.animation.createSpin = function(options) {
/** /**
* @param {ol.animation.ZoomFromOptions} options Options. * @param {ol.animation.ZoomOptions} options Options.
* @return {ol.PreRenderFunction} Pre-render function. * @return {ol.PreRenderFunction} Pre-render function.
*/ */
ol.animation.createZoomFrom = function(options) { ol.animation.zoom = function(options) {
var sourceResolution = options.resolution; var sourceResolution = options.resolution;
var start = goog.isDef(options.start) ? options.start : goog.now(); var start = goog.isDef(options.start) ? options.start : goog.now();
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = goog.isDef(options.duration) ? options.duration : 1000;
+1
View File
@@ -1,2 +1,3 @@
@exportClass ol.control.Attribution ol.control.AttributionOptions @exportClass ol.control.Attribution ol.control.AttributionOptions
@exportProperty ol.control.Attribution.prototype.setMap
+1
View File
@@ -1,2 +1,3 @@
@exportClass ol.control.MousePosition ol.control.MousePositionOptions @exportClass ol.control.MousePosition ol.control.MousePositionOptions
@exportProperty ol.control.MousePosition.prototype.setMap
+1 -1
View File
@@ -1,2 +1,2 @@
@exportClass ol.control.Zoom ol.control.ZoomOptions @exportClass ol.control.Zoom ol.control.ZoomOptions
@exportProperty ol.control.Zoom.prototype.setMap
+1 -1
View File
@@ -31,7 +31,7 @@ goog.require('ol.layer.LayerState');
* usedTiles: Object.<string, Object.<string, ol.TileRange>>, * usedTiles: Object.<string, Object.<string, ol.TileRange>>,
* view2DState: ol.View2DState, * view2DState: ol.View2DState,
* viewHints: Array.<number>, * viewHints: Array.<number>,
* wantedTiles: Object.<string, Object.<string, ol.TileRange>>}} * wantedTiles: Object.<string, Object.<string, boolean>>}}
*/ */
ol.FrameState; ol.FrameState;
+1
View File
@@ -0,0 +1 @@
@exportSymbol ol.Geolocation
+168
View File
@@ -0,0 +1,168 @@
// FIXME handle geolocation not supported
// FIXME handle geolocation errors
goog.provide('ol.Geolocation');
goog.provide('ol.GeolocationProperty');
goog.require('goog.functions');
goog.require('ol.Coordinate');
goog.require('ol.Object');
goog.require('ol.Projection');
/**
* @enum {string}
*/
ol.GeolocationProperty = {
ACCURACY: 'accuracy',
POSITION: 'position',
PROJECTION: 'projection'
};
/**
* @constructor
* @extends {ol.Object}
* @param {GeolocationPositionOptions=} opt_positionOptions PositionOptions.
*/
ol.Geolocation = function(opt_positionOptions) {
goog.base(this);
/**
* The unprojected (EPSG:4326) device position.
* @private
* @type {ol.Coordinate}
*/
this.position_ = null;
if (ol.Geolocation.isSupported) {
goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
this.handleProjectionChanged_, false, this);
/**
* @private
* @type {number}
*/
this.watchId_ = navigator.geolocation.watchPosition(
goog.bind(this.positionChange_, this),
goog.bind(this.positionError_, this),
opt_positionOptions);
}
};
goog.inherits(ol.Geolocation, ol.Object);
/**
* @inheritDoc
*/
ol.Geolocation.prototype.disposeInternal = function() {
navigator.geolocation.clearWatch(this.watchId_);
goog.base(this, 'disposeInternal');
};
/**
* @private
*/
ol.Geolocation.prototype.handleProjectionChanged_ = function() {
var projection = this.getProjection();
if (goog.isDefAndNotNull(projection)) {
this.transformCoords_ = ol.Projection.getTransform(
ol.Projection.getFromCode('EPSG:4326'), projection);
if (!goog.isNull(this.position_)) {
this.set(ol.GeolocationProperty.POSITION,
this.transformCoords_(this.position_));
}
}
};
/**
* @type {boolean} Is supported.
*/
ol.Geolocation.isSupported = 'geolocation' in navigator;
/**
* @private
* @param {GeolocationPosition} position position event.
*/
ol.Geolocation.prototype.positionChange_ = function(position) {
var coords = position.coords;
this.position_ = new ol.Coordinate(coords.longitude, coords.latitude);
this.set(ol.GeolocationProperty.POSITION,
this.transformCoords_(this.position_));
this.set(ol.GeolocationProperty.ACCURACY, coords.accuracy);
};
/**
* @private
* @param {GeolocationPositionError} error error object.
*/
ol.Geolocation.prototype.positionError_ = function(error) {
};
/**
* The position of the device.
* @return {ol.Coordinate|undefined} position.
*/
ol.Geolocation.prototype.getPosition = function() {
return /** @type {ol.Coordinate} */ (
this.get(ol.GeolocationProperty.POSITION));
};
goog.exportProperty(
ol.Geolocation.prototype,
'getPosition',
ol.Geolocation.prototype.getPosition);
/**
* The accuracy of the position in meters.
* @return {number|undefined} accuracy.
*/
ol.Geolocation.prototype.getAccuracy = function() {
return /** @type {number} */ (
this.get(ol.GeolocationProperty.ACCURACY));
};
goog.exportProperty(
ol.Geolocation.prototype,
'getAccuracy',
ol.Geolocation.prototype.getAccuracy);
/**
* @return {ol.Projection|undefined} projection.
*/
ol.Geolocation.prototype.getProjection = function() {
return /** @type {ol.Projection} */ (
this.get(ol.GeolocationProperty.PROJECTION));
};
goog.exportProperty(
ol.Geolocation.prototype,
'getProjection',
ol.Geolocation.prototype.getProjection);
/**
* @param {ol.Projection} projection Projection.
*/
ol.Geolocation.prototype.setProjection = function(projection) {
this.set(ol.GeolocationProperty.PROJECTION, projection);
};
goog.exportProperty(
ol.Geolocation.prototype,
'setProjection',
ol.Geolocation.prototype.setProjection);
/**
* @private
* @param {ol.Coordinate} coordinate Coordinate.
* @return {ol.Coordinate} Coordinate.
*/
ol.Geolocation.prototype.transformCoords_ = goog.functions.identity;
+5 -3
View File
@@ -51,7 +51,9 @@ goog.inherits(ol.interaction.DragPan, ol.interaction.Drag);
*/ */
ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) { ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
if (this.kinetic_) { if (this.kinetic_) {
this.kinetic_.update(mapBrowserEvent.browserEvent); this.kinetic_.update(
mapBrowserEvent.browserEvent.clientX,
mapBrowserEvent.browserEvent.clientY);
} }
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
// FIXME works for View2D only // FIXME works for View2D only
@@ -84,7 +86,7 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) {
var distance = this.kinetic_.getDistance(); var distance = this.kinetic_.getDistance();
var angle = this.kinetic_.getAngle(); var angle = this.kinetic_.getAngle();
var center = view.getCenter(); var center = view.getCenter();
this.kineticPreRenderFn_ = this.kinetic_.createPanFrom(center); this.kineticPreRenderFn_ = this.kinetic_.pan(center);
map.addPreRenderFunction(this.kineticPreRenderFn_); map.addPreRenderFunction(this.kineticPreRenderFn_);
var centerpx = map.getPixelFromCoordinate(center); var centerpx = map.getPixelFromCoordinate(center);
@@ -104,7 +106,7 @@ ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
var browserEvent = mapBrowserEvent.browserEvent; var browserEvent = mapBrowserEvent.browserEvent;
if (this.condition_(browserEvent)) { if (this.condition_(browserEvent)) {
if (this.kinetic_) { if (this.kinetic_) {
this.kinetic_.begin(browserEvent); this.kinetic_.begin(browserEvent.clientX, browserEvent.clientY);
} }
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
map.requestRenderFrame(); map.requestRenderFrame();
@@ -79,7 +79,7 @@ ol.interaction.DragRotateAndZoom.prototype.handleDragStart =
browserEvent.offsetX - size.width / 2, browserEvent.offsetX - size.width / 2,
size.height / 2 - browserEvent.offsetY); size.height / 2 - browserEvent.offsetY);
var theta = Math.atan2(delta.y, delta.x); var theta = Math.atan2(delta.y, delta.x);
this.startRotation_ = (view.getRotation() || 0) + theta; this.startRotation_ = view.getRotation() + theta;
this.startRatio_ = resolution / delta.magnitude(); this.startRatio_ = resolution / delta.magnitude();
map.requestRenderFrame(); map.requestRenderFrame();
return true; return true;
+1 -1
View File
@@ -67,7 +67,7 @@ ol.interaction.DragRotate.prototype.handleDragStart =
var theta = Math.atan2( var theta = Math.atan2(
size.height / 2 - offset.y, size.height / 2 - offset.y,
offset.x - size.width / 2); offset.x - size.width / 2);
this.startRotation_ = (view.getRotation() || 0) + theta; this.startRotation_ = view.getRotation() + theta;
return true; return true;
} else { } else {
return false; return false;
+11 -9
View File
@@ -63,23 +63,25 @@ ol.Kinetic = function(decay, minVelocity, delay) {
/** /**
* @param {goog.events.BrowserEvent} browserEvent Browser event. * @param {number} x X.
* @param {number} y Y.
*/ */
ol.Kinetic.prototype.begin = function(browserEvent) { ol.Kinetic.prototype.begin = function(x, y) {
this.points_.length = 0; this.points_.length = 0;
this.angle_ = 0; this.angle_ = 0;
this.initialVelocity_ = 0; this.initialVelocity_ = 0;
this.update(browserEvent); this.update(x, y);
}; };
/** /**
* @param {goog.events.BrowserEvent} browserEvent Browser event. * @param {number} x X.
* @param {number} y Y.
*/ */
ol.Kinetic.prototype.update = function(browserEvent) { ol.Kinetic.prototype.update = function(x, y) {
this.points_.push({ this.points_.push({
x: browserEvent.clientX, x: x,
y: browserEvent.clientY, y: y,
t: goog.now() t: goog.now()
}); });
}; };
@@ -112,7 +114,7 @@ ol.Kinetic.prototype.end = function() {
* @param {ol.Coordinate} source Source coordinate for the animation. * @param {ol.Coordinate} source Source coordinate for the animation.
* @return {ol.PreRenderFunction} Pre-render function for kinetic animation. * @return {ol.PreRenderFunction} Pre-render function for kinetic animation.
*/ */
ol.Kinetic.prototype.createPanFrom = function(source) { ol.Kinetic.prototype.pan = function(source) {
var decay = this.decay_; var decay = this.decay_;
var initialVelocity = this.initialVelocity_; var initialVelocity = this.initialVelocity_;
var minVelocity = this.minVelocity_; var minVelocity = this.minVelocity_;
@@ -121,7 +123,7 @@ ol.Kinetic.prototype.createPanFrom = function(source) {
return initialVelocity * (Math.exp((decay * t) * duration) - 1) / return initialVelocity * (Math.exp((decay * t) * duration) - 1) /
(minVelocity - initialVelocity); (minVelocity - initialVelocity);
}; };
return ol.animation.createPanFrom({ return ol.animation.pan({
source: source, source: source,
duration: duration, duration: duration,
easing: easingFunction easing: easingFunction
-1
View File
@@ -1,7 +1,6 @@
@exportClass ol.Map ol.MapOptions @exportClass ol.Map ol.MapOptions
@exportProperty ol.Map.prototype.addPreRenderFunction @exportProperty ol.Map.prototype.addPreRenderFunction
@exportProperty ol.Map.prototype.addPreRenderFunctions @exportProperty ol.Map.prototype.addPreRenderFunctions
@exportProperty ol.Map.prototype.getControls
@exportProperty ol.Map.prototype.getInteractions @exportProperty ol.Map.prototype.getInteractions
@exportSymbol ol.RendererHint @exportSymbol ol.RendererHint
+26 -64
View File
@@ -22,8 +22,6 @@ goog.require('goog.events.MouseWheelHandler');
goog.require('goog.events.MouseWheelHandler.EventType'); goog.require('goog.events.MouseWheelHandler.EventType');
goog.require('ol.BrowserFeature'); goog.require('ol.BrowserFeature');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.CollectionEvent');
goog.require('ol.CollectionEventType');
goog.require('ol.Color'); goog.require('ol.Color');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.Extent'); goog.require('ol.Extent');
@@ -230,17 +228,6 @@ ol.Map = function(mapOptions) {
this.handleBrowserEvent, false, this); this.handleBrowserEvent, false, this);
this.registerDisposable(mouseWheelHandler); this.registerDisposable(mouseWheelHandler);
/**
* @type {ol.Collection}
* @private
*/
this.controls_ = mapOptionsInternal.controls;
goog.events.listen(this.controls_, ol.CollectionEventType.ADD,
this.handleControlsAdd_, false, this);
goog.events.listen(this.controls_, ol.CollectionEventType.REMOVE,
this.handleControlsRemove_, false, this);
/** /**
* @type {ol.Collection} * @type {ol.Collection}
* @private * @private
@@ -299,7 +286,9 @@ ol.Map = function(mapOptions) {
// this gives the map an initial size // this gives the map an initial size
this.handleBrowserWindowResize(); this.handleBrowserWindowResize();
this.controls_.forEach( /** @type {Array.<ol.control.Control>} */
var controls = mapOptionsInternal.controls;
goog.array.forEach(controls,
/** /**
* @param {ol.control.Control} control Control. * @param {ol.control.Control} control Control.
*/ */
@@ -387,14 +376,6 @@ ol.Map.prototype.getTarget = function() {
}; };
/**
* @return {ol.Collection} Controls.
*/
ol.Map.prototype.getControls = function() {
return this.controls_;
};
/** /**
* @param {ol.Pixel} pixel Pixel. * @param {ol.Pixel} pixel Pixel.
* @return {ol.Coordinate} Coordinate. * @return {ol.Coordinate} Coordinate.
@@ -500,9 +481,8 @@ ol.Map.prototype.getTilePriority = function(tile, tileSourceKey, tileCenter) {
if (goog.isNull(frameState) || !(tileSourceKey in frameState.wantedTiles)) { if (goog.isNull(frameState) || !(tileSourceKey in frameState.wantedTiles)) {
return ol.TileQueue.DROP; return ol.TileQueue.DROP;
} }
var zKey = tile.tileCoord.z.toString(); var coordKey = tile.tileCoord.toString();
if (!(zKey in frameState.wantedTiles[tileSourceKey]) || if (!frameState.wantedTiles[tileSourceKey][coordKey]) {
!frameState.wantedTiles[tileSourceKey][zKey].contains(tile.tileCoord)) {
return ol.TileQueue.DROP; return ol.TileQueue.DROP;
} }
var center = frameState.view2DState.center; var center = frameState.view2DState.center;
@@ -523,26 +503,6 @@ ol.Map.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
}; };
/**
* @param {ol.CollectionEvent} collectionEvent Collection event.
* @private
*/
ol.Map.prototype.handleControlsAdd_ = function(collectionEvent) {
var control = /** @type {ol.control.Control} */ (collectionEvent.elem);
control.setMap(this);
};
/**
* @param {ol.CollectionEvent} collectionEvent Collection event.
* @private
*/
ol.Map.prototype.handleControlsRemove_ = function(collectionEvent) {
var control = /** @type {ol.control.Control} */ (collectionEvent.elem);
control.setMap(null);
};
/** /**
* @param {ol.MapBrowserEvent} mapBrowserEvent The event to handle. * @param {ol.MapBrowserEvent} mapBrowserEvent The event to handle.
*/ */
@@ -754,8 +714,8 @@ ol.Map.prototype.renderFrame_ = function(time) {
frameState.extent = ol.Extent.boundingExtent.apply(null, corners); frameState.extent = ol.Extent.boundingExtent.apply(null, corners);
} }
this.renderer_.renderFrame(frameState);
this.frameState_ = frameState; this.frameState_ = frameState;
this.renderer_.renderFrame(frameState);
this.dirty_ = false; this.dirty_ = false;
if (!goog.isNull(frameState)) { if (!goog.isNull(frameState)) {
@@ -849,7 +809,7 @@ ol.Map.prototype.withFrozenRendering = function(f, opt_obj) {
/** /**
* @typedef {{controls: ol.Collection, * @typedef {{controls: Array.<ol.control.Control>,
* interactions: ol.Collection, * interactions: ol.Collection,
* rendererConstructor: * rendererConstructor:
* function(new: ol.renderer.Map, Element, ol.Map), * function(new: ol.renderer.Map, Element, ol.Map),
@@ -915,14 +875,9 @@ ol.Map.createOptionsInternal = function(mapOptions) {
} }
/** /**
* @type {ol.Collection} * @type {Array.<ol.control.Control>}
*/ */
var controls; var controls = ol.Map.createControls_(mapOptions);
if (goog.isDef(mapOptions.controls)) {
controls = mapOptions.controls;
} else {
controls = ol.Map.createControls_(mapOptions);
}
/** /**
* @type {ol.Collection} * @type {ol.Collection}
@@ -953,22 +908,29 @@ ol.Map.createOptionsInternal = function(mapOptions) {
/** /**
* @private * @private
* @param {ol.MapOptions} mapOptions Map options. * @param {ol.MapOptions} mapOptions Map options.
* @return {ol.Collection} Controls. * @return {Array.<ol.control.Control>} Controls.
*/ */
ol.Map.createControls_ = function(mapOptions) { ol.Map.createControls_ = function(mapOptions) {
/** @type {Array.<ol.control.Control>} */
var controls = [];
var controls = new ol.Collection(); var attributionControl = goog.isDef(mapOptions.attributionControl) ?
mapOptions.attributionControl : true;
if (attributionControl) {
controls.push(new ol.control.Attribution({}));
}
controls.push(new ol.control.Attribution({})); var zoomControl = goog.isDef(mapOptions.zoomControl) ?
mapOptions.zoomControl : true;
var zoomDelta = goog.isDef(mapOptions.zoomDelta) ? if (zoomControl) {
mapOptions.zoomDelta : 4; var zoomDelta = goog.isDef(mapOptions.zoomDelta) ?
controls.push(new ol.control.Zoom({ mapOptions.zoomDelta : 4;
delta: zoomDelta controls.push(new ol.control.Zoom({
})); delta: zoomDelta
}));
}
return controls; return controls;
}; };
@@ -167,6 +167,9 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
tileState = tile.getState(); tileState = tile.getState();
if (tileState == ol.TileState.IDLE) { if (tileState == ol.TileState.IDLE) {
goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
this.handleTileChange, false, this);
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
tileCenter = tileGrid.getTileCoordCenter(tileCoord); tileCenter = tileGrid.getTileCoordCenter(tileCoord);
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter); frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
} else if (tileState == ol.TileState.LOADED) { } else if (tileState == ol.TileState.LOADED) {
@@ -214,11 +217,6 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
} }
} }
if (!allTilesLoaded) {
frameState.animate = true;
this.updateWantedTiles(frameState.wantedTiles, tileSource, z, tileRange);
}
this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange); this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange);
this.scheduleExpireCache(frameState, tileSource); this.scheduleExpireCache(frameState, tileSource);
+3 -5
View File
@@ -131,6 +131,9 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
tileState = tile.getState(); tileState = tile.getState();
if (tileState == ol.TileState.IDLE) { if (tileState == ol.TileState.IDLE) {
goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
this.handleTileChange, false, this);
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
tileCenter = tileGrid.getTileCoordCenter(tileCoord); tileCenter = tileGrid.getTileCoordCenter(tileCoord);
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter); frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
} else if (tileState == ol.TileState.LOADED) { } else if (tileState == ol.TileState.LOADED) {
@@ -232,11 +235,6 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
this.renderedVisible_ = true; this.renderedVisible_ = true;
} }
if (!allTilesLoaded) {
frameState.animate = true;
this.updateWantedTiles(frameState.wantedTiles, tileSource, z, tileRange);
}
this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange); this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange);
this.scheduleExpireCache(frameState, tileSource); this.scheduleExpireCache(frameState, tileSource);
+22 -14
View File
@@ -4,7 +4,10 @@ goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('ol.FrameState'); goog.require('ol.FrameState');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.Tile');
goog.require('ol.TileCoord');
goog.require('ol.TileRange'); goog.require('ol.TileRange');
goog.require('ol.TileState');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
goog.require('ol.layer.LayerProperty'); goog.require('ol.layer.LayerProperty');
goog.require('ol.layer.LayerState'); goog.require('ol.layer.LayerState');
@@ -146,6 +149,19 @@ ol.renderer.Layer.prototype.handleLayerVisibleChange = function() {
}; };
/**
* Handle changes in tile state.
* @param {goog.events.Event} event Tile change event.
* @protected
*/
ol.renderer.Layer.prototype.handleTileChange = function(event) {
var tile = /** @type {ol.Tile} */ (event.target);
if (tile.getState() === ol.TileState.LOADED) {
this.getMap().requestRenderFrame();
}
};
/** /**
* @param {ol.FrameState} frameState Frame state. * @param {ol.FrameState} frameState Frame state.
* @param {ol.layer.LayerState} layerState Layer state. * @param {ol.layer.LayerState} layerState Layer state.
@@ -197,24 +213,16 @@ ol.renderer.Layer.prototype.updateUsedTiles =
/** /**
* @protected * @protected
* @param {Object.<string, Object.<string, ol.TileRange>>} wantedTiles Wanted * @param {Object.<string, Object.<string, boolean>>} wantedTiles Wanted tiles.
* tile ranges.
* @param {ol.source.Source} source Source. * @param {ol.source.Source} source Source.
* @param {number} z Z. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.TileRange} tileRange Tile range.
*/ */
ol.renderer.Layer.prototype.updateWantedTiles = ol.renderer.Layer.prototype.updateWantedTiles =
function(wantedTiles, source, z, tileRange) { function(wantedTiles, source, tileCoord) {
var sourceKey = goog.getUid(source).toString(); var sourceKey = goog.getUid(source).toString();
var zKey = z.toString(); var coordKey = tileCoord.toString();
if (sourceKey in wantedTiles) { if (!(sourceKey in wantedTiles)) {
if (zKey in wantedTiles[sourceKey]) {
wantedTiles[sourceKey][zKey].extend(tileRange);
} else {
wantedTiles[sourceKey][zKey] = tileRange;
}
} else {
wantedTiles[sourceKey] = {}; wantedTiles[sourceKey] = {};
wantedTiles[sourceKey][zKey] = tileRange;
} }
wantedTiles[sourceKey][coordKey] = true;
}; };
@@ -393,6 +393,9 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
tileState = tile.getState(); tileState = tile.getState();
if (tileState == ol.TileState.IDLE) { if (tileState == ol.TileState.IDLE) {
goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
this.handleTileChange, false, this);
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
tileCenter = tileGrid.getTileCoordCenter(tileCoord); tileCenter = tileGrid.getTileCoordCenter(tileCoord);
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter); frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
} else if (tileState == ol.TileState.LOADED) { } else if (tileState == ol.TileState.LOADED) {
@@ -457,7 +460,6 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
this.renderedTileRange_ = null; this.renderedTileRange_ = null;
this.renderedFramebufferExtent_ = null; this.renderedFramebufferExtent_ = null;
frameState.animate = true; frameState.animate = true;
this.updateWantedTiles(frameState.wantedTiles, tileSource, z, tileRange);
} }
} }
+1 -10
View File
@@ -91,7 +91,7 @@ ol.structs.LRUCache.prototype.clear = function() {
* @return {boolean} Contains key. * @return {boolean} Contains key.
*/ */
ol.structs.LRUCache.prototype.containsKey = function(key) { ol.structs.LRUCache.prototype.containsKey = function(key) {
return key in this.entries_; return this.entries_.hasOwnProperty(key);
}; };
@@ -155,15 +155,6 @@ ol.structs.LRUCache.prototype.getKeys = function() {
}; };
/**
* @return {string} Last key.
*/
ol.structs.LRUCache.prototype.getLastKey = function() {
goog.asserts.assert(!goog.isNull(this.newest_));
return this.newest_.key_;
};
/** /**
* @return {Array} Values. * @return {Array} Values.
*/ */
+1 -1
View File
@@ -298,7 +298,7 @@ ol.View2D.prototype.zoom = function(map, delta, opt_anchor, opt_duration) {
var currentResolution = this.getResolution(); var currentResolution = this.getResolution();
if (goog.isDef(currentResolution) && goog.isDef(opt_duration)) { if (goog.isDef(currentResolution) && goog.isDef(opt_duration)) {
map.requestRenderFrame(); map.requestRenderFrame();
map.addPreRenderFunction(ol.animation.createZoomFrom({ map.addPreRenderFunction(ol.animation.zoom({
resolution: currentResolution, resolution: currentResolution,
duration: opt_duration duration: opt_duration
})); }));
+29 -2
View File
@@ -99,11 +99,38 @@ describe('ol.structs.LRUCache', function() {
}); });
}); });
describe('setting a disallowed key', function() { describe('disallowed keys', function() {
it('raises an exception', function() { it('setting raises an exception', function() {
expect(function() {
lruCache.set('constructor', 0);
}).toThrow();
expect(function() { expect(function() {
lruCache.set('hasOwnProperty', 0); lruCache.set('hasOwnProperty', 0);
}).toThrow(); }).toThrow();
expect(function() {
lruCache.set('isPrototypeOf', 0);
}).toThrow();
expect(function() {
lruCache.set('propertyIsEnumerable', 0);
}).toThrow();
expect(function() {
lruCache.set('toLocaleString', 0);
}).toThrow();
expect(function() {
lruCache.set('toString', 0);
}).toThrow();
expect(function() {
lruCache.set('valueOf', 0);
}).toThrow();
});
it('getting returns false', function() {
expect(lruCache.containsKey('constructor')).toBeFalsy();
expect(lruCache.containsKey('hasOwnProperty')).toBeFalsy();
expect(lruCache.containsKey('isPrototypeOf')).toBeFalsy();
expect(lruCache.containsKey('propertyIsEnumerable')).toBeFalsy();
expect(lruCache.containsKey('toLocaleString')).toBeFalsy();
expect(lruCache.containsKey('toString')).toBeFalsy();
expect(lruCache.containsKey('valueOf')).toBeFalsy();
}); });
}); });