Merge branch 'master' of github.com:openlayers/ol3 into animation-frame
Conflicts: src/ol/renderer/dom/tilelayer.js
This commit is contained in:
8
Makefile
8
Makefile
@@ -109,6 +109,14 @@ build/jsdoc-$(BRANCH)-timestamp: $(SRC) $(shell find doc/template -type f)
|
||||
$(JSDOC) -t doc/template -r src -d build/gh-pages/$(BRANCH)/apidoc
|
||||
touch $@
|
||||
|
||||
.PHONY: hostexamples
|
||||
hostexamples: build examples
|
||||
mkdir -p build/gh-pages/$(BRANCH)/examples
|
||||
mkdir -p build/gh-pages/$(BRANCH)/build
|
||||
cp $(EXAMPLES) $(subst .html,.js,$(EXAMPLES)) examples/style.css build/gh-pages/$(BRANCH)/examples/
|
||||
cp build/loader_hosted_examples.js build/gh-pages/$(BRANCH)/examples/loader.js
|
||||
cp build/ol.js build/ol.css build/gh-pages/$(BRANCH)/build/
|
||||
|
||||
.PHONY: test
|
||||
test: $(INTERNAL_SRC)
|
||||
$(PHANTOMJS) test/phantom-jasmine/run_jasmine_test.coffee test/ol.html
|
||||
|
||||
@@ -27,6 +27,7 @@ Eric Lemoine
|
||||
Philip Lindsay
|
||||
Martijn van Oosterhout
|
||||
David Overstrom
|
||||
Tom Payne
|
||||
Corey Puffault
|
||||
Peter William Robins
|
||||
Gregers Rygg
|
||||
|
||||
@@ -114,9 +114,10 @@ class ObjectLiteral(Exportable):
|
||||
|
||||
class Symbol(Exportable):
|
||||
|
||||
def __init__(self, name, export_symbol):
|
||||
def __init__(self, name, export_symbol, export_as=None):
|
||||
Exportable.__init__(self, name)
|
||||
self.export_symbol = export_symbol
|
||||
self.export_as = export_as or self.name
|
||||
self.props = set()
|
||||
|
||||
__repr__ = simplerepr
|
||||
@@ -124,7 +125,7 @@ class Symbol(Exportable):
|
||||
def export(self):
|
||||
lines = []
|
||||
if self.export_symbol:
|
||||
lines.append('\n\ngoog.exportSymbol(\n \'%s\',\n %s);\n' % (self.name, self.name))
|
||||
lines.append('\n\ngoog.exportSymbol(\n \'%s\',\n %s);\n' % (self.name, self.export_as))
|
||||
lines.extend('goog.exportProperty(\n %s,\n \'%s\',\n %s.%s);\n' % (self.name, prop, self.name, prop) for prop in sorted(self.props))
|
||||
return ''.join(lines)
|
||||
|
||||
@@ -193,14 +194,16 @@ def main(argv):
|
||||
objects[name] = symbol
|
||||
symbol.props.add(prop)
|
||||
continue
|
||||
m = re.match(r'@exportSymbol\s+(?P<name>\S+)\Z', line)
|
||||
m = re.match(r'@exportSymbol\s+(?P<name>\S+)(?:\s+(?P<export_as>\S+))?\Z', line)
|
||||
if m:
|
||||
name = m.group('name')
|
||||
if name in objects:
|
||||
raise RuntimeError(line) # Name already defined
|
||||
symbol = Symbol(name, True)
|
||||
export_as = m.group('export_as')
|
||||
symbol = Symbol(name, True, export_as)
|
||||
objects[name] = symbol
|
||||
requires.add(name)
|
||||
if not export_as:
|
||||
requires.add(name)
|
||||
continue
|
||||
raise RuntimeError(line)
|
||||
|
||||
|
||||
46
build/loader_hosted_examples.js
Normal file
46
build/loader_hosted_examples.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
* Loader to add ol.css, ol.js and the example-specific js file to the
|
||||
* documents.
|
||||
*
|
||||
* This loader is used for the hosted examples. It is used in place of the
|
||||
* development loader (examples/loader.js).
|
||||
*
|
||||
* ol.css and ol.js are built with Plovr/Closure, based build/ol.json.
|
||||
* (`make build` should build them). They are located in the ../build/
|
||||
* directory, relatively to this script.
|
||||
*
|
||||
* The script should be named loader.js. So it needs to be renamed to
|
||||
* loader.js from loader_hosted_examples.js.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <script src="../loader.js?id=my-demo"></script>
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
|
||||
var i, src, index, search, chunks, pair, params = {};
|
||||
for (i = scripts.length - 1; i >= 0; --i) {
|
||||
src = scripts[i].getAttribute('src');
|
||||
if (~(index = src.indexOf('loader.js?'))) {
|
||||
search = src.substr(index + 10);
|
||||
chunks = search ? search.split('&') : [];
|
||||
for (i = chunks.length - 1; i >= 0; --i) {
|
||||
pair = chunks[i].split('=');
|
||||
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
document.write('<link rel="stylesheet" href="../build/ol.css" '+
|
||||
'type="text/css">');
|
||||
document.write('<scr' + 'ipt type="text/javascript" ' +
|
||||
'src="../build/ol.js">' +
|
||||
'</scr' + 'ipt>');
|
||||
document.write('<scr' + 'ipt type="text/javascript" ' +
|
||||
'src="' + encodeURIComponent(params.id) + '.js">' +
|
||||
'</scr' + 'ipt>');
|
||||
}());
|
||||
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; 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="style.css" type="text/css">
|
||||
<style type="text/css">
|
||||
@@ -12,7 +13,6 @@
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<title>ol3 full-screen demo</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
|
||||
|
||||
/**
|
||||
* Loader to add the plovr generated script to the document. The following
|
||||
* default values may be overridden with query string parameters:
|
||||
* Loader to add the plovr generated script and ol.css to the document.
|
||||
*
|
||||
* * hostname - the current hostname
|
||||
* The following default values may be overridden with query string
|
||||
* parameters:
|
||||
*
|
||||
* * hostname - the current hostname (window.location.hostname)
|
||||
* * port - 9810
|
||||
* * mode - ADVANCED
|
||||
* * id - id param in loader.js query string; defaults to 'ol' if not set
|
||||
@@ -54,6 +56,8 @@
|
||||
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
|
||||
}
|
||||
|
||||
document.write('<link rel="stylesheet" href="../css/ol.css" ' +
|
||||
'type="text/css">');
|
||||
var url = 'http://' + host + '/compile?' + pairs.join('&');
|
||||
document.write('<script type="text/javascript" src="' + url + '"></script>');
|
||||
}());
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; 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="style.css" type="text/css">
|
||||
<style type="text/css">
|
||||
@@ -66,7 +67,6 @@
|
||||
margin-left: -13px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<title>ol3 overlay-and-popup demo</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<style type="text/css">
|
||||
.map {
|
||||
|
||||
@@ -39,7 +39,7 @@ var webglMap = new ol.Map({
|
||||
renderer: ol.RendererHint.WEBGL,
|
||||
target: 'webglMap'
|
||||
});
|
||||
if (!goog.isNull(webglMap)) {
|
||||
if (webglMap !== null) {
|
||||
webglMap.bindTo('center', domMap);
|
||||
webglMap.bindTo('layers', domMap);
|
||||
webglMap.bindTo('resolution', domMap);
|
||||
|
||||
@@ -18,18 +18,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var layer = new ol.layer.TileLayer({
|
||||
source: new ol.source.MapQuestOpenAerial()
|
||||
});
|
||||
var map = new ol.Map({
|
||||
center: new ol.Coordinate(0, 0),
|
||||
layers: new ol.Collection([layer]),
|
||||
target: 'map',
|
||||
zoom: 2
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="../full-screen.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -77,40 +77,6 @@
|
||||
<!-- Popup -->
|
||||
<div class="overlay arrow_box" id="popup"></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var layer = new ol.layer.TileLayer({
|
||||
source: new ol.source.MapQuestOpenAerial()
|
||||
});
|
||||
var map = new ol.Map({
|
||||
center: new ol.Coordinate(0, 0),
|
||||
layers: new ol.Collection([layer]),
|
||||
target: 'map',
|
||||
zoom: 2
|
||||
});
|
||||
|
||||
// Vienna label
|
||||
var vienna = new ol.overlay.Overlay({
|
||||
map: map,
|
||||
coordinate: ol.Projection.transformWithCodes(
|
||||
new ol.Coordinate(16.3725, 48.208889), 'EPSG:4326', 'EPSG:3857'),
|
||||
element: document.getElementById('vienna')
|
||||
});
|
||||
|
||||
// Popup showing the position the user clicked
|
||||
var popup = new ol.overlay.Overlay({
|
||||
element: document.getElementById('popup')
|
||||
});
|
||||
map.addEventListener('click', function(evt) {
|
||||
var coordinate = evt.getCoordinate();
|
||||
popup.getElement().innerHTML =
|
||||
'Welcome to ol3. The location you clicked was<br>' +
|
||||
ol.CoordinateFormat.hdms(ol.Projection.transformWithCodes(
|
||||
coordinate, 'EPSG:3857', 'EPSG:4326'));
|
||||
popup.setMap(evt.map);
|
||||
popup.setCoordinate(evt.getCoordinate());
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="../overlay-and-popup.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -66,92 +66,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
<p><b>Notes:</b> The two maps share the same center, resolution, rotation and layers.</p>
|
||||
<script type="text/javascript">
|
||||
|
||||
var layer = new ol.layer.TileLayer({
|
||||
source: new ol.source.MapQuestOpenAerial()
|
||||
});
|
||||
|
||||
var domMap = new ol.Map({
|
||||
center: new ol.Coordinate(0, 0),
|
||||
layers: new ol.Collection([layer]),
|
||||
renderer: ol.RendererHint.DOM,
|
||||
target: 'domMap',
|
||||
zoom: 1
|
||||
});
|
||||
|
||||
domMap.getControls().push(new ol.control.MousePosition({
|
||||
coordinateFormat: ol.CoordinateFormat.hdms,
|
||||
projection: ol.Projection.getFromCode('EPSG:4326'),
|
||||
target: document.getElementById('domMousePosition'),
|
||||
undefinedHtml: ' '
|
||||
}));
|
||||
|
||||
var webglMap = new ol.Map({
|
||||
renderer: ol.RendererHint.WEBGL,
|
||||
target: 'webglMap'
|
||||
});
|
||||
if (webglMap) {
|
||||
webglMap.bindTo('center', domMap);
|
||||
webglMap.bindTo('layers', domMap);
|
||||
webglMap.bindTo('resolution', domMap);
|
||||
webglMap.bindTo('rotation', domMap);
|
||||
}
|
||||
|
||||
webglMap.getControls().push(new ol.control.MousePosition({
|
||||
coordinateFormat: ol.CoordinateFormat.hdms,
|
||||
projection: ol.Projection.getFromCode('EPSG:4326'),
|
||||
target: document.getElementById('webglMousePosition'),
|
||||
undefinedHtml: ' '
|
||||
}));
|
||||
|
||||
var keyboardInteraction = new ol.interaction.Keyboard();
|
||||
keyboardInteraction.addCallback('0', function() {
|
||||
layer.setBrightness(0);
|
||||
layer.setContrast(0);
|
||||
layer.setHue(0);
|
||||
layer.setSaturation(0);
|
||||
layer.setOpacity(1);
|
||||
layer.setVisible(true);
|
||||
});
|
||||
keyboardInteraction.addCallback('b', function() {
|
||||
layer.setBrightness(layer.getBrightness() - 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('B', function() {
|
||||
layer.setBrightness(layer.getBrightness() + 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('c', function() {
|
||||
layer.setContrast(layer.getContrast() - 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('C', function() {
|
||||
layer.setContrast(layer.getContrast() + 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('h', function() {
|
||||
layer.setHue(layer.getHue() - 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('H', function() {
|
||||
layer.setHue(layer.getHue() + 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('o', function() {
|
||||
layer.setOpacity(layer.getOpacity() - 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('O', function() {
|
||||
layer.setOpacity(layer.getOpacity() + 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('r', function() {
|
||||
webglMap.setRotation(0);
|
||||
});
|
||||
keyboardInteraction.addCallback('s', function() {
|
||||
layer.setSaturation(layer.getSaturation() - 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('S', function() {
|
||||
layer.setSaturation(layer.getSaturation() + 0.1);
|
||||
});
|
||||
keyboardInteraction.addCallback('vV', function() {
|
||||
layer.setVisible(!layer.getVisible());
|
||||
});
|
||||
domMap.getInteractions().push(keyboardInteraction);
|
||||
|
||||
</script>
|
||||
<script src="../side-by-side.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<style type="text/css">
|
||||
.map {
|
||||
|
||||
@@ -49,6 +49,15 @@ ol.control.Control = function(controlOptions) {
|
||||
goog.inherits(ol.control.Control, goog.Disposable);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.control.Control.prototype.disposeInternal = function() {
|
||||
goog.dom.removeNode(this.element);
|
||||
goog.base(this, 'disposeInternal');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Map} Map.
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@exportSymbol goog.require goog.nullFunction
|
||||
|
||||
@exportProperty ol.MapBrowserEvent.prototype.getCoordinate
|
||||
|
||||
@exportSymbol ol.Collection
|
||||
@@ -122,6 +124,16 @@
|
||||
@exportProperty ol.overlay.Overlay.prototype.setMap
|
||||
|
||||
@exportSymbol ol.source.BingMaps
|
||||
@exportSymbol ol.BingMapsStyle
|
||||
@exportProperty ol.BingMapsStyle.AERIAL
|
||||
@exportProperty ol.BingMapsStyle.AERIAL_WITH_LABELS
|
||||
@exportProperty ol.BingMapsStyle.ROAD
|
||||
@exportProperty ol.BingMapsStyle.ORDNANCE_SURVEY
|
||||
@exportProperty ol.BingMapsStyle.COLLINS_BART
|
||||
@exportObjectLiteral ol.source.BingMapsOptions
|
||||
@exportObjectLiteralProperty ol.source.BingMapsOptions.culture string|undefined
|
||||
@exportObjectLiteralProperty ol.source.BingMapsOptions.key string
|
||||
@exportObjectLiteralProperty ol.source.BingMapsOptions.style ol.BingMapsStyle
|
||||
|
||||
@exportSymbol ol.source.MapQuestOSM
|
||||
|
||||
|
||||
56
src/ol/interaction/condition.js
Normal file
56
src/ol/interaction/condition.js
Normal file
@@ -0,0 +1,56 @@
|
||||
goog.provide('ol.interaction.ConditionType');
|
||||
goog.provide('ol.interaction.condition');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {function(goog.events.BrowserEvent): boolean}
|
||||
*/
|
||||
ol.interaction.ConditionType;
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @return {boolean} True if only the alt key is pressed.
|
||||
*/
|
||||
ol.interaction.condition.altKeyOnly = function(browserEvent) {
|
||||
return (
|
||||
browserEvent.altKey &&
|
||||
!browserEvent.platformModifierKey &&
|
||||
!browserEvent.shiftKey);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @return {boolean} True if only the no modifier keys are pressed.
|
||||
*/
|
||||
ol.interaction.condition.noModifierKeys = function(browserEvent) {
|
||||
return (
|
||||
!browserEvent.altKey &&
|
||||
!browserEvent.platformModifierKey &&
|
||||
!browserEvent.shiftKey);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @return {boolean} True if only the platform modifier key is pressed.
|
||||
*/
|
||||
ol.interaction.condition.platformModifierKeyOnly = function(browserEvent) {
|
||||
return (
|
||||
!browserEvent.altKey &&
|
||||
browserEvent.platformModifierKey &&
|
||||
!browserEvent.shiftKey);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @return {boolean} True if only the shift key is pressed.
|
||||
*/
|
||||
ol.interaction.condition.shiftKeyOnly = function(browserEvent) {
|
||||
return (
|
||||
!browserEvent.altKey &&
|
||||
!browserEvent.platformModifierKey &&
|
||||
browserEvent.shiftKey);
|
||||
};
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.interaction.DragPan');
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -9,9 +10,18 @@ goog.require('ol.interaction.Drag');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.DragPan = function() {
|
||||
ol.interaction.DragPan = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.DragPan, ol.interaction.Drag);
|
||||
|
||||
@@ -39,7 +49,7 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
*/
|
||||
ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (!browserEvent.shiftKey) {
|
||||
if (this.condition_(browserEvent)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.provide('ol.interaction.AltDragRotate');
|
||||
goog.provide('ol.interaction.DragRotate');
|
||||
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -8,11 +9,18 @@ goog.require('ol.interaction.Drag');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.AltDragRotate = function() {
|
||||
ol.interaction.DragRotate = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -20,13 +28,13 @@ ol.interaction.AltDragRotate = function() {
|
||||
this.startRotation_ = 0;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.AltDragRotate, ol.interaction.Drag);
|
||||
goog.inherits(ol.interaction.DragRotate, ol.interaction.Drag);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.AltDragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
var size = map.getSize();
|
||||
@@ -41,11 +49,11 @@ ol.interaction.AltDragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.AltDragRotate.prototype.handleDragStart =
|
||||
ol.interaction.DragRotate.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
if (browserEvent.isMouseActionButton() && browserEvent.altKey &&
|
||||
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent) &&
|
||||
map.canRotate()) {
|
||||
var size = map.getSize();
|
||||
var offset = mapBrowserEvent.getPixel();
|
||||
@@ -1,7 +1,8 @@
|
||||
goog.provide('ol.interaction.ShiftDragRotateAndZoom');
|
||||
goog.provide('ol.interaction.DragRotateAndZoom');
|
||||
|
||||
goog.require('goog.math.Vec2');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -9,11 +10,18 @@ goog.require('ol.interaction.Drag');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.ShiftDragRotateAndZoom = function() {
|
||||
ol.interaction.DragRotateAndZoom = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -27,13 +35,13 @@ ol.interaction.ShiftDragRotateAndZoom = function() {
|
||||
this.startRotation_ = 0;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.ShiftDragRotateAndZoom, ol.interaction.Drag);
|
||||
goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Drag);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.ShiftDragRotateAndZoom.prototype.handleDrag =
|
||||
ol.interaction.DragRotateAndZoom.prototype.handleDrag =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
@@ -52,11 +60,11 @@ ol.interaction.ShiftDragRotateAndZoom.prototype.handleDrag =
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.ShiftDragRotateAndZoom.prototype.handleDragStart =
|
||||
ol.interaction.DragRotateAndZoom.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
if (map.canRotate() && browserEvent.shiftKey) {
|
||||
if (map.canRotate() && this.condition_(browserEvent)) {
|
||||
var resolution = map.getResolution();
|
||||
var size = map.getSize();
|
||||
var delta = new goog.math.Vec2(
|
||||
@@ -1,10 +1,11 @@
|
||||
// FIXME draw drag box
|
||||
|
||||
goog.provide('ol.interaction.ShiftDragZoom');
|
||||
goog.provide('ol.interaction.DragZoom');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.control.DragBox');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -26,11 +27,18 @@ ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED =
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.ShiftDragZoom = function() {
|
||||
ol.interaction.DragZoom = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
/**
|
||||
* @type {ol.control.DragBox}
|
||||
* @private
|
||||
@@ -39,13 +47,13 @@ ol.interaction.ShiftDragZoom = function() {
|
||||
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.ShiftDragZoom, ol.interaction.Drag);
|
||||
goog.inherits(ol.interaction.DragZoom, ol.interaction.Drag);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.ShiftDragZoom.prototype.handleDragEnd =
|
||||
ol.interaction.DragZoom.prototype.handleDragEnd =
|
||||
function(mapBrowserEvent) {
|
||||
this.dragBox_.setMap(null);
|
||||
this.dragBox_ = null;
|
||||
@@ -63,10 +71,10 @@ ol.interaction.ShiftDragZoom.prototype.handleDragEnd =
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.ShiftDragZoom.prototype.handleDragStart =
|
||||
ol.interaction.DragZoom.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (browserEvent.isMouseActionButton() && browserEvent.shiftKey) {
|
||||
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent)) {
|
||||
this.dragBox_ = new ol.control.DragBox({
|
||||
map: mapBrowserEvent.map,
|
||||
startCoordinate: this.startCoordinate
|
||||
@@ -39,14 +39,15 @@ goog.require('ol.Size');
|
||||
goog.require('ol.TransformFunction');
|
||||
goog.require('ol.control.Attribution');
|
||||
goog.require('ol.control.Zoom');
|
||||
goog.require('ol.interaction.AltDragRotate');
|
||||
goog.require('ol.interaction.DblClickZoom');
|
||||
goog.require('ol.interaction.DragPan');
|
||||
goog.require('ol.interaction.DragRotate');
|
||||
goog.require('ol.interaction.DragZoom');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.interaction.KeyboardPan');
|
||||
goog.require('ol.interaction.KeyboardZoom');
|
||||
goog.require('ol.interaction.MouseWheelZoom');
|
||||
goog.require('ol.interaction.ShiftDragZoom');
|
||||
goog.require('ol.interaction.condition');
|
||||
goog.require('ol.renderer.Layer');
|
||||
goog.require('ol.renderer.Map');
|
||||
goog.require('ol.renderer.dom');
|
||||
@@ -263,6 +264,16 @@ ol.Map.prototype.canRotate = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.Map.prototype.disposeInternal = function() {
|
||||
goog.dom.removeNode(this.viewport_);
|
||||
goog.base(this, 'disposeInternal');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
*/
|
||||
@@ -995,7 +1006,8 @@ ol.Map.createInteractions_ = function(mapOptions) {
|
||||
var rotate = goog.isDef(mapOptions.rotate) ?
|
||||
mapOptions.rotate : true;
|
||||
if (rotate) {
|
||||
interactions.push(new ol.interaction.AltDragRotate());
|
||||
interactions.push(
|
||||
new ol.interaction.DragRotate(ol.interaction.condition.altKeyOnly));
|
||||
}
|
||||
|
||||
var doubleClickZoom = goog.isDef(mapOptions.doubleClickZoom) ?
|
||||
@@ -1009,7 +1021,8 @@ ol.Map.createInteractions_ = function(mapOptions) {
|
||||
var dragPan = goog.isDef(mapOptions.dragPan) ?
|
||||
mapOptions.dragPan : true;
|
||||
if (dragPan) {
|
||||
interactions.push(new ol.interaction.DragPan());
|
||||
interactions.push(
|
||||
new ol.interaction.DragPan(ol.interaction.condition.noModifierKeys));
|
||||
}
|
||||
|
||||
var keyboard = goog.isDef(mapOptions.keyboard) ?
|
||||
@@ -1033,7 +1046,8 @@ ol.Map.createInteractions_ = function(mapOptions) {
|
||||
var shiftDragZoom = goog.isDef(mapOptions.shiftDragZoom) ?
|
||||
mapOptions.shiftDragZoom : true;
|
||||
if (shiftDragZoom) {
|
||||
interactions.push(new ol.interaction.ShiftDragZoom());
|
||||
interactions.push(
|
||||
new ol.interaction.DragZoom(ol.interaction.condition.shiftKeyOnly));
|
||||
}
|
||||
|
||||
return interactions;
|
||||
|
||||
@@ -285,9 +285,11 @@ ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
|
||||
this.handleUp_, false, this);
|
||||
goog.events.unlisten(element,
|
||||
goog.events.EventType.CLICK, this.click_, false, this);
|
||||
goog.asserts.assert(goog.isDef(this.dragListenerKeys_));
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_ = null;
|
||||
if (!goog.isNull(this.dragListenerKeys_)) {
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_ = null;
|
||||
}
|
||||
goog.base(this, 'disposeInternal');
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -116,10 +116,10 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
||||
var z = tileGrid.getZForResolution(mapResolution);
|
||||
|
||||
/**
|
||||
* @type {Object.<string, Object.<string, ol.Tile>>}
|
||||
* @type {Object.<number, Object.<string, ol.Tile>>}
|
||||
*/
|
||||
var tilesToDrawByZ = {};
|
||||
tilesToDrawByZ[String(z)] = {};
|
||||
tilesToDrawByZ[z] = {};
|
||||
|
||||
var tileRange =
|
||||
tileGrid.getTileRangeForExtentAndResolution(mapExtent, mapResolution);
|
||||
@@ -136,7 +136,7 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
||||
var key = tile.tileCoord.toString();
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.LOADED) {
|
||||
tilesToDrawByZ[String(z)][key] = tile;
|
||||
tilesToDrawByZ[z][key] = tile;
|
||||
return;
|
||||
} else {
|
||||
if (state != ol.TileState.LOADING) {
|
||||
@@ -155,12 +155,10 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
||||
tileGrid.forEachTileCoordParentTileRange(
|
||||
tileCoord,
|
||||
function(altZ, altTileRange) {
|
||||
altZ = String(altZ);
|
||||
var fullyCovered = true;
|
||||
altTileRange.forEachTileCoord(altZ, function(altTileCoord) {
|
||||
var tileKey = altTileCoord.toString();
|
||||
if (tilesToDrawByZ[altZ] &&
|
||||
tilesToDrawByZ[altZ][tileKey]) {
|
||||
if (tilesToDrawByZ[altZ] && tilesToDrawByZ[altZ][tileKey]) {
|
||||
return;
|
||||
}
|
||||
var altTile = tileSource.getTile(altTileCoord);
|
||||
@@ -179,16 +177,17 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
||||
|
||||
}, this);
|
||||
|
||||
var zs = goog.object.getKeys(tilesToDrawByZ);
|
||||
zs.sort(function(a, b) {return a - b});
|
||||
/** @type {Array.<number>} */
|
||||
var zs = goog.array.map(goog.object.getKeys(tilesToDrawByZ), Number);
|
||||
goog.array.sort(zs);
|
||||
|
||||
var fragment = document.createDocumentFragment();
|
||||
var altFragment = document.createDocumentFragment();
|
||||
var newTiles = false;
|
||||
var newAltTiles = false;
|
||||
for (var i = 0, ii = zs.length; i < ii; ++i) {
|
||||
var tileZ = +zs[i];
|
||||
var tilesToDraw = tilesToDrawByZ[String(tileZ)];
|
||||
var tileZ = zs[i];
|
||||
var tilesToDraw = tilesToDrawByZ[tileZ];
|
||||
var tileOffset = this.getTileOffset_(tileZ, mapResolution);
|
||||
for (var key in tilesToDraw) {
|
||||
var tile = tilesToDraw[key];
|
||||
|
||||
@@ -22,6 +22,7 @@ goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.renderer.webgl.FragmentShader');
|
||||
goog.require('ol.renderer.webgl.TileLayer');
|
||||
goog.require('ol.renderer.webgl.VertexShader');
|
||||
goog.require('ol.webgl');
|
||||
goog.require('ol.webgl.WebGLContextEventType');
|
||||
|
||||
|
||||
@@ -163,7 +164,7 @@ ol.renderer.webgl.Map = function(container, map) {
|
||||
* @private
|
||||
* @type {WebGLRenderingContext}
|
||||
*/
|
||||
this.gl_ = this.canvas_.getContext('experimental-webgl', {
|
||||
this.gl_ = ol.webgl.getContext(this.canvas_, {
|
||||
alpha: false,
|
||||
antialias: true,
|
||||
depth: false,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
goog.provide('ol.renderer.webgl');
|
||||
|
||||
goog.require('ol.webgl');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Free resources immediately.
|
||||
@@ -10,14 +12,4 @@ ol.renderer.webgl.FREE_RESOURCES_IMMEDIATELY = false;
|
||||
/**
|
||||
* @return {boolean} Is supported.
|
||||
*/
|
||||
ol.renderer.webgl.isSupported = function() {
|
||||
if (!('WebGLRenderingContext' in goog.global)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS);
|
||||
return !goog.isNull(canvas.getContext('experimental-webgl'));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
ol.renderer.webgl.isSupported = ol.webgl.isSupported;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
goog.provide('ol.BingMapsStyle');
|
||||
goog.provide('ol.source.BingMaps');
|
||||
|
||||
goog.require('goog.Uri');
|
||||
@@ -21,14 +22,6 @@ ol.BingMapsStyle = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{culture: (string|undefined),
|
||||
* key: string,
|
||||
* style: ol.BingMapsStyle}}
|
||||
*/
|
||||
ol.source.BingMapsOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
goog.provide('ol.webgl');
|
||||
goog.provide('ol.webgl.WebGLContextEventType');
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @private
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
ol.webgl.CONTEXT_IDS_ = [
|
||||
'webgl',
|
||||
'webgl-experimental',
|
||||
'webkit-3d',
|
||||
'moz-webgl'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
@@ -8,3 +22,39 @@ ol.webgl.WebGLContextEventType = {
|
||||
LOST: 'webglcontextlost',
|
||||
RESTORED: 'webglcontextrestored'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} canvas Canvas.
|
||||
* @param {Object=} opt_attributes Attributes.
|
||||
* @return {WebGLRenderingContext} WebGL rendering context.
|
||||
*/
|
||||
ol.webgl.getContext = function(canvas, opt_attributes) {
|
||||
var context, i, ii = ol.webgl.CONTEXT_IDS_.length;
|
||||
for (i = 0; i < ii; ++i) {
|
||||
try {
|
||||
context = canvas.getContext(ol.webgl.CONTEXT_IDS_[i], opt_attributes);
|
||||
if (!goog.isNull(context)) {
|
||||
return context;
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean} Is supported.
|
||||
*/
|
||||
ol.webgl.isSupported = function() {
|
||||
if (!('WebGLRenderingContext' in goog.global)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS);
|
||||
return !goog.isNull(ol.webgl.getContext(canvas));
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<script type="text/javascript" src="spec/ol/tilegrid.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/tilerange.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/tileurlfunction.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/control/control.test.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -124,5 +125,6 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
27
test/spec/ol/control/control.test.js
Normal file
27
test/spec/ol/control/control.test.js
Normal file
@@ -0,0 +1,27 @@
|
||||
goog.require('goog.dom');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.control.Control');
|
||||
|
||||
describe('ol.control.Control', function() {
|
||||
var map, control;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
target: document.getElementById('map')
|
||||
});
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV);
|
||||
control = new ol.control.Control({element: element});
|
||||
control.setMap(map);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
map.dispose();
|
||||
});
|
||||
|
||||
describe('dispose', function() {
|
||||
it('removes the control element from its parent', function() {
|
||||
control.dispose();
|
||||
expect(goog.dom.getParentElement(control.element)).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,23 @@
|
||||
goog.require('goog.dom');
|
||||
goog.require('ol.Map');
|
||||
|
||||
describe('ol.Map', function() {
|
||||
|
||||
describe('dispose', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
target: document.getElementById('map')
|
||||
});
|
||||
});
|
||||
|
||||
it('removes the viewport from its parent', function() {
|
||||
map.dispose();
|
||||
expect(goog.dom.getParentElement(map.getViewport())).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('create constraints', function() {
|
||||
|
||||
describe('create resolution constraint', function() {
|
||||
|
||||
Reference in New Issue
Block a user