A browser library for smooth interactive XYZ raster-tile maps like OpenStreetMap.
onDraw callback to draw application-specific visuals after the map has been rendered in each frame.MapComponent class.<kayahr-map> custom element.Import the package module, give the element a CSS size, and specify the initial view directly in HTML.
<script type="module">
import "@kayahr/etchmap";
</script>
<style>
kayahr-map {
width: 100vw;
height: 100vh;
}
</style>
<kayahr-map center-x="6.9603" center-y="50.9375" zoom="13"></kayahr-map>
JavaScript can access the complete component API of a declaratively created map with document.querySelector("kayahr-map").getComponent().
import { MapComponent } from "@kayahr/etchmap";
const map = new MapComponent({
center: { x: 6.9603, y: 50.9375 },
zoom: 13
});
map.onDraw = (context, map) => {
const point = map.projectPoint({ x: 6.9583, y: 50.9413 });
context.fillRect(point.x - 4, point.y - 4, 8, 8);
};
document.body.append(map.getElement());
onDraw callback to position an HTML marker at Cologne Cathedral.