Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ To add markers to the map, use `?marker=lat,lon`. You can pass this multiple tim

- https://map.simonwillison.net/?center=51.49,0&zoom=8&marker=51.49,0&marker=51.3,0.2

To add a special marker (red), use `?specialMarker=lat,lon`.

- https://map.simonwillison.net/?center=51.49,0&zoom=8&marker=51.49,0&marker=51.3,0.2&specialMarker=51.523774,-0.158431

## Using this with shot-scraper

You can use this tool to create static map images using [shot-scraper](https://shot-scraper.datasette.io/). For example:
Expand Down
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
height: 100%;
margin: 0;
}
img.specialcolor {
filter: hue-rotate(120deg);
}
</style>
</head>
<body>
Expand All @@ -26,6 +29,7 @@
let zoom = parseInt(initialZoom || '2', 10);
let q = params.get('q');
let markers = params.getAll('marker');
let specialMarker = params.get('specialMarker');
let map = L.map('map', { zoomControl: false }).setView(toPoint(center), zoom);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
Expand Down Expand Up @@ -53,13 +57,16 @@
let center = map.getCenter();
let u = new URLSearchParams();
markers.forEach(s => u.append('marker', s));
u.append('specialMarker', specialMarker);
u.append('center', `${center.lat},${center.lng}`);
u.append('zoom', newZoom);
history.replaceState(null, null, '?' + u.toString());
});
markers.forEach(s => {
L.marker(toPoint(s)).addTo(map);
});
var s = L.marker(toPoint(specialMarker)).addTo(map);
s._icon.classList.add("specialcolor");
}
load();
</script>
Expand Down