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:
+11
-11
@@ -4,19 +4,19 @@ import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
||||
|
||||
var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5';
|
||||
const key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5';
|
||||
|
||||
var roads = new TileLayer({
|
||||
const roads = new TileLayer({
|
||||
source: new BingMaps({key: key, imagerySet: 'Road'})
|
||||
});
|
||||
|
||||
var imagery = new TileLayer({
|
||||
const imagery = new TileLayer({
|
||||
source: new BingMaps({key: key, imagerySet: 'Aerial'})
|
||||
});
|
||||
|
||||
var container = document.getElementById('map');
|
||||
const container = document.getElementById('map');
|
||||
|
||||
var map = new Map({
|
||||
const map = new Map({
|
||||
layers: [roads, imagery],
|
||||
target: container,
|
||||
view: new View({
|
||||
@@ -25,7 +25,7 @@ var map = new Map({
|
||||
})
|
||||
});
|
||||
|
||||
var radius = 75;
|
||||
let radius = 75;
|
||||
document.addEventListener('keydown', function(evt) {
|
||||
if (evt.which === 38) {
|
||||
radius = Math.min(radius + 5, 150);
|
||||
@@ -39,7 +39,7 @@ document.addEventListener('keydown', function(evt) {
|
||||
});
|
||||
|
||||
// get the pixel position with every move
|
||||
var mousePosition = null;
|
||||
let mousePosition = null;
|
||||
|
||||
container.addEventListener('mousemove', function(event) {
|
||||
mousePosition = map.getEventPixel(event);
|
||||
@@ -53,14 +53,14 @@ container.addEventListener('mouseout', function() {
|
||||
|
||||
// before rendering the layer, do some clipping
|
||||
imagery.on('precompose', function(event) {
|
||||
var ctx = event.context;
|
||||
var pixelRatio = event.frameState.pixelRatio;
|
||||
const ctx = event.context;
|
||||
const pixelRatio = event.frameState.pixelRatio;
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
if (mousePosition) {
|
||||
// only show a circle around the mouse
|
||||
ctx.arc(mousePosition[0] * pixelRatio, mousePosition[1] * pixelRatio,
|
||||
radius * pixelRatio, 0, 2 * Math.PI);
|
||||
radius * pixelRatio, 0, 2 * Math.PI);
|
||||
ctx.lineWidth = 5 * pixelRatio;
|
||||
ctx.strokeStyle = 'rgba(0,0,0,0.5)';
|
||||
ctx.stroke();
|
||||
@@ -70,6 +70,6 @@ imagery.on('precompose', function(event) {
|
||||
|
||||
// after rendering the layer, restore the canvas context
|
||||
imagery.on('postcompose', function(event) {
|
||||
var ctx = event.context;
|
||||
const ctx = event.context;
|
||||
ctx.restore();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user