Merge remote-tracking branch 'upstream/master'
This commit is contained in:
4
build.py
4
build.py
@@ -32,7 +32,11 @@ class ThreadPool:
|
||||
try:
|
||||
function(*args, **kargs)
|
||||
except:
|
||||
print("ERROR")
|
||||
for count, thing in enumerate(args):
|
||||
print '{0}. {1}'.format(count, thing)
|
||||
print(sys.exc_info()[0])
|
||||
print("ERROR")
|
||||
self.tasks.errors = True
|
||||
self.tasks.task_done()
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"library_url": "https://github.com/google/closure-library/archive/5b7a6ce1974c230dc169cb93ed5f9689e880aa50.zip"
|
||||
"library_url": "https://github.com/google/closure-library/archive/ad5e66c1e7d7829b0d77feae49aaf5f011265715.zip"
|
||||
}
|
||||
|
||||
75
examples/earthquake-clusters.html
Normal file
75
examples/earthquake-clusters.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>Earthquake Clusters</title>
|
||||
<style>
|
||||
#map {
|
||||
position: relative;
|
||||
}
|
||||
#info {
|
||||
position: absolute;
|
||||
height: 1px;
|
||||
width: 1px;
|
||||
z-index: 100;
|
||||
}
|
||||
.tooltip.in {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100);
|
||||
}
|
||||
.tooltip.top .tooltip-arrow {
|
||||
border-top-color: white;
|
||||
}
|
||||
.tooltip-inner {
|
||||
border: 2px solid white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div id="map" class="map"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
<h4 id="title">Earthquake Clusters</h4>
|
||||
<p id="shortdesc">Demonstrates the use of style geometries to render source features of a cluster.</p>
|
||||
<div id="docs">
|
||||
<p>
|
||||
This example parses a KML file and renders the features as clusters on a vector layer. The styling in this example is quite involved. Single earthquake locations (rendered as stars) have a size relative to their magnitude. Clusters have an opacity relative to the number of features in the cluster, and a size that represents the extent of the features that make up the cluster. When clicking or hovering on a cluster, the individual features that make up the cluster will be shown.
|
||||
</p>
|
||||
<p>To achieve this, we make heavy use of style functions and <code>ol.style.Style#geometry</code>. See the <a href="earthquake-clusters.js" target="_blank">earthquake-clusters.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">KML, vector, style, geometry, cluster</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../resources/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="../resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=earthquake-clusters" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
154
examples/earthquake-clusters.js
Normal file
154
examples/earthquake-clusters.js
Normal file
@@ -0,0 +1,154 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.interaction.Select');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.source.Cluster');
|
||||
goog.require('ol.source.KML');
|
||||
goog.require('ol.source.Stamen');
|
||||
goog.require('ol.style.Circle');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.RegularShape');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.style.Text');
|
||||
|
||||
|
||||
var earthquakeFill = new ol.style.Fill({
|
||||
color: 'rgba(255, 153, 0, 0.8)'
|
||||
});
|
||||
var earthquakeStroke = new ol.style.Stroke({
|
||||
color: 'rgba(255, 204, 0, 0.2)',
|
||||
width: 1
|
||||
});
|
||||
var textFill = new ol.style.Fill({
|
||||
color: '#fff'
|
||||
});
|
||||
var textStroke = new ol.style.Stroke({
|
||||
color: 'rgba(0, 0, 0, 0.6)',
|
||||
width: 3
|
||||
});
|
||||
var invisibleFill = new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.01)'
|
||||
});
|
||||
|
||||
function createEarthquakeStyle(feature) {
|
||||
// 2012_Earthquakes_Mag5.kml stores the magnitude of each earthquake in a
|
||||
// standards-violating <magnitude> tag in each Placemark. We extract it
|
||||
// from the Placemark's name instead.
|
||||
var name = feature.get('name');
|
||||
var magnitude = parseFloat(name.substr(2));
|
||||
var radius = 5 + 20 * (magnitude - 5);
|
||||
|
||||
return new ol.style.Style({
|
||||
geometry: feature.getGeometry(),
|
||||
image: new ol.style.RegularShape({
|
||||
radius1: radius,
|
||||
radius2: 3,
|
||||
points: 5,
|
||||
angle: Math.PI,
|
||||
fill: earthquakeFill,
|
||||
stroke: earthquakeStroke
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
var maxFeatureCount;
|
||||
function calculateClusterInfo(resolution) {
|
||||
maxFeatureCount = 0;
|
||||
var features = vector.getSource().getFeatures();
|
||||
var feature, radius;
|
||||
for (var i = features.length - 1; i >= 0; --i) {
|
||||
feature = features[i];
|
||||
var originalFeatures = feature.get('features');
|
||||
var extent = ol.extent.createEmpty();
|
||||
for (var j = 0, jj = originalFeatures.length; j < jj; ++j) {
|
||||
ol.extent.extend(extent, originalFeatures[j].getGeometry().getExtent());
|
||||
}
|
||||
maxFeatureCount = Math.max(maxFeatureCount, jj);
|
||||
radius = 0.25 * (ol.extent.getWidth(extent) + ol.extent.getHeight(extent)) /
|
||||
resolution;
|
||||
feature.set('radius', radius);
|
||||
}
|
||||
}
|
||||
|
||||
var currentResolution;
|
||||
function styleFunction(feature, resolution) {
|
||||
if (resolution != currentResolution) {
|
||||
calculateClusterInfo(resolution);
|
||||
currentResolution = resolution;
|
||||
}
|
||||
var style;
|
||||
var size = feature.get('features').length;
|
||||
if (size > 1) {
|
||||
style = [new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
radius: feature.get('radius'),
|
||||
fill: new ol.style.Fill({
|
||||
color: [255, 153, 0, Math.min(0.8, 0.4 + (size / maxFeatureCount))]
|
||||
})
|
||||
}),
|
||||
text: new ol.style.Text({
|
||||
text: size.toString(),
|
||||
fill: textFill,
|
||||
stroke: textStroke
|
||||
})
|
||||
})];
|
||||
} else {
|
||||
var originalFeature = feature.get('features')[0];
|
||||
style = [createEarthquakeStyle(originalFeature)];
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
function selectStyleFunction(feature, resolution) {
|
||||
var styles = [new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
radius: feature.get('radius'),
|
||||
fill: invisibleFill
|
||||
})
|
||||
})];
|
||||
var originalFeatures = feature.get('features');
|
||||
var originalFeature;
|
||||
for (var i = originalFeatures.length - 1; i >= 0; --i) {
|
||||
originalFeature = originalFeatures[i];
|
||||
styles.push(createEarthquakeStyle(originalFeature));
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
|
||||
var vector = new ol.layer.Vector({
|
||||
source: new ol.source.Cluster({
|
||||
distance: 40,
|
||||
source: new ol.source.KML({
|
||||
extractStyles: false,
|
||||
projection: 'EPSG:3857',
|
||||
url: 'data/kml/2012_Earthquakes_Mag5.kml'
|
||||
})
|
||||
}),
|
||||
style: styleFunction
|
||||
});
|
||||
|
||||
var raster = new ol.layer.Tile({
|
||||
source: new ol.source.Stamen({
|
||||
layer: 'toner'
|
||||
})
|
||||
});
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [raster, vector],
|
||||
interactions: ol.interaction.defaults().extend([new ol.interaction.Select({
|
||||
condition: function(evt) {
|
||||
return evt.originalEvent.type == 'mousemove' ||
|
||||
evt.type == 'singleclick';
|
||||
},
|
||||
style: selectStyleFunction
|
||||
})]),
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
})
|
||||
});
|
||||
@@ -34,9 +34,9 @@ var GeoJSONCRS = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {!GeoJSONCRSCode|!GeoJSONCRSName|!GeoJSONLink}
|
||||
* TODO: remove GeoJSONCRSCode when http://jira.codehaus.org/browse/GEOS-5996
|
||||
* is fixed and widely deployed.
|
||||
* @type {!GeoJSONCRSCode|!GeoJSONCRSName|!GeoJSONLink}
|
||||
*/
|
||||
GeoJSONCRS.prototype.properties;
|
||||
|
||||
@@ -60,9 +60,9 @@ var GeoJSONCRSName = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* TODO: remove this when http://jira.codehaus.org/browse/GEOS-5996 is fixed
|
||||
* and widely deployed.
|
||||
* @type {string}
|
||||
*/
|
||||
GeoJSONCRSName.prototype.code;
|
||||
|
||||
|
||||
@@ -137,22 +137,6 @@ oli.control.Control.prototype.setMap = function(map) {};
|
||||
oli.interaction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
oli.interaction.Interaction = function() {};
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} Whether the map browser event should continue
|
||||
* through the chain of interactions. `false` means stop, `true`
|
||||
* means continue.
|
||||
*/
|
||||
oli.interaction.Interaction.prototype.handleMapBrowserEvent =
|
||||
function(mapBrowserEvent) {};
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
|
||||
124
externs/olx.js
124
externs/olx.js
@@ -172,6 +172,25 @@ olx.GraticuleOptions.prototype.strokeStyle;
|
||||
olx.GraticuleOptions.prototype.targetSize;
|
||||
|
||||
|
||||
/**
|
||||
* Object literal with config options for interactions.
|
||||
* @typedef {{handleEvent: function(ol.MapBrowserEvent):boolean}}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.InteractionOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Method called by the map to notify the interaction that a browser event was
|
||||
* dispatched to the map. The function may return `false` to prevent the
|
||||
* propagation of the event to other interactions in the map's interactions
|
||||
* chain. Required.
|
||||
* @type {function(ol.MapBrowserEvent):boolean}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.InteractionOptions.prototype.handleEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Object literal with config options for the map.
|
||||
* @typedef {{controls: (ol.Collection.<ol.control.Control>|Array.<ol.control.Control>|undefined),
|
||||
@@ -802,6 +821,7 @@ olx.control;
|
||||
* tipLabel: (string|undefined),
|
||||
* label: (string|undefined),
|
||||
* collapseLabel: (string|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
* target: (Element|undefined)}}
|
||||
* @api
|
||||
*/
|
||||
@@ -865,8 +885,19 @@ olx.control.AttributionOptions.prototype.label;
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.collapseLabel;
|
||||
|
||||
|
||||
/**
|
||||
* Function called when the control should be re-rendered. This is called
|
||||
* in a requestAnimationFrame callback.
|
||||
* @type {function(ol.MapEvent)|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.render;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{element: (Element|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
* target: (Element|string|undefined)}}
|
||||
* @api stable
|
||||
*/
|
||||
@@ -882,6 +913,15 @@ olx.control.ControlOptions;
|
||||
olx.control.ControlOptions.prototype.element;
|
||||
|
||||
|
||||
/**
|
||||
* Function called when the control should be re-rendered. This is called
|
||||
* in a requestAnimationFrame callback.
|
||||
* @type {function(ol.MapEvent)|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.ControlOptions.prototype.render;
|
||||
|
||||
|
||||
/**
|
||||
* Specify a target if you want the control to be rendered outside of the map's
|
||||
* viewport.
|
||||
@@ -997,6 +1037,7 @@ olx.control.FullScreenOptions.prototype.target;
|
||||
* @typedef {{className: (string|undefined),
|
||||
* coordinateFormat: (ol.CoordinateFormatType|undefined),
|
||||
* projection: ol.proj.ProjectionLike,
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
* target: (Element|undefined),
|
||||
* undefinedHTML: (string|undefined)}}
|
||||
* @api stable
|
||||
@@ -1028,6 +1069,15 @@ olx.control.MousePositionOptions.prototype.coordinateFormat;
|
||||
olx.control.MousePositionOptions.prototype.projection;
|
||||
|
||||
|
||||
/**
|
||||
* Function called when the control should be re-rendered. This is called
|
||||
* in a requestAnimationFrame callback.
|
||||
* @type {function(ol.MapEvent)|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.MousePositionOptions.prototype.render;
|
||||
|
||||
|
||||
/**
|
||||
* Target.
|
||||
* @type {Element|undefined}
|
||||
@@ -1050,6 +1100,7 @@ olx.control.MousePositionOptions.prototype.undefinedHTML;
|
||||
* collapsible: (boolean|undefined),
|
||||
* label: (string|undefined),
|
||||
* layers: (Array.<ol.layer.Layer>|ol.Collection|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
* target: (Element|undefined),
|
||||
* tipLabel: (string|undefined)}}
|
||||
* @api
|
||||
@@ -1099,6 +1150,15 @@ olx.control.OverviewMapOptions.prototype.label;
|
||||
olx.control.OverviewMapOptions.prototype.layers;
|
||||
|
||||
|
||||
/**
|
||||
* Function called when the control should be re-rendered. This is called
|
||||
* in a requestAnimationFrame callback.
|
||||
* @type {function(ol.MapEvent)|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.OverviewMapOptions.prototype.render;
|
||||
|
||||
|
||||
/**
|
||||
* Specify a target if you want the control to be rendered outside of the map's
|
||||
* viewport.
|
||||
@@ -1119,6 +1179,7 @@ olx.control.OverviewMapOptions.prototype.tipLabel;
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* minWidth: (number|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
* target: (Element|undefined),
|
||||
* units: (ol.control.ScaleLineUnits|string|undefined)}}
|
||||
* @api stable
|
||||
@@ -1142,6 +1203,15 @@ olx.control.ScaleLineOptions.prototype.className;
|
||||
olx.control.ScaleLineOptions.prototype.minWidth;
|
||||
|
||||
|
||||
/**
|
||||
* Function called when the control should be re-rendered. This is called
|
||||
* in a requestAnimationFrame callback.
|
||||
* @type {function(ol.MapEvent)|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.ScaleLineOptions.prototype.render;
|
||||
|
||||
|
||||
/**
|
||||
* Target.
|
||||
* @type {Element|undefined}
|
||||
@@ -1164,6 +1234,7 @@ olx.control.ScaleLineOptions.prototype.units;
|
||||
* label: (string|undefined),
|
||||
* tipLabel: (string|undefined),
|
||||
* target: (Element|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
* autoHide: (boolean|undefined)}}
|
||||
* @api stable
|
||||
*/
|
||||
@@ -1210,6 +1281,15 @@ olx.control.RotateOptions.prototype.duration;
|
||||
olx.control.RotateOptions.prototype.autoHide;
|
||||
|
||||
|
||||
/**
|
||||
* Function called when the control should be re-rendered. This is called
|
||||
* in a requestAnimationFrame callback.
|
||||
* @type {function(ol.MapEvent)|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.RotateOptions.prototype.render;
|
||||
|
||||
|
||||
/**
|
||||
* Target.
|
||||
* @type {Element|undefined}
|
||||
@@ -1299,8 +1379,9 @@ olx.control.ZoomOptions.prototype.target;
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* maxResolution: (number|undefined),
|
||||
* minResolution: (number|undefined)}}
|
||||
* @api stable
|
||||
* minResolution: (number|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined)}}
|
||||
* @api
|
||||
*/
|
||||
olx.control.ZoomSliderOptions;
|
||||
|
||||
@@ -1329,6 +1410,15 @@ olx.control.ZoomSliderOptions.prototype.maxResolution;
|
||||
olx.control.ZoomSliderOptions.prototype.minResolution;
|
||||
|
||||
|
||||
/**
|
||||
* Function called when the control should be re-rendered. This is called
|
||||
* in a requestAnimationFrame callback.
|
||||
* @type {function(ol.MapEvent)|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.ZoomSliderOptions.prototype.render;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* target: (Element|undefined),
|
||||
@@ -2339,6 +2429,24 @@ olx.interaction.PinchZoomOptions;
|
||||
olx.interaction.PinchZoomOptions.prototype.duration;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{handleEvent: function(ol.MapBrowserEvent):boolean}}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PointerOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Method called by the map to notify the interaction that a browser event was
|
||||
* dispatched to the map. The function may return `false` to prevent the
|
||||
* propagation of the event to other interactions in the map's interactions
|
||||
* chain.
|
||||
* @type {function(ol.MapBrowserEvent):boolean}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PointerOptions.prototype.handleEvent;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{addCondition: (ol.events.ConditionType|undefined),
|
||||
* condition: (ol.events.ConditionType|undefined),
|
||||
@@ -5967,7 +6075,8 @@ olx.style.TextOptions.prototype.stroke;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{fill: (ol.style.Fill|undefined),
|
||||
* @typedef {{geometry: (undefined|string|ol.geom.Geometry|ol.style.GeometryFunction),
|
||||
* fill: (ol.style.Fill|undefined),
|
||||
* image: (ol.style.Image|undefined),
|
||||
* stroke: (ol.style.Stroke|undefined),
|
||||
* text: (ol.style.Text|undefined),
|
||||
@@ -5977,6 +6086,15 @@ olx.style.TextOptions.prototype.stroke;
|
||||
olx.style.StyleOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Feature property or geometry or function returning a geometry to render for
|
||||
* this style.
|
||||
* @type {undefined|string|ol.geom.Geometry|ol.style.GeometryFunction}
|
||||
* @api
|
||||
*/
|
||||
olx.style.StyleOptions.prototype.geometry;
|
||||
|
||||
|
||||
/**
|
||||
* Fill style.
|
||||
* @type {ol.style.Fill|undefined}
|
||||
|
||||
@@ -113,8 +113,12 @@ ol.control.Attribution = function(opt_options) {
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV,
|
||||
cssClasses, this.ulElement_, button);
|
||||
|
||||
var render = goog.isDef(options.render) ?
|
||||
options.render : ol.control.Attribution.render;
|
||||
|
||||
goog.base(this, {
|
||||
element: element,
|
||||
render: render,
|
||||
target: options.target
|
||||
});
|
||||
|
||||
@@ -192,9 +196,11 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapEvent} mapEvent Map event.
|
||||
* @this {ol.control.Attribution}
|
||||
* @api
|
||||
*/
|
||||
ol.control.Attribution.prototype.handleMapPostrender = function(mapEvent) {
|
||||
ol.control.Attribution.render = function(mapEvent) {
|
||||
this.updateElement_(mapEvent.frameState);
|
||||
};
|
||||
|
||||
|
||||
@@ -66,6 +66,11 @@ ol.control.Control = function(options) {
|
||||
*/
|
||||
this.listenerKeys = [];
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapEvent)}
|
||||
*/
|
||||
this.render = goog.isDef(options.render) ? options.render : goog.nullFunction;
|
||||
|
||||
};
|
||||
goog.inherits(ol.control.Control, ol.Object);
|
||||
|
||||
@@ -89,15 +94,6 @@ ol.control.Control.prototype.getMap = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function called on each map render. Executes in a requestAnimationFrame
|
||||
* callback. Can be implemented in sub-classes to re-render the control's
|
||||
* UI.
|
||||
* @param {ol.MapEvent} mapEvent Map event.
|
||||
*/
|
||||
ol.control.Control.prototype.handleMapPostrender = goog.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
* Remove the control from its current map and attach it to the new map.
|
||||
* Subclasses may set up event handlers to get notified about changes to
|
||||
@@ -118,9 +114,9 @@ ol.control.Control.prototype.setMap = function(map) {
|
||||
var target = !goog.isNull(this.target_) ?
|
||||
this.target_ : map.getOverlayContainerStopEvent();
|
||||
goog.dom.appendChild(target, this.element);
|
||||
if (this.handleMapPostrender !== goog.nullFunction) {
|
||||
if (this.render !== goog.nullFunction) {
|
||||
this.listenerKeys.push(goog.events.listen(map,
|
||||
ol.MapEventType.POSTRENDER, this.handleMapPostrender, false, this));
|
||||
ol.MapEventType.POSTRENDER, this.render, false, this));
|
||||
}
|
||||
map.render();
|
||||
}
|
||||
|
||||
@@ -47,8 +47,12 @@ ol.control.MousePosition = function(opt_options) {
|
||||
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, className);
|
||||
|
||||
var render = goog.isDef(options.render) ?
|
||||
options.render : ol.control.MousePosition.render;
|
||||
|
||||
goog.base(this, {
|
||||
element: element,
|
||||
render: render,
|
||||
target: options.target
|
||||
});
|
||||
|
||||
@@ -99,9 +103,11 @@ goog.inherits(ol.control.MousePosition, ol.control.Control);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapEvent} mapEvent Map event.
|
||||
* @this {ol.control.MousePosition}
|
||||
* @api
|
||||
*/
|
||||
ol.control.MousePosition.prototype.handleMapPostrender = function(mapEvent) {
|
||||
ol.control.MousePosition.render = function(mapEvent) {
|
||||
var frameState = mapEvent.frameState;
|
||||
if (goog.isNull(frameState)) {
|
||||
this.mapProjection_ = null;
|
||||
|
||||
@@ -136,8 +136,12 @@ ol.control.OverviewMap = function(opt_options) {
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV,
|
||||
cssClasses, ovmapDiv, button);
|
||||
|
||||
var render = goog.isDef(options.render) ?
|
||||
options.render : ol.control.OverviewMap.render;
|
||||
|
||||
goog.base(this, {
|
||||
element: element,
|
||||
render: render,
|
||||
target: options.target
|
||||
});
|
||||
};
|
||||
@@ -201,12 +205,11 @@ ol.control.OverviewMap.prototype.bindView_ = function() {
|
||||
|
||||
|
||||
/**
|
||||
* Function called on each map render. Executes in a requestAnimationFrame
|
||||
* callback. Manage the extent of the overview map accordingly,
|
||||
* then update the overview map box.
|
||||
* @param {goog.events.Event} event Event.
|
||||
* @param {ol.MapEvent} mapEvent Map event.
|
||||
* @this {ol.control.OverviewMap}
|
||||
* @api
|
||||
*/
|
||||
ol.control.OverviewMap.prototype.handleMapPostrender = function(event) {
|
||||
ol.control.OverviewMap.render = function(mapEvent) {
|
||||
this.validateExtent_();
|
||||
this.updateBox_();
|
||||
};
|
||||
|
||||
@@ -62,8 +62,12 @@ ol.control.Rotate = function(opt_options) {
|
||||
ol.css.CLASS_CONTROL;
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, button);
|
||||
|
||||
var render = goog.isDef(options.render) ?
|
||||
options.render : ol.control.Rotate.render;
|
||||
|
||||
goog.base(this, {
|
||||
element: element,
|
||||
render: render,
|
||||
target: options.target
|
||||
});
|
||||
|
||||
@@ -135,9 +139,11 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapEvent} mapEvent Map event.
|
||||
* @this {ol.control.Rotate}
|
||||
* @api
|
||||
*/
|
||||
ol.control.Rotate.prototype.handleMapPostrender = function(mapEvent) {
|
||||
ol.control.Rotate.render = function(mapEvent) {
|
||||
var frameState = mapEvent.frameState;
|
||||
if (goog.isNull(frameState)) {
|
||||
return;
|
||||
|
||||
@@ -112,8 +112,12 @@ ol.control.ScaleLine = function(opt_options) {
|
||||
*/
|
||||
this.toEPSG4326_ = null;
|
||||
|
||||
var render = goog.isDef(options.render) ?
|
||||
options.render : ol.control.ScaleLine.render;
|
||||
|
||||
goog.base(this, {
|
||||
element: this.element_,
|
||||
render: render,
|
||||
target: options.target
|
||||
});
|
||||
|
||||
@@ -152,9 +156,11 @@ goog.exportProperty(
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapEvent} mapEvent Map event.
|
||||
* @this {ol.control.ScaleLine}
|
||||
* @api
|
||||
*/
|
||||
ol.control.ScaleLine.prototype.handleMapPostrender = function(mapEvent) {
|
||||
ol.control.ScaleLine.render = function(mapEvent) {
|
||||
var frameState = mapEvent.frameState;
|
||||
if (goog.isNull(frameState)) {
|
||||
this.viewState_ = null;
|
||||
|
||||
@@ -100,8 +100,12 @@ ol.control.ZoomSlider = function(opt_options) {
|
||||
goog.events.listen(thumbElement, goog.events.EventType.CLICK,
|
||||
goog.events.Event.stopPropagation);
|
||||
|
||||
var render = goog.isDef(options.render) ?
|
||||
options.render : ol.control.ZoomSlider.render;
|
||||
|
||||
goog.base(this, {
|
||||
element: containerElement
|
||||
element: containerElement,
|
||||
render: render
|
||||
});
|
||||
};
|
||||
goog.inherits(ol.control.ZoomSlider, ol.control.Control);
|
||||
@@ -166,9 +170,11 @@ ol.control.ZoomSlider.prototype.initSlider_ = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapEvent} mapEvent Map event.
|
||||
* @this {ol.control.ZoomSlider}
|
||||
* @api
|
||||
*/
|
||||
ol.control.ZoomSlider.prototype.handleMapPostrender = function(mapEvent) {
|
||||
ol.control.ZoomSlider.render = function(mapEvent) {
|
||||
if (goog.isNull(mapEvent.frameState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -544,8 +544,8 @@ ol.format.GMLBase.prototype.readFeatures;
|
||||
ol.format.GMLBase.prototype.readFeaturesFromNode =
|
||||
function(node, opt_options) {
|
||||
var options = {
|
||||
'featureType': this.featureType,
|
||||
'featureNS': this.featureNS
|
||||
featureType: this.featureType,
|
||||
featureNS: this.featureNS
|
||||
};
|
||||
if (goog.isDef(opt_options)) {
|
||||
goog.object.extend(options, this.getReadOptions(node, opt_options));
|
||||
|
||||
@@ -26,7 +26,9 @@ ol.interaction.DoubleClickZoom = function(opt_options) {
|
||||
*/
|
||||
this.delta_ = goog.isDef(options.delta) ? options.delta : 1;
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.DoubleClickZoom.handleEvent
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -39,10 +41,12 @@ goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.DoubleClickZoom}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.DoubleClickZoom.prototype.handleMapBrowserEvent =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
|
||||
var stopEvent = false;
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DBLCLICK) {
|
||||
|
||||
@@ -29,7 +29,9 @@ ol.interaction.DragAndDrop = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.DragAndDrop.handleEvent
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -133,10 +135,12 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.DragAndDrop}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.DragAndDrop.prototype.handleMapBrowserEvent =
|
||||
goog.functions.TRUE;
|
||||
ol.interaction.DragAndDrop.handleEvent = goog.functions.TRUE;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,7 +85,9 @@ goog.inherits(ol.DrawEvent, goog.events.Event);
|
||||
*/
|
||||
ol.interaction.Draw = function(options) {
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.Draw.handleEvent
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {ol.Pixel}
|
||||
@@ -236,20 +238,23 @@ ol.interaction.Draw.prototype.setMap = function(map) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.Draw}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Draw.prototype.handleMapBrowserEvent = function(event) {
|
||||
var map = event.map;
|
||||
ol.interaction.Draw.handleEvent = function(mapBrowserEvent) {
|
||||
var map = mapBrowserEvent.map;
|
||||
if (!map.isDef()) {
|
||||
return true;
|
||||
}
|
||||
var pass = true;
|
||||
if (event.type === ol.MapBrowserEvent.EventType.POINTERMOVE) {
|
||||
pass = this.handlePointerMove_(event);
|
||||
} else if (event.type === ol.MapBrowserEvent.EventType.DBLCLICK) {
|
||||
if (mapBrowserEvent.type === ol.MapBrowserEvent.EventType.POINTERMOVE) {
|
||||
pass = this.handlePointerMove_(mapBrowserEvent);
|
||||
} else if (mapBrowserEvent.type === ol.MapBrowserEvent.EventType.DBLCLICK) {
|
||||
pass = false;
|
||||
}
|
||||
return (goog.base(this, 'handleMapBrowserEvent', event) && pass);
|
||||
return ol.interaction.Pointer.handleEvent.call(this, mapBrowserEvent) && pass;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ ol.interaction.InteractionProperty = {
|
||||
* vectors and so are visible on the screen.
|
||||
*
|
||||
* @constructor
|
||||
* @param {olx.interaction.InteractionOptions} options Options.
|
||||
* @extends {ol.Object}
|
||||
* @implements {oli.interaction.Interaction}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Interaction = function() {
|
||||
ol.interaction.Interaction = function(options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
@@ -48,6 +48,11 @@ ol.interaction.Interaction = function() {
|
||||
|
||||
this.setActive(true);
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapBrowserEvent):boolean}
|
||||
*/
|
||||
this.handleEvent = options.handleEvent;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.Interaction, ol.Object);
|
||||
|
||||
@@ -76,22 +81,6 @@ ol.interaction.Interaction.prototype.getMap = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Method called by the map to notify the interaction that a browser
|
||||
* event was dispatched on the map. If the interaction wants to handle
|
||||
* that event it can return `false` to prevent the propagation of the
|
||||
* event to other interactions in the map's interactions chain.
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} Whether the map browser event should continue
|
||||
* through the chain of interactions. `false` means stop, `true`
|
||||
* means continue.
|
||||
* @function
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Interaction.prototype.handleMapBrowserEvent =
|
||||
goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* Activate or deactivate the interaction.
|
||||
* @param {boolean} active Active.
|
||||
|
||||
@@ -31,7 +31,9 @@ goog.require('ol.interaction.Interaction');
|
||||
*/
|
||||
ol.interaction.KeyboardPan = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.KeyboardPan.handleEvent
|
||||
});
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
@@ -54,10 +56,12 @@ goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.KeyboardPan}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) {
|
||||
var stopEvent = false;
|
||||
if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) {
|
||||
var keyEvent = /** @type {goog.events.KeyEvent} */
|
||||
|
||||
@@ -27,7 +27,9 @@ goog.require('ol.interaction.Interaction');
|
||||
*/
|
||||
ol.interaction.KeyboardZoom = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.KeyboardZoom.handleEvent
|
||||
});
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
@@ -55,10 +57,12 @@ goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.KeyboardZoom}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
|
||||
var stopEvent = false;
|
||||
if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) {
|
||||
var keyEvent = /** @type {goog.events.KeyEvent} */
|
||||
|
||||
@@ -47,8 +47,9 @@ ol.interaction.SegmentDataType;
|
||||
*/
|
||||
ol.interaction.Modify = function(options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.Modify.handleEvent
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {ol.events.ConditionType}
|
||||
@@ -433,6 +434,10 @@ ol.interaction.Modify.prototype.handlePointerDrag = function(evt) {
|
||||
var segment = segmentData.segment;
|
||||
var index = dragSegment[1];
|
||||
|
||||
while (vertex.length < geometry.getStride()) {
|
||||
vertex.push(0);
|
||||
}
|
||||
|
||||
switch (geometry.getType()) {
|
||||
case ol.geom.GeometryType.POINT:
|
||||
coordinates = vertex;
|
||||
@@ -481,10 +486,12 @@ ol.interaction.Modify.prototype.handlePointerUp = function(evt) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.Modify}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Modify.prototype.handleMapBrowserEvent =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
|
||||
var handled;
|
||||
if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] &&
|
||||
mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE) {
|
||||
@@ -496,7 +503,8 @@ ol.interaction.Modify.prototype.handleMapBrowserEvent =
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point);
|
||||
handled = this.removeVertex_();
|
||||
}
|
||||
return goog.base(this, 'handleMapBrowserEvent', mapBrowserEvent) && !handled;
|
||||
return ol.interaction.Pointer.handleEvent.call(this, mapBrowserEvent) &&
|
||||
!handled;
|
||||
};
|
||||
|
||||
|
||||
@@ -588,6 +596,10 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
|
||||
var index = segmentData.index;
|
||||
var coordinates;
|
||||
|
||||
while (vertex.length < geometry.getStride()) {
|
||||
vertex.push(0);
|
||||
}
|
||||
|
||||
switch (geometry.getType()) {
|
||||
case ol.geom.GeometryType.MULTI_LINE_STRING:
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString);
|
||||
|
||||
@@ -21,9 +21,11 @@ goog.require('ol.interaction.Interaction');
|
||||
*/
|
||||
ol.interaction.MouseWheelZoom = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.MouseWheelZoom.handleEvent
|
||||
});
|
||||
|
||||
goog.base(this);
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -60,10 +62,12 @@ goog.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.MouseWheelZoom}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
||||
var stopEvent = false;
|
||||
if (mapBrowserEvent.type ==
|
||||
goog.events.MouseWheelHandler.EventType.MOUSEWHEEL) {
|
||||
|
||||
@@ -17,11 +17,20 @@ goog.require('ol.interaction.Interaction');
|
||||
* instantiated in apps.
|
||||
*
|
||||
* @constructor
|
||||
* @param {olx.interaction.PointerOptions=} opt_options Options.
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Pointer = function() {
|
||||
ol.interaction.Pointer = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
var handleEvent = goog.isDef(options.handleEvent) ?
|
||||
options.handleEvent : ol.interaction.Pointer.handleEvent;
|
||||
|
||||
goog.base(this, {
|
||||
handleEvent: handleEvent
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
@@ -124,10 +133,12 @@ ol.interaction.Pointer.prototype.handlePointerDown = goog.functions.FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.Pointer}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Pointer.prototype.handleMapBrowserEvent =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.Pointer.handleEvent = function(mapBrowserEvent) {
|
||||
if (!(mapBrowserEvent instanceof ol.MapBrowserPointerEvent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ goog.require('ol.style.Style');
|
||||
*/
|
||||
ol.interaction.Select = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.Select.handleEvent
|
||||
});
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
@@ -115,10 +117,12 @@ ol.interaction.Select.prototype.getFeatures = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @return {boolean} `false` to stop event propagation.
|
||||
* @this {ol.interaction.Select}
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Select.prototype.handleMapBrowserEvent =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
|
||||
if (!this.condition_(mapBrowserEvent)) {
|
||||
return true;
|
||||
}
|
||||
@@ -179,7 +183,7 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
|
||||
}
|
||||
features.extend(selected);
|
||||
}
|
||||
return this.condition_ == ol.events.condition.mouseMove;
|
||||
return ol.events.condition.mouseMove(mapBrowserEvent);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ ol.Map = function(options) {
|
||||
* @private
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
this.previousExtent_ = null;
|
||||
this.previousExtent_ = ol.extent.createEmpty();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -870,7 +870,7 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
|
||||
if (!interaction.getActive()) {
|
||||
continue;
|
||||
}
|
||||
var cont = interaction.handleMapBrowserEvent(mapBrowserEvent);
|
||||
var cont = interaction.handleEvent(mapBrowserEvent);
|
||||
if (!cont) {
|
||||
break;
|
||||
}
|
||||
@@ -1261,13 +1261,12 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
||||
var idle = this.preRenderFunctions_.length === 0 &&
|
||||
!frameState.viewHints[ol.ViewHint.ANIMATING] &&
|
||||
!frameState.viewHints[ol.ViewHint.INTERACTING] &&
|
||||
(!this.previousExtent_ ||
|
||||
!ol.extent.equals(frameState.extent, this.previousExtent_));
|
||||
!ol.extent.equals(frameState.extent, this.previousExtent_);
|
||||
|
||||
if (idle) {
|
||||
this.dispatchEvent(
|
||||
new ol.MapEvent(ol.MapEventType.MOVEEND, this, frameState));
|
||||
this.previousExtent_ = ol.extent.clone(frameState.extent);
|
||||
ol.extent.clone(frameState.extent, this.previousExtent_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ ol.Overlay.prototype.handleMapChanged = function() {
|
||||
var map = this.getMap();
|
||||
if (goog.isDefAndNotNull(map)) {
|
||||
this.mapPostrenderListenerKey_ = goog.events.listen(map,
|
||||
ol.MapEventType.POSTRENDER, this.handleMapPostrender, false, this);
|
||||
ol.MapEventType.POSTRENDER, this.render, false, this);
|
||||
this.updatePixelPosition_();
|
||||
var container = this.stopEvent_ ?
|
||||
map.getOverlayContainerStopEvent() : map.getOverlayContainer();
|
||||
@@ -273,7 +273,7 @@ ol.Overlay.prototype.handleMapChanged = function() {
|
||||
/**
|
||||
* @protected
|
||||
*/
|
||||
ol.Overlay.prototype.handleMapPostrender = function() {
|
||||
ol.Overlay.prototype.render = function() {
|
||||
this.updatePixelPosition_();
|
||||
};
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ ol.render.canvas.Immediate.prototype.drawCircleGeometry =
|
||||
* @api
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawFeature = function(feature, style) {
|
||||
var geometry = feature.getGeometry();
|
||||
var geometry = style.getGeometryFunction()(feature);
|
||||
if (!goog.isDefAndNotNull(geometry) ||
|
||||
!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||
return;
|
||||
|
||||
@@ -1957,9 +1957,9 @@ ol.render.canvas.ReplayGroup.prototype.replay = function(
|
||||
var minY = maxExtent[1];
|
||||
var maxX = maxExtent[2];
|
||||
var maxY = maxExtent[3];
|
||||
var flatClipCoords = ol.geom.flat.transform.transform2D(
|
||||
[minX, minY, minX, maxY, maxX, maxY, maxX, minY],
|
||||
0, 8, 2, transform);
|
||||
var flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
|
||||
ol.geom.flat.transform.transform2D(
|
||||
flatClipCoords, 0, 8, 2, transform, flatClipCoords);
|
||||
context.save();
|
||||
context.beginPath();
|
||||
context.moveTo(flatClipCoords[0], flatClipCoords[1]);
|
||||
|
||||
@@ -123,7 +123,7 @@ ol.renderer.vector.renderFeature = function(
|
||||
*/
|
||||
ol.renderer.vector.renderFeature_ = function(
|
||||
replayGroup, feature, style, squaredTolerance) {
|
||||
var geometry = feature.getGeometry();
|
||||
var geometry = style.getGeometryFunction()(feature);
|
||||
if (!goog.isDefAndNotNull(geometry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ ol.render.webgl.Immediate.prototype.drawCircleGeometry =
|
||||
* @api
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) {
|
||||
var geometry = feature.getGeometry();
|
||||
var geometry = style.getGeometryFunction()(feature);
|
||||
if (!goog.isDefAndNotNull(geometry) ||
|
||||
!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||
return;
|
||||
|
||||
@@ -70,6 +70,7 @@ ol.style.Image = function(options) {
|
||||
|
||||
/**
|
||||
* @return {number} Opacity.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Image.prototype.getOpacity = function() {
|
||||
return this.opacity_;
|
||||
@@ -78,6 +79,7 @@ ol.style.Image.prototype.getOpacity = function() {
|
||||
|
||||
/**
|
||||
* @return {boolean} Rotate with map.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Image.prototype.getRotateWithView = function() {
|
||||
return this.rotateWithView_;
|
||||
@@ -104,6 +106,7 @@ ol.style.Image.prototype.getScale = function() {
|
||||
|
||||
/**
|
||||
* @return {boolean} Snap to pixel?
|
||||
* @api
|
||||
*/
|
||||
ol.style.Image.prototype.getSnapToPixel = function() {
|
||||
return this.snapToPixel_;
|
||||
|
||||
@@ -151,6 +151,15 @@ ol.style.RegularShape.prototype.getAnchor = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} Shape's rotation in radians.
|
||||
* @api
|
||||
*/
|
||||
ol.style.RegularShape.prototype.getAngle = function() {
|
||||
return this.angle_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.style.Fill} Fill style.
|
||||
* @api
|
||||
@@ -218,6 +227,15 @@ ol.style.RegularShape.prototype.getHitDetectionOrigin = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} Number of points for stars and regular polygons.
|
||||
* @api
|
||||
*/
|
||||
ol.style.RegularShape.prototype.getPoints = function() {
|
||||
return this.points_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} Radius.
|
||||
* @api
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
goog.provide('ol.style.Style');
|
||||
goog.provide('ol.style.defaultGeometryFunction');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.style.Circle');
|
||||
goog.require('ol.style.Fill');
|
||||
@@ -24,6 +26,22 @@ ol.style.Style = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string|ol.geom.Geometry|ol.style.GeometryFunction}
|
||||
*/
|
||||
this.geometry_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!ol.style.GeometryFunction}
|
||||
*/
|
||||
this.geometryFunction_ = ol.style.defaultGeometryFunction;
|
||||
|
||||
if (goog.isDef(options.geometry)) {
|
||||
this.setGeometry(options.geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.Fill}
|
||||
@@ -57,6 +75,27 @@ ol.style.Style = function(opt_options) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|ol.geom.Geometry|ol.style.GeometryFunction}
|
||||
* Feature property or geometry or function that returns the geometry that will
|
||||
* be rendered with this style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getGeometry = function() {
|
||||
return this.geometry_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {!ol.style.GeometryFunction} Function that is called with a feature
|
||||
* and returns the geometry to render instead of the feature's geometry.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.getGeometryFunction = function() {
|
||||
return this.geometryFunction_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.style.Fill} Fill style.
|
||||
* @api
|
||||
@@ -102,6 +141,37 @@ ol.style.Style.prototype.getZIndex = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set a geometry that is rendered instead of the feature's geometry.
|
||||
*
|
||||
* @param {string|ol.geom.Geometry|ol.style.GeometryFunction} geometry
|
||||
* Feature property or geometry or function returning a geometry to render
|
||||
* for this style.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Style.prototype.setGeometry = function(geometry) {
|
||||
if (goog.isFunction(geometry)) {
|
||||
this.geometryFunction_ = geometry;
|
||||
} else if (goog.isString(geometry)) {
|
||||
this.geometryFunction_ = function(feature) {
|
||||
var result = feature.get(geometry);
|
||||
if (goog.isDefAndNotNull(result)) {
|
||||
goog.asserts.assertInstanceof(result, ol.geom.Geometry);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
} else if (goog.isNull(geometry)) {
|
||||
this.geometryFunction_ = ol.style.defaultGeometryFunction;
|
||||
} else if (goog.isDef(geometry)) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry);
|
||||
this.geometryFunction_ = function() {
|
||||
return geometry;
|
||||
};
|
||||
}
|
||||
this.geometry_ = geometry;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the zIndex.
|
||||
*
|
||||
@@ -264,3 +334,24 @@ ol.style.createDefaultEditingStyles = function() {
|
||||
|
||||
return styles;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A function that takes an {@link ol.Feature} as argument and returns an
|
||||
* {@link ol.geom.Geometry} that will be rendered and styled for the feature.
|
||||
*
|
||||
* @typedef {function(ol.Feature): (ol.geom.Geometry|undefined)}
|
||||
* @api
|
||||
*/
|
||||
ol.style.GeometryFunction;
|
||||
|
||||
|
||||
/**
|
||||
* Function that is called with a feature and returns its default geometry.
|
||||
* @param {ol.Feature} feature Feature to get the geometry for.
|
||||
* @return {ol.geom.Geometry|undefined} Geometry to render.
|
||||
*/
|
||||
ol.style.defaultGeometryFunction = function(feature) {
|
||||
goog.asserts.assert(!goog.isNull(feature));
|
||||
return feature.getGeometry();
|
||||
};
|
||||
|
||||
@@ -71,15 +71,15 @@ ol.tilecoord.createFromString = function(str) {
|
||||
* @param {number} z Z.
|
||||
* @param {number} x X.
|
||||
* @param {number} y Y.
|
||||
* @param {ol.TileCoord|undefined} tileCoord Tile coordinate.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Tile coordinate.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
ol.tilecoord.createOrUpdate = function(z, x, y, tileCoord) {
|
||||
if (goog.isDef(tileCoord)) {
|
||||
tileCoord[0] = z;
|
||||
tileCoord[1] = x;
|
||||
tileCoord[2] = y;
|
||||
return tileCoord;
|
||||
ol.tilecoord.createOrUpdate = function(z, x, y, opt_tileCoord) {
|
||||
if (goog.isDef(opt_tileCoord)) {
|
||||
opt_tileCoord[0] = z;
|
||||
opt_tileCoord[1] = x;
|
||||
opt_tileCoord[2] = y;
|
||||
return opt_tileCoord;
|
||||
} else {
|
||||
return [z, x, y];
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ function getInfoTime(callback) {
|
||||
|
||||
|
||||
/**
|
||||
* Test whether externs/olx.js is newer than the provided date.
|
||||
* Test whether any externs are newer than the provided date.
|
||||
* @param {Date} date Modification time of info file.
|
||||
* @param {function(Error, Date, boolen)} callback Called with any
|
||||
* error, the mtime of the info file (zero date if it doesn't exist), and
|
||||
* whether externs/olx.js is newer than that date.
|
||||
* whether any externs are newer than that date.
|
||||
*/
|
||||
function getNewerExterns(date, callback) {
|
||||
var newer = false;
|
||||
@@ -58,7 +58,7 @@ function getNewerExterns(date, callback) {
|
||||
next();
|
||||
});
|
||||
walker.on('errors', function() {
|
||||
callback(new Error('Trouble walking ' + sourceDir));
|
||||
callback(new Error('Trouble walking ' + externsDir));
|
||||
});
|
||||
walker.on('end', function() {
|
||||
callback(null, date, newer);
|
||||
@@ -70,7 +70,7 @@ function getNewerExterns(date, callback) {
|
||||
* Generate a list of all .js paths in the source directory if any are newer
|
||||
* than the provided date.
|
||||
* @param {Date} date Modification time of info file.
|
||||
* @param {boolean} newer Whether externs/olx.js is newer than date.
|
||||
* @param {boolean} newer Whether any externs are newer than date.
|
||||
* @param {function(Error, Array.<string>)} callback Called with any
|
||||
* error and the array of source paths (empty if none newer).
|
||||
*/
|
||||
|
||||
41
test/spec/ol/format/gml/only-boundedby.xml
Normal file
41
test/spec/ol/format/gml/only-boundedby.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<wfs:FeatureCollection numberOfFeatures="3" timeStamp="2008-09-12T00:24:21.013-04:00"
|
||||
xsi:schemaLocation="http://www.openplans.org/topp http://sigma.openplans.org:80/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=topp:states http://www.opengis.net/wfs http://sigma.openplans.org:80/geoserver/schemas/wfs/1.1.0/wfs.xsd"
|
||||
xmlns:ogc="http://www.opengis.net/ogc" xmlns:opengeo="http://open-geo.com"
|
||||
xmlns:tiger="http://www.census.gov" xmlns:wfs="http://www.opengis.net/wfs"
|
||||
xmlns:topp="http://www.openplans.org/topp" xmlns:seb="http://seb.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows"
|
||||
xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<gml:featureMembers>
|
||||
<topp:states gml:id="states.1">
|
||||
<gml:boundedBy>
|
||||
<gml:Envelope srsName="urn:x-ogc:def:crs:EPSG:4326">
|
||||
<gml:lowerCorner>36.986 -91.516</gml:lowerCorner>
|
||||
<gml:upperCorner>42.509 -87.507</gml:upperCorner>
|
||||
</gml:Envelope>
|
||||
</gml:boundedBy>
|
||||
<topp:STATE_NAME>Illinois</topp:STATE_NAME>
|
||||
<topp:STATE_FIPS>17</topp:STATE_FIPS>
|
||||
<topp:SUB_REGION>E N Cen</topp:SUB_REGION>
|
||||
<topp:STATE_ABBR>IL</topp:STATE_ABBR>
|
||||
<topp:LAND_KM>143986.61</topp:LAND_KM>
|
||||
<topp:WATER_KM>1993.335</topp:WATER_KM>
|
||||
<topp:PERSONS>1.143E7</topp:PERSONS>
|
||||
<topp:FAMILIES>2924880.0</topp:FAMILIES>
|
||||
<topp:HOUSHOLD>4202240.0</topp:HOUSHOLD>
|
||||
<topp:MALE>5552233.0</topp:MALE>
|
||||
<topp:FEMALE>5878369.0</topp:FEMALE>
|
||||
<topp:WORKERS>4199206.0</topp:WORKERS>
|
||||
<topp:DRVALONE>3741715.0</topp:DRVALONE>
|
||||
<topp:CARPOOL>652603.0</topp:CARPOOL>
|
||||
<topp:PUBTRANS>538071.0</topp:PUBTRANS>
|
||||
<topp:EMPLOYED>5417967.0</topp:EMPLOYED>
|
||||
<topp:UNEMPLOY>385040.0</topp:UNEMPLOY>
|
||||
<topp:SERVICE>1360159.0</topp:SERVICE>
|
||||
<topp:MANUAL>828906.0</topp:MANUAL>
|
||||
<topp:P_MALE>0.486</topp:P_MALE>
|
||||
<topp:P_FEMALE>0.514</topp:P_FEMALE>
|
||||
<topp:SAMP_POP>1747776.0</topp:SAMP_POP>
|
||||
</topp:states>
|
||||
</gml:featureMembers>
|
||||
</wfs:FeatureCollection>
|
||||
@@ -1066,6 +1066,27 @@ describe('ol.format.GML3', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('when parsing only a boundedBy element and no geometry', function() {
|
||||
|
||||
var features;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/gml/only-boundedby.xml', function(xml) {
|
||||
try {
|
||||
features = new ol.format.GML().readFeatures(xml);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a feature without a geometry', function() {
|
||||
var feature = features[0];
|
||||
expect(feature.getGeometry()).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('ol.interaction.Interaction', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Interaction();
|
||||
interaction = new ol.interaction.Interaction({});
|
||||
});
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
@@ -24,13 +24,13 @@ describe('ol.interaction.Interaction', function() {
|
||||
|
||||
it('retrieves the associated map', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
interaction.setMap(map);
|
||||
expect(interaction.getMap()).to.be(map);
|
||||
});
|
||||
|
||||
it('returns null if no map', function() {
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
expect(interaction.getMap()).to.be(null);
|
||||
});
|
||||
|
||||
@@ -40,13 +40,13 @@ describe('ol.interaction.Interaction', function() {
|
||||
|
||||
it('allows a map to be set', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
interaction.setMap(map);
|
||||
expect(interaction.getMap()).to.be(map);
|
||||
});
|
||||
|
||||
it('accepts null', function() {
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
interaction.setMap(null);
|
||||
expect(interaction.getMap()).to.be(null);
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('ol.Map', function() {
|
||||
describe('#addInteraction()', function() {
|
||||
it('adds an interaction to the map', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
|
||||
var before = map.getInteractions().getLength();
|
||||
map.addInteraction(interaction);
|
||||
@@ -36,7 +36,7 @@ describe('ol.Map', function() {
|
||||
describe('#removeInteraction()', function() {
|
||||
it('removes an interaction from the map', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
|
||||
var before = map.getInteractions().getLength();
|
||||
map.addInteraction(interaction);
|
||||
|
||||
@@ -11,6 +11,53 @@ describe('ol.style.Style', function() {
|
||||
expect(style.getZIndex()).to.be(0.7);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setGeometry', function() {
|
||||
var style = new ol.style.Style();
|
||||
|
||||
it('creates a geometry function from a string', function() {
|
||||
var feature = new ol.Feature();
|
||||
feature.set('myGeom', new ol.geom.Point([0, 0]));
|
||||
style.setGeometry('myGeom');
|
||||
expect(style.getGeometryFunction()(feature))
|
||||
.to.eql(feature.get('myGeom'));
|
||||
});
|
||||
|
||||
it('creates a geometry function from a geometry', function() {
|
||||
var geom = new ol.geom.Point([0, 0]);
|
||||
style.setGeometry(geom);
|
||||
expect(style.getGeometryFunction()())
|
||||
.to.eql(geom);
|
||||
});
|
||||
|
||||
it('returns the configured geometry function', function() {
|
||||
var geom = new ol.geom.Point([0, 0]);
|
||||
style.setGeometry(function() {
|
||||
return geom;
|
||||
});
|
||||
expect(style.getGeometryFunction()())
|
||||
.to.eql(geom);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getGeometry', function() {
|
||||
|
||||
it('returns whatever was passed to setGeometry', function() {
|
||||
var style = new ol.style.Style();
|
||||
style.setGeometry('foo');
|
||||
expect(style.getGeometry()).to.eql('foo');
|
||||
var geom = new ol.geom.Point([1, 2]);
|
||||
style.setGeometry(geom);
|
||||
expect(style.getGeometry()).to.eql(geom);
|
||||
var fn = function() { return geom; };
|
||||
style.setGeometry(fn);
|
||||
expect(style.getGeometry()).to.eql(fn);
|
||||
style.setGeometry(null);
|
||||
expect(style.getGeometry()).to.eql(null);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.style.createStyleFunction()', function() {
|
||||
@@ -42,4 +89,6 @@ describe('ol.style.createStyleFunction()', function() {
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.style.Style');
|
||||
|
||||
Reference in New Issue
Block a user