Skip to content

Commit

Permalink
Remove Maptiler, since they seem to have added print restrictions to …
Browse files Browse the repository at this point in the history
…their terms.
  • Loading branch information
mpetroff committed Jun 21, 2022
1 parent ac54769 commit 51b1167
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 43 deletions.
19 changes: 0 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ <h1>Print Maps</h1>
<option value="mapbox://styles/mapbox/emerald-v8">Mapbox Emerald</option>
<option value="mapbox://styles/mapbox/light-v9">Mapbox Light</option>
<option value="mapbox://styles/mapbox/streets-v10">Mapbox Streets</option>
<option value="https://api.maptiler.com/maps/basic/style.json">Klokantech Basic</option>
<option value="https://api.maptiler.com/maps/bright/style.json">Klokantech Bright</option>
<option value="https://api.maptiler.com/maps/darkmatter/style.json">Klokantech Dark Matter</option>
<option value="https://api.maptiler.com/maps/pastel/style.json">Klokantech Pastel</option>
<option value="https://api.maptiler.com/maps/positron/style.json">Klokantech Positron</option>
<option value="https://api.maptiler.com/maps/streets/style.json">Klokantech Streets</option>
<option value="https://api.maptiler.com/maps/toner/style.json">Klokantech Toner</option>
<option value="https://api.maptiler.com/maps/topo/style.json">Klokantech Topo</option>
<option value="https://api.maptiler.com/maps/topographique/style.json">Klokantech Topographique</option>
<option value="https://api.maptiler.com/maps/voyager/style.json">Klokantech Voyager</option>
<option value="https://tiles.stadiamaps.com/styles/alidade_smooth.json">Stadia Maps Alidade Smooth</option>
<option value="https://tiles.stadiamaps.com/styles/alidade_smooth_dark.json">Stadia Maps Alidade Smooth Dark</option>
<option value="https://tiles.stadiamaps.com/styles/outdoors.json">Stadia Maps Outdoors</option>
Expand Down Expand Up @@ -147,15 +137,6 @@ <h3 class="panel-title">Required Attribution</h3>
<p>For print output or if you can’t include links, use this text-only attribution:</p>
<pre>© Mapbox, © OpenStreetMap</pre>
</div>
<div class="panel-body" id="openmaptiles-attribution" style="display: none;">
<p><strong>Attribution of maps is required.</strong> Per the <a href="https://openmaptiles.com/terms/">OpenMapTiles terms of use:</a></p>
<p><strong>Commerical use is prohibited.</strong></p>
<p>The OpenMapTiles has a strict requirement of attribution on the produced maps - whether you use the free, purchased or self-generated map tiles. It is important part of the sustainability strategy. By using OpenMapTiles you agree to provide such attribution on the maps you display.</p>
<p>For a browsable electronic map based on OpenMapTiles and OpenStreetMap data, the credit should appear in the corner of the map. For example:</p>
<pre>© &lt;a href='https://openmaptiles.org/'&gt;OpenMapTiles&lt;/a&gt; © &lt;a href='https://www.openstreetmap.org/copyright'&gt;OpenStreetMap contributors&lt;/a&gt; &lt;strong&gt;&lt;a href='https://www.mapbox.com/map-feedback/' target='_blank'&gt;Improve this map&lt;/a&gt;&lt;/strong&gt;</pre>
<p>For printed maps, images or video recording a similar attribution should be made in a clearly visible textual description near the map, in the same fashion as if you cite a photograph.</p>
<p>Other datasets (such as Satellite or DEM derived data) may require attribution as well.</p>
</div>
<div class="panel-body" id="stadiamaps-attribution" style="display: none;">
<p><strong>Attribution of maps is required.</strong> See the Stadia Maps <a href="https://stadiamaps.com/attribution/">attribution</a> and <a href="https://stadiamaps.com/terms-of-service/">terms of service</a> pages for details.</p>
<p><strong>Commerical use is prohibited.</strong></p>
Expand Down
25 changes: 1 addition & 24 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/

mapboxgl.accessToken = '';
var mapTilerAccessToken = '';

var form = document.getElementById('config');

Expand All @@ -34,20 +33,10 @@ if (!mapboxgl.accessToken || mapboxgl.accessToken.length < 10) {
}
}
}
if (!mapTilerAccessToken || mapTilerAccessToken.length < 10) {
// Don't use MapTiler styles without access token
for (var i = form.styleSelect.length - 1; i >= 0; i--) {
if (form.styleSelect[i].value.indexOf('tilehosting') >= 0) {
form.styleSelect.remove(i);
}
}
}

// Show attribution requirement of initial style
if (form.styleSelect.value.indexOf('mapbox') >= 0)
document.getElementById('mapbox-attribution').style.display = 'block';
else if (form.styleSelect.value.indexOf('maptiler') >= 0)
document.getElementById('openmaptiles-attribution').style.display = 'block';
else
document.getElementById('stadiamaps-attribution').style.display = 'block';

Expand All @@ -71,8 +60,6 @@ function updateLocationInputs() {
var map;
try {
var style = form.styleSelect.value;
if (style.indexOf('maptiler') >= 0)
style += '?key=' + mapTilerAccessToken;
map = new mapboxgl.Map({
container: 'map',
center: [0, 0],
Expand Down Expand Up @@ -249,24 +236,16 @@ form.styleSelect.addEventListener('change', function() {
'use strict';
try {
var style = form.styleSelect.value;
if (style.indexOf('maptiler') >= 0)
style += '?key=' + mapTilerAccessToken;
map.setStyle(style);
} catch (e) {
openErrorModal("Error changing style: " + e.message);
}
// Update attribution requirements
if (form.styleSelect.value.indexOf('mapbox') >= 0) {
document.getElementById('mapbox-attribution').style.display = 'block';
document.getElementById('openmaptiles-attribution').style.display = 'none';
document.getElementById('stadiamaps-attribution').style.display = 'none';
} else if (form.styleSelect.value.indexOf('maptiler') >= 0) {
document.getElementById('mapbox-attribution').style.display = 'none';
document.getElementById('openmaptiles-attribution').style.display = 'block';
document.getElementById('stadiamaps-attribution').style.display = 'none';
} else {
document.getElementById('mapbox-attribution').style.display = 'none';
document.getElementById('openmaptiles-attribution').style.display = 'none';
document.getElementById('stadiamaps-attribution').style.display = 'block';
}
});
Expand Down Expand Up @@ -393,8 +372,6 @@ function generateMap() {
var unit = form.unitOptions[0].checked ? 'in' : 'mm';

var style = form.styleSelect.value;
if (style.indexOf('maptiler') >= 0)
style += '?key=' + mapTilerAccessToken;

var zoom = map.getZoom();
var center = map.getCenter();
Expand Down Expand Up @@ -456,7 +433,7 @@ function createPrintMap(width, height, dpi, format, unit, zoom, center,
var title = map.getStyle().name,
subject = "center: [" + form.lonInput.value + ", " + form.latInput.value + ", " + form.zoomInput.value + "]",
attribution = '(c) ' +
(form.styleSelect.value.indexOf('mapbox') >= 0 ? 'Mapbox' : 'OpenMapTiles') +
(form.styleSelect.value.indexOf('mapbox') >= 0 ? 'Mapbox' : 'Stadia Maps') +
', (c) OpenStreetMap';

pdf.setProperties({
Expand Down

0 comments on commit 51b1167

Please sign in to comment.