Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
@@ -9,7 +9,7 @@ import Style from '../src/ol/style/Style.js';
|
||||
import Text from '../src/ol/style/Text.js';
|
||||
|
||||
|
||||
var style = new Style({
|
||||
const style = new Style({
|
||||
fill: new Fill({
|
||||
color: 'rgba(255, 255, 255, 0.6)'
|
||||
}),
|
||||
@@ -29,7 +29,7 @@ var style = new Style({
|
||||
})
|
||||
});
|
||||
|
||||
var vectorLayer = new VectorLayer({
|
||||
const vectorLayer = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
url: 'data/geojson/countries.geojson',
|
||||
format: new GeoJSON()
|
||||
@@ -40,7 +40,7 @@ var vectorLayer = new VectorLayer({
|
||||
}
|
||||
});
|
||||
|
||||
var map = new Map({
|
||||
const map = new Map({
|
||||
layers: [vectorLayer],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
@@ -49,7 +49,7 @@ var map = new Map({
|
||||
})
|
||||
});
|
||||
|
||||
var highlightStyle = new Style({
|
||||
const highlightStyle = new Style({
|
||||
stroke: new Stroke({
|
||||
color: '#f00',
|
||||
width: 1
|
||||
@@ -69,7 +69,7 @@ var highlightStyle = new Style({
|
||||
})
|
||||
});
|
||||
|
||||
var featureOverlay = new VectorLayer({
|
||||
const featureOverlay = new VectorLayer({
|
||||
source: new VectorSource(),
|
||||
map: map,
|
||||
style: function(feature) {
|
||||
@@ -78,14 +78,14 @@ var featureOverlay = new VectorLayer({
|
||||
}
|
||||
});
|
||||
|
||||
var highlight;
|
||||
var displayFeatureInfo = function(pixel) {
|
||||
let highlight;
|
||||
const displayFeatureInfo = function(pixel) {
|
||||
|
||||
var feature = map.forEachFeatureAtPixel(pixel, function(feature) {
|
||||
const feature = map.forEachFeatureAtPixel(pixel, function(feature) {
|
||||
return feature;
|
||||
});
|
||||
|
||||
var info = document.getElementById('info');
|
||||
const info = document.getElementById('info');
|
||||
if (feature) {
|
||||
info.innerHTML = feature.getId() + ': ' + feature.get('name');
|
||||
} else {
|
||||
@@ -108,7 +108,7 @@ map.on('pointermove', function(evt) {
|
||||
if (evt.dragging) {
|
||||
return;
|
||||
}
|
||||
var pixel = map.getEventPixel(evt.originalEvent);
|
||||
const pixel = map.getEventPixel(evt.originalEvent);
|
||||
displayFeatureInfo(pixel);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user