0

I'm trying to write a simple file for testing Leaflet Plugin "Leaflet Custom Headers". Some discussion about the Plugin's purpose has been written here: https://github.com/Leaflet/Leaflet/issues/7560

I'm not into .ts-Scripting nor Packet manager-Installations. So I downloaded the Repo's zip-file and put its content into the same folder as my "test.htm". But the following code doesn't work, my Browser doesn't open the map. Any ideas to improve the code?

<!DOCTYPE html>
<html>
<head>
    <title>Test with Leaflet Custom Headers</title>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"/>
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
</head>
<body>
<div id="map" style="width: 800px; height: 600px;"></div>

<script defer src="main.ts"></script>

<script>
    var map = L.map('map').setView([51.505, -0.09], 13);

var layerWithHeaders = new TileLayerHeaders(“https://tile.openstreetmap.org/{z}/{x}/{y}.png”, {
  customHeaders: {
    "Authorization": "MY_TEST_TOKEN"
  }
});

layerWithHeaders.addTo(map);

</script>
</body>
</html>
1
  • I got the info that Typescripts (.ts) can't be imported into .html files, just pure Javascript (.js) Files. So I compiled (transpiled) "main.ts" using "tsc" which created a file "main.js". After that I imported "main.js" instead of "main.ts" in the HTML-code above. But still no map gets loaded but errors in the Browser's console Commented Jun 3 at 15:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.