Permalink
Browse files

Lint free examples

  • Loading branch information...
1 parent 0555bb0 commit 8c38d22b60bea2324e6e0b10b7c213df6896d3ce @tschaub tschaub committed Jan 9, 2016
Showing with 423 additions and 483 deletions.
  1. +2 −0 .eslintignore
  2. +17 −0 examples/.eslintrc
  3. +1 −1 examples/attributions.js
  4. +6 −7 examples/blend-modes.js
  5. +2 −2 examples/box-selection.js
  6. +5 −36 examples/center.js
  7. +1 −5 examples/cluster.js
  8. +2 −1 examples/color-manipulation.js
  9. +1 −1 examples/custom-controls.js
  10. +3 −11 examples/custom-interactions.js
  11. +1 −1 examples/d3.js
  12. +1 −1 examples/device-orientation.js
  13. +1 −1 examples/drag-and-drop-image-vector.js
  14. +1 −1 examples/drag-and-drop.js
  15. +4 −5 examples/draw-and-modify-features.js
  16. +2 −3 examples/draw-features.js
  17. +5 −4 examples/earthquake-clusters.js
  18. +3 −3 examples/earthquake-custom-symbol.js
  19. +1 −1 examples/export-map.js
  20. +2 −2 examples/export-pdf.js
  21. +6 −5 examples/feature-move-animation.js
  22. +11 −10 examples/flight-animation.js
  23. +59 −71 examples/geojson.js
  24. +2 −2 examples/geolocation-orientation.js
  25. +1 −1 examples/geolocation.js
  26. +1 −1 examples/getfeatureinfo-image.js
  27. +1 −1 examples/getfeatureinfo-tile.js
  28. +2 −5 examples/gpx.js
  29. +6 −4 examples/icon-negative.js
  30. +3 −3 examples/icon-sprite-webgl.js
  31. +1 −1 examples/icon.js
  32. +1 −1 examples/igc.js
  33. +3 −3 examples/image-load-events.js
  34. +1 −1 examples/image-vector-layer.js
  35. +2 −2 examples/kml-earthquakes.js
  36. +2 −2 examples/kml-timezones.js
  37. +1 −1 examples/kml.js
  38. +1 −1 examples/line-arrows.js
  39. +64 −64 examples/measure.js
  40. +72 −85 examples/modify-test.js
  41. +3 −3 examples/osm-vector-tiles.js
  42. +28 −33 examples/polygon-styles.js
  43. +11 −11 examples/popup.js
  44. +6 −0 examples/raster.js
  45. +4 −4 examples/region-growing.js
  46. +2 −2 examples/render-geometry.js
  47. +6 −5 examples/reprojection-by-code.js
  48. +8 −8 examples/reprojection.js
  49. +10 −10 examples/side-by-side.js
  50. +1 −2 examples/snap.js
  51. +1 −1 examples/sphere-mollweide.js
  52. +1 −1 examples/synthetic-points.js
  53. +3 −3 examples/tile-load-events.js
  54. +1 −1 examples/topojson.js
  55. +26 −27 examples/vector-esri-edit.js
  56. +2 −2 examples/vector-esri.js
  57. +2 −1 examples/vector-labels.js
  58. +1 −1 examples/vector-layer.js
  59. +1 −1 examples/vector-osm.js
  60. +1 −1 examples/vector-wfs.js
  61. +0 −13 examples/wms-custom-proj.js
  62. +1 −1 examples/zoomify.js
  63. +1 −1 examples/zoomslider.js
  64. +2 −1 package.json
