From 79558c8e2a5408ffddc7066e5ff5513234d5a74d Mon Sep 17 00:00:00 2001 From: morikuni Date: Wed, 30 Mar 2022 12:31:40 +0900 Subject: [PATCH] Support multiple layers --- template.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/template.go b/template.go index 0001fb6..bbfb46f 100644 --- a/template.go +++ b/template.go @@ -27,9 +27,19 @@ const htmlTemplate = ` center: [0, 0], zoom: 1, }); - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap contributors' + // tiles are copied from: https://leaflet-extras.github.io/leaflet-providers/preview/ + const Esri_WorldStreetMap = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { + attribution: 'Tiles © Esri — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012' }).addTo(map); + const OpenStreetMap_Mapnik = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + maxZoom: 19, + attribution: '© OpenStreetMap contributors' + }); + const layers = { + "Esri": Esri_WorldStreetMap, + "OpenStreetMap": OpenStreetMap_Mapnik, + } + L.control.layers(layers).addTo(map); map.attributionControl.addAttribution('© go-geoplot by morikuni'); {{ range .lines }} {{- .}}