简体   繁体   English

使用 svg 作为使用 leaflet.js 的地图

[英]Use svg as map using leaflet.js

Is it possible to use SVG image as the base map for leaflet.js?是否可以使用 SVG 图像作为 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.在我的例子中,我有一个巨大的 svg 文件,我希望我的用户可以使用传单的所有功能,例如缩放、标记、图层。

Yes, you can just use imageOverlay , like this是的,你可以像这样使用imageOverlay

 // 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/leaflet@1.7.1/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script> <div id="map"></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM