Add markers to a non-georeferenced image
The MapTiler’s SDK ImageViewerMarker allows you to add markers to your non-georeferenced images while interacting with them similarly to how you would navigate a regular map.
Image: 1932 Japanese pictorial world map game board - World Adventure
NPM module setup
npm install --save @maptiler/sdk
import { config, ImageViewer, ImageViewerMarker } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';
config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const imageViewer = new ImageViewer({
container: 'map',
imageUUID: 'YOUR_MAPTILER_TILESET_ID_HERE',
});
imageViewer.on('imageviewerready', () => {
const marker = new ImageViewerMarker({})
.setPosition([1000, 2000])
.addTo(imageViewer);
const marker1 = new ImageViewerMarker({
color: "#FF0000",
draggable: true
}).setPosition([2496, 1135])
.addTo(imageViewer);
marker1.on("dragend", (evt) => {
console.log(evt);
})
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Add markers to a non-georeferenced image | NPM example</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="map"></div>
<script type="module" src="./main.js"></script>
</body>
</html>
body {margin: 0; padding: 0;}
#map {position: absolute; top: 0; bottom: 0; width: 100%;}
Learn more
Visit the ImageViewer API reference for full details on supported options, methods, etc.
Check out the ImageViewerMarker API reference for information about available options, functions, and more.
Related examples
Display a non-georeferenced image
ExamplesDisplay a zoomable non-georeferenced, geographically "inaccurate" maps in your application using the ImageViewer.