mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-15 22:36:58 +00:00
Enable no-var
linting rule and fix issues (#8602)
This commit is contained in:
@ -3,45 +3,45 @@ layout: tutorial_frame
|
||||
title: Layers Control Tutorial
|
||||
---
|
||||
<script>
|
||||
var cities = L.layerGroup();
|
||||
const cities = L.layerGroup();
|
||||
|
||||
var mLittleton = L.marker([39.61, -105.02]).bindPopup('This is Littleton, CO.').addTo(cities);
|
||||
var mDenver = L.marker([39.74, -104.99]).bindPopup('This is Denver, CO.').addTo(cities);
|
||||
var mAurora = L.marker([39.73, -104.8]).bindPopup('This is Aurora, CO.').addTo(cities);
|
||||
var mGolden = L.marker([39.77, -105.23]).bindPopup('This is Golden, CO.').addTo(cities);
|
||||
const mLittleton = L.marker([39.61, -105.02]).bindPopup('This is Littleton, CO.').addTo(cities);
|
||||
const mDenver = L.marker([39.74, -104.99]).bindPopup('This is Denver, CO.').addTo(cities);
|
||||
const mAurora = L.marker([39.73, -104.8]).bindPopup('This is Aurora, CO.').addTo(cities);
|
||||
const mGolden = L.marker([39.77, -105.23]).bindPopup('This is Golden, CO.').addTo(cities);
|
||||
|
||||
var mbAttr = 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>';
|
||||
var mbUrl = 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw';
|
||||
const mbAttr = 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>';
|
||||
const mbUrl = 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw';
|
||||
|
||||
var streets = L.tileLayer(mbUrl, {id: 'mapbox/streets-v11', tileSize: 512, zoomOffset: -1, attribution: mbAttr});
|
||||
const streets = L.tileLayer(mbUrl, {id: 'mapbox/streets-v11', tileSize: 512, zoomOffset: -1, attribution: mbAttr});
|
||||
|
||||
var osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
const osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
});
|
||||
|
||||
var map = L.map('map', {
|
||||
const map = L.map('map', {
|
||||
center: [39.73, -104.99],
|
||||
zoom: 10,
|
||||
layers: [osm, cities]
|
||||
});
|
||||
|
||||
var baseLayers = {
|
||||
const baseLayers = {
|
||||
'OpenStreetMap': osm,
|
||||
'Streets': streets
|
||||
};
|
||||
|
||||
var overlays = {
|
||||
const overlays = {
|
||||
'Cities': cities
|
||||
};
|
||||
|
||||
var layerControl = L.control.layers(baseLayers, overlays).addTo(map);
|
||||
var crownHill = L.marker([39.75, -105.09]).bindPopup('This is Crown Hill Park.');
|
||||
var rubyHill = L.marker([39.68, -105.00]).bindPopup('This is Ruby Hill Park.');
|
||||
const layerControl = L.control.layers(baseLayers, overlays).addTo(map);
|
||||
const crownHill = L.marker([39.75, -105.09]).bindPopup('This is Crown Hill Park.');
|
||||
const rubyHill = L.marker([39.68, -105.00]).bindPopup('This is Ruby Hill Park.');
|
||||
|
||||
var parks = L.layerGroup([crownHill, rubyHill]);
|
||||
const parks = L.layerGroup([crownHill, rubyHill]);
|
||||
|
||||
var satellite = L.tileLayer(mbUrl, {id: 'mapbox/satellite-v9', tileSize: 512, zoomOffset: -1, attribution: mbAttr});
|
||||
const satellite = L.tileLayer(mbUrl, {id: 'mapbox/satellite-v9', tileSize: 512, zoomOffset: -1, attribution: mbAttr});
|
||||
layerControl.addBaseLayer(satellite, 'Satellite');
|
||||
layerControl.addOverlay(parks, 'Parks');
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user