-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathleaflet.html
More file actions
63 lines (50 loc) · 2.17 KB
/
leaflet.html
File metadata and controls
63 lines (50 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Polyscript JS Modules</title>
<style>#main-map, #worker-map { height: 320px; } h3 { margin-bottom: 0; }</style>
<link rel="stylesheet" href="style.css">
<script type="module" src="../dist/index.js"></script>
</head>
<body>
<!--
main only: npx static-handler .
main/worker: npx static-handler --coop --coep .
Note: --corp breaks the tiles server
-->
<h3>Main</h3>
<div id="main-map"></div>
<script type="pyodide" config="./modules.toml">
# needed to fix pyodide proxies
from pyodide.ffi import to_js
from polyscript import js_modules
from polyscript.js_modules import leaflet as L
print(js_modules.random_js.default)
center = to_js([51.505, -0.09])
mark = to_js([51.5, -0.09])
map = L.map('main-map').setView(center, 13)
L.tileLayer(
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
to_js({"attribution": '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'})
).addTo(map)
L.marker(mark).addTo(map).bindPopup('Modules on Main are a no brainer 👍').openPopup()
</script>
<hr>
<h3>Worker</h3>
<div id="worker-map"></div>
<script type="pyodide" config="./modules.toml" worker>
from polyscript.js_modules import random_js, leaflet as L
print(random_js.default)
center = [51.505, -0.09]
mark = [51.5, -0.09]
map = L.map('worker-map').setView(center, 13)
L.tileLayer(
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
{"attribution": '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}
).addTo(map)
L.marker(mark).addTo(map).bindPopup('Modules on Worker are awesome 🥳').openPopup()
</script>
</body>
</html>