Is it possible to use SVG image as the base map for leaflet.js ?
In my case I have huge svg file and I wish to allow my users to use all of leaflet's features such as zoom, markers, layers.
Yes, you can just use imageOverlay, like this
// create the map
var map = L.map('map', {
center: [40.75, -74.2],
zoom: 13
});
var imageUrl = 'https://www.amcharts.com/lib/3/maps/svg/australiaHigh.svg',
imageBounds = [
[40.712216, -74.22655],
[40.773941, -74.12544]
];
L.imageOverlay(imageUrl, imageBounds).addTo(map);
#map {
height: 400px;
}
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<div id="map"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With