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:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions
+25 -25
View File
@@ -5,65 +5,65 @@ import TileLayer from '../src/ol/layer/Tile.js';
import TileJSON from '../src/ol/source/TileJSON.js';
import UTFGrid from '../src/ol/source/TileUTFGrid.js';
var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
var mapLayer = new TileLayer({
const mapLayer = new TileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v4/mapbox.geography-class.json?secure&access_token=' + key
})
});
var gridSource = new UTFGrid({
const gridSource = new UTFGrid({
url: 'https://api.tiles.mapbox.com/v4/mapbox.geography-class.json?secure&access_token=' + key
});
var gridLayer = new TileLayer({source: gridSource});
const gridLayer = new TileLayer({source: gridSource});
var view = new View({
const view = new View({
center: [0, 0],
zoom: 1
});
var mapElement = document.getElementById('map');
var map = new Map({
const mapElement = document.getElementById('map');
const map = new Map({
layers: [mapLayer, gridLayer],
target: mapElement,
view: view
});
var infoElement = document.getElementById('country-info');
var flagElement = document.getElementById('country-flag');
var nameElement = document.getElementById('country-name');
const infoElement = document.getElementById('country-info');
const flagElement = document.getElementById('country-flag');
const nameElement = document.getElementById('country-name');
var infoOverlay = new Overlay({
const infoOverlay = new Overlay({
element: infoElement,
offset: [15, 15],
stopEvent: false
});
map.addOverlay(infoOverlay);
var displayCountryInfo = function(coordinate) {
var viewResolution = /** @type {number} */ (view.getResolution());
const displayCountryInfo = function(coordinate) {
const viewResolution = /** @type {number} */ (view.getResolution());
gridSource.forDataAtCoordinateAndResolution(coordinate, viewResolution,
function(data) {
// If you want to use the template from the TileJSON,
// load the mustache.js library separately and call
// info.innerHTML = Mustache.render(gridSource.getTemplate(), data);
mapElement.style.cursor = data ? 'pointer' : '';
if (data) {
flagElement.src = 'data:image/png;base64,' + data['flag_png'];
nameElement.innerHTML = data['admin'];
}
infoOverlay.setPosition(data ? coordinate : undefined);
});
function(data) {
// If you want to use the template from the TileJSON,
// load the mustache.js library separately and call
// info.innerHTML = Mustache.render(gridSource.getTemplate(), data);
mapElement.style.cursor = data ? 'pointer' : '';
if (data) {
flagElement.src = 'data:image/png;base64,' + data['flag_png'];
nameElement.innerHTML = data['admin'];
}
infoOverlay.setPosition(data ? coordinate : undefined);
});
};
map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var coordinate = map.getEventCoordinate(evt.originalEvent);
const coordinate = map.getEventCoordinate(evt.originalEvent);
displayCountryInfo(coordinate);
});