View
@@ -0,0 +1,2 @@
+examples/Jugl.js
+examples/resources/
View
@@ -0,0 +1,17 @@
+{
+ "globals": {
+ "FastClick": false,
+ "$": false,
+ "arc": false,
+ "common": false,
+ "createMapboxStreetsV6Style": false,
+ "d3": false,
+ "jsPDF": false,
+ "jsts": false,
+ "topojson": false,
+ "turf": false
+ },
+ "rules": {
+ "no-unused-vars": [2, {"varsIgnorePattern": "^map"}]
+ }
+}
@@ -14,7 +14,7 @@ var map = new ol.Map({
source: new ol.source.OSM()
})
],
- controls: ol.control.defaults({ attribution: false }).extend([attribution]),
+ controls: ol.control.defaults({attribution: false}).extend([attribution]),
renderer: common.getRendererFromQueryString(),
target: 'map',
view: new ol.View({
@@ -85,8 +85,13 @@ var map = new ol.Map({
})
});
+// Get the form elements and bind the listeners
+var select = document.getElementById('blend-mode');
+var affectRed = document.getElementById('affect-red');
+var affectGreen = document.getElementById('affect-green');
+var affectBlue = document.getElementById('affect-blue');
+
-// Various helper methods and event handlers
/**
* This method sets the globalCompositeOperation to the value of the select
* field and it is bound to the precompose event of the layers.
@@ -154,12 +159,6 @@ var affectLayerClicked = function() {
};
-// Get the form elements and bind the listeners
-var select = document.getElementById('blend-mode');
-var affectRed = document.getElementById('affect-red');
-var affectGreen = document.getElementById('affect-green');
-var affectBlue = document.getElementById('affect-blue');
-
// Rerender map when blend mode changes
select.addEventListener('change', function() {
map.render();
@@ -48,7 +48,7 @@ map.addInteraction(dragBox);
var infoBox = document.getElementById('info');
-dragBox.on('boxend', function(e) {
+dragBox.on('boxend', function() {
// features that intersect the box are added to the collection of
// selected features, and their names are displayed in the "info"
// div
@@ -64,7 +64,7 @@ dragBox.on('boxend', function(e) {
});
// clear selection when drawing a new box and when clicking on the map
-dragBox.on('boxstart', function(e) {
+dragBox.on('boxstart', function() {
selectedFeatures.clear();
infoBox.innerHTML = ' ';
});
View
@@ -65,14 +65,7 @@ zoomtoswitzerlandbest.addEventListener('click', function() {
var feature = source.getFeatures()[0];
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
var size = /** @type {ol.Size} */ (map.getSize());
- view.fit(
- polygon,
- size,
- {
- padding: [170, 50, 30, 150],
- constrainResolution: false
- }
- );
+ view.fit(polygon, size, {padding: [170, 50, 30, 150], constrainResolution: false});
}, false);
var zoomtoswitzerlandconstrained =
@@ -81,13 +74,7 @@ zoomtoswitzerlandconstrained.addEventListener('click', function() {
var feature = source.getFeatures()[0];
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
var size = /** @type {ol.Size} */ (map.getSize());
- view.fit(
- polygon,
- size,
- {
- padding: [170, 50, 30, 150]
- }
- );
+ view.fit(polygon, size, {padding: [170, 50, 30, 150]});
}, false);
var zoomtoswitzerlandnearest =
@@ -96,39 +83,21 @@ zoomtoswitzerlandnearest.addEventListener('click', function() {
var feature = source.getFeatures()[0];
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
var size = /** @type {ol.Size} */ (map.getSize());
- view.fit(
- polygon,
- size,
- {
- padding: [170, 50, 30, 150],
- nearest: true
- }
- );
+ view.fit(polygon, size, {padding: [170, 50, 30, 150], nearest: true});
}, false);
var zoomtolausanne = document.getElementById('zoomtolausanne');
zoomtolausanne.addEventListener('click', function() {
var feature = source.getFeatures()[1];
var point = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
var size = /** @type {ol.Size} */ (map.getSize());
- view.fit(
- point,
- size,
- {
- padding: [170, 50, 30, 150],
- minResolution: 50
- }
- );
+ view.fit(point, size, {padding: [170, 50, 30, 150], minResolution: 50});
}, false);
var centerlausanne = document.getElementById('centerlausanne');
centerlausanne.addEventListener('click', function() {
var feature = source.getFeatures()[1];
var point = /** @type {ol.geom.Point} */ (feature.getGeometry());
var size = /** @type {ol.Size} */ (map.getSize());
- view.centerOn(
- point.getCoordinates(),
- size,
- [570, 500]
- );
+ view.centerOn(point.getCoordinates(), size, [570, 500]);
}, false);
View
@@ -34,7 +34,7 @@ var clusterSource = new ol.source.Cluster({
var styleCache = {};
var clusters = new ol.layer.Vector({
source: clusterSource,
- style: function(feature, resolution) {
+ style: function(feature) {
var size = feature.get('features').length;
var style = styleCache[size];
if (!style) {
@@ -65,10 +65,6 @@ var raster = new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'sat'})
});
-var raw = new ol.layer.Vector({
- source: source
-});
-
var map = new ol.Map({
layers: [raster, clusters],
renderer: 'canvas',
@@ -138,6 +138,8 @@ var raster = new ol.source.Raster({
}
});
+var controls = {};
+
raster.on('beforeoperations', function(event) {
var data = event.data;
for (var id in controls) {
@@ -160,7 +162,6 @@ var map = new ol.Map({
});
var controlIds = ['hue', 'chroma', 'lightness'];
-var controls = {};
controlIds.forEach(function(id) {
var control = document.getElementById(id);
var output = document.getElementById(id + 'Out');
@@ -33,7 +33,7 @@ app.RotateNorthControl = function(opt_options) {
button.innerHTML = 'N';
var this_ = this;
- var handleRotateNorth = function(e) {
+ var handleRotateNorth = function() {
this_.getMap().getView().setRotation(0);
};
@@ -72,7 +72,7 @@ app.Drag.prototype.handleDownEvent = function(evt) {
var map = evt.map;
var feature = map.forEachFeatureAtPixel(evt.pixel,
- function(feature, layer) {
+ function(feature) {
return feature;
});
@@ -89,13 +89,6 @@ app.Drag.prototype.handleDownEvent = function(evt) {
* @param {ol.MapBrowserEvent} evt Map browser event.
*/
app.Drag.prototype.handleDragEvent = function(evt) {
- var map = evt.map;
-
- var feature = map.forEachFeatureAtPixel(evt.pixel,
- function(feature, layer) {
- return feature;
- });
-
var deltaX = evt.coordinate[0] - this.coordinate_[0];
var deltaY = evt.coordinate[1] - this.coordinate_[1];
@@ -115,7 +108,7 @@ app.Drag.prototype.handleMoveEvent = function(evt) {
if (this.cursor_) {
var map = evt.map;
var feature = map.forEachFeatureAtPixel(evt.pixel,
- function(feature, layer) {
+ function(feature) {
return feature;
});
var element = evt.map.getTargetElement();
@@ -133,10 +126,9 @@ app.Drag.prototype.handleMoveEvent = function(evt) {
/**
- * @param {ol.MapBrowserEvent} evt Map browser event.
* @return {boolean} `false` to stop the drag sequence.
*/
-app.Drag.prototype.handleUpEvent = function(evt) {
+app.Drag.prototype.handleUpEvent = function() {
this.coordinate_ = null;
this.feature_ = null;
return false;
View
@@ -39,7 +39,7 @@ d3.json('data/topojson/us.json', function(error, us) {
* @param {number} pixelRatio Pixel ratio.
* @param {ol.Size} size Size.
* @param {ol.proj.Projection} projection Projection.
- * @return {HTMLCanvasElement}
+ * @return {HTMLCanvasElement} A canvas element.
*/
var canvasFunction = function(extent, resolution, pixelRatio,
size, projection) {
@@ -39,7 +39,7 @@ el('track').addEventListener('change', function() {
deviceOrientation.setTracking(this.checked);
});
-deviceOrientation.on('change', function(event) {
+deviceOrientation.on('change', function() {
el('alpha').innerText = deviceOrientation.getAlpha() + ' [rad]';
el('beta').innerText = deviceOrientation.getBeta() + ' [rad]';
el('gamma').innerText = deviceOrientation.getGamma() + ' [rad]';
@@ -128,7 +128,7 @@ dragAndDropInteraction.on('addfeatures', function(event) {
var displayFeatureInfo = function(pixel) {
var features = [];
- map.forEachFeatureAtPixel(pixel, function(feature, layer) {
+ map.forEachFeatureAtPixel(pixel, function(feature) {
features.push(feature);
});
if (features.length > 0) {
@@ -124,7 +124,7 @@ dragAndDropInteraction.on('addfeatures', function(event) {
var displayFeatureInfo = function(pixel) {
var features = [];
- map.forEachFeatureAtPixel(pixel, function(feature, layer) {
+ map.forEachFeatureAtPixel(pixel, function(feature) {
features.push(feature);
});
if (features.length > 0) {
@@ -60,6 +60,8 @@ var modify = new ol.interaction.Modify({
map.addInteraction(modify);
var draw; // global so we can remove it later
+var typeSelect = document.getElementById('type');
+
function addInteraction() {
draw = new ol.interaction.Draw({
features: features,
@@ -68,14 +70,11 @@ function addInteraction() {
map.addInteraction(draw);
}
-var typeSelect = document.getElementById('type');
-
/**
- * Let user change the geometry type.
- * @param {Event} e Change event.
+ * Handle change event.
*/
-typeSelect.onchange = function(e) {
+typeSelect.onchange = function() {
map.removeInteraction(draw);
addInteraction();
};
@@ -83,10 +83,9 @@ function addInteraction() {
/**
- * Let user change the geometry type.
- * @param {Event} e Change event.
+ * Handle change event.
*/
-typeSelect.onchange = function(e) {
+typeSelect.onchange = function() {
map.removeInteraction(draw);
addInteraction();
};
@@ -56,7 +56,7 @@ function createEarthquakeStyle(feature) {
});
}
-var maxFeatureCount;
+var maxFeatureCount, vector;
function calculateClusterInfo(resolution) {
maxFeatureCount = 0;
var features = vector.getSource().getFeatures();
@@ -65,7 +65,8 @@ function calculateClusterInfo(resolution) {
feature = features[i];
var originalFeatures = feature.get('features');
var extent = ol.extent.createEmpty();
- for (var j = 0, jj = originalFeatures.length; j < jj; ++j) {
+ var j, jj;
+ for (j = 0, jj = originalFeatures.length; j < jj; ++j) {
ol.extent.extend(extent, originalFeatures[j].getGeometry().getExtent());
}
maxFeatureCount = Math.max(maxFeatureCount, jj);
@@ -104,7 +105,7 @@ function styleFunction(feature, resolution) {
return style;
}
-function selectStyleFunction(feature, resolution) {
+function selectStyleFunction(feature) {
var styles = [new ol.style.Style({
image: new ol.style.Circle({
radius: feature.get('radius'),
@@ -120,7 +121,7 @@ function selectStyleFunction(feature, resolution) {
return styles;
}
-var vector = new ol.layer.Vector({
+vector = new ol.layer.Vector({
source: new ol.source.Cluster({
distance: 40,
source: new ol.source.Vector({
@@ -14,7 +14,7 @@ goog.require('ol.style.Style');
var styleCache = {};
-var styleFunction = function(feature, resolution) {
+var styleFunction = function(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.
@@ -29,8 +29,8 @@ var styleFunction = function(feature, resolution) {
/** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')),
{size: [size + 2, size + 2], pixelRatio: size / 10});
render.setFillStrokeStyle(
- new ol.style.Fill({ color: 'rgba(255, 153, 0, 0.4)' }),
- new ol.style.Stroke({ color: 'rgba(255, 204, 0, 0.2)', width: 1 }));
+ new ol.style.Fill({color: 'rgba(255, 153, 0, 0.4)'}),
+ new ol.style.Stroke({color: 'rgba(255, 204, 0, 0.2)', width: 1}));
render.drawPolygonGeometry(new ol.geom.Polygon(
[[[0, 0], [4, 2], [6, 0], [10, 5], [6, 3], [4, 5], [0, 0]]]));
style = new ol.style.Style({
@@ -34,7 +34,7 @@ var map = new ol.Map({
var exportPNGElement = document.getElementById('export-png');
if ('download' in exportPNGElement) {
- exportPNGElement.addEventListener('click', function(e) {
+ exportPNGElement.addEventListener('click', function() {
map.once('postcompose', function(event) {
var canvas = event.context.canvas;
exportPNGElement.href = canvas.toDataURL('image/png');
@@ -54,7 +54,7 @@ var loaded = 0;
var exportButton = document.getElementById('export-pdf');
-exportButton.addEventListener('click', function(e) {
+exportButton.addEventListener('click', function() {
exportButton.disabled = true;
document.body.style.cursor = 'progress';
@@ -73,7 +73,7 @@ exportButton.addEventListener('click', function(e) {
++loading;
};
- var tileLoadEnd = function(callback) {
+ var tileLoadEnd = function() {
++loaded;
if (loading === loaded) {
var canvas = this;
Oops, something went wrong.

0 comments on commit 8c38d22

Please sign in to comment.