Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Add MapTiler attribution control

Russ Garrett09ad874acd86
diff --git a/dist/img/maptiler.png b/dist/img/maptiler.png
index d6b4793..36809ae 100644
Binary files a/dist/img/maptiler.png and b/dist/img/maptiler.png differ
diff --git a/src/index.css b/src/index.css
index f133d27..29b8393 100644
--- a/src/index.css
+++ b/src/index.css
@@ -87,3 +87,15 @@ canvas:focus {
/* Remove unnecessary focus border */
outline:none;
}
+
+#maptiler-attribution {
+ background-color: rgba(255, 255, 255, 0.5);
+ backdrop-filter: blur(3px) saturate(80%);
+ border-radius: 4px;
+}
+
+#maptiler-attribution img {
+ display: block;
+ width: 100px;
+ padding: 2px;
+}
diff --git a/src/index.js b/src/index.js
index 69ddf63..d60e2ad 100644
--- a/src/index.js
+++ b/src/index.js
@@ -8,6 +8,7 @@ import LayerSwitcher from '@russss/mapboxgl-layer-switcher';
import URLHash from '@russss/mapboxgl-layer-switcher/urlhash';
import EditButton from './editbutton.js';
+import MapTilerAttribution from './maptiler-attribution.js';
import InfoBox from './infobox.js';
import InfoPopup from './infopopup.js';
import KeyControl from './key/key.js';
@@ -70,8 +71,8 @@ function init() {
if (DEV) {
map_style['sprite'] = 'http://localhost:8080/style/sprite';
- map_style['sources']['openinframap']['url'] = 'http://localhost:8081/capabilities/openinframap.json'
- map_style['sources']['solar_heatmap']['url'] = 'http://localhost:8081/capabilities/solar_heatmap.json'
+ // map_style['sources']['openinframap']['url'] = 'http://localhost:8081/capabilities/openinframap.json'
+ // map_style['sources']['solar_heatmap']['url'] = 'http://localhost:8081/capabilities/solar_heatmap.json'
}
var map = new mapboxgl.Map(url_hash.init({
@@ -95,7 +96,10 @@ function init() {
trackUserLocation: true,
}),
);
+
+ map.addControl(new MapTilerAttribution(), 'bottom-right');
map.addControl(new mapboxgl.ScaleControl({position: 'bottom-left'}));
+
map.addControl(new KeyControl(), 'top-right');
map.addControl(layer_switcher, 'top-right');
map.addControl(new EditButton(), 'bottom-right');
diff --git a/src/maptiler-attribution.js b/src/maptiler-attribution.js
new file mode 100644
index 0000000..02d9e72
--- /dev/null
+++ b/src/maptiler-attribution.js
@@ -0,0 +1,26 @@
+import { el } from "redom";
+
+class MapTilerAttribution {
+ onAdd(map) {
+ this._map = map;
+
+ var img = el(
+ "a",
+ el("img", {
+ src: "img/maptiler.png"
+ }),
+ {
+ href: "https://www.maptiler.com",
+ target: "_blank"
+ }
+ );
+
+ this._control = el("div#maptiler-attribution", img, {
+ class: "mapboxgl-ctrl"
+ });
+
+ return this._control;
+ }
+}
+
+export { MapTilerAttribution as default };