如果这很简单,我道歉,但我对此不太熟悉,并已阅读并调整了多个示例,才达到当前的进展。
我正在为一次活动制作地图。我使用了leaflet来完成这项工作,并经过大量调试,最终使用了单个图像(这正是我想要的,因为它将经常更新)。
下一步是在感兴趣的位置添加标记。现在我不特别想要任何花哨的东西,我想使用标记和弹出窗口(如此处所示:http://leafletjs.com/examples/quick-start/example-popups.html ),但是我尝试过的各种方法,从各种示例和教程中查看后似乎都无法工作。
我会粘贴我的代码,非常感谢任何能够提供帮助的人。再次道歉,如果这真的很简单,所有我有限的知识都来自于阅读和调整示例。
大部分内容都是使用此教程构建的:http://kempe.net/blog/2014/06/14/leaflet-pan-zoom-image.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="icon" type="image/png" href="assets/icon.ico">
<title>Whispers of Valentia</title>
<link rel="stylesheet" href="map.css" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Cantora+One|Acme|Meddon|Jim+Nightshade' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css">
</head>
<body>
<div id="navigationBar">
<div id="navigationLogo">
<abbr title="This is a test map.">WHISPERS OF VALENTIA</abbr>
</div>
</div>
<div class="shadeBar"></div>
<div id="image-map" style="background: #1e2831;">
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script>
// Using leaflet.js to pan and zoom a big image.
// See also: http://kempe.net/blog/2014/06/14/leaflet-pan-zoom-image.html
// create the slippy map
var map = L.map('image-map', {
minZoom: 2,
maxZoom: 6,
center: [5000, 2400],
zoom: 2,
crs: L.CRS.Simple
});
// dimensions of the image
var w = 10000,
h = 4800,
url = 'valentiatest.jpg';
// calculate the edges of the image, in coordinate space
var southWest = map.unproject([0, h], map.getMaxZoom()-1);
var northEast = map.unproject([w, 0], map.getMaxZoom()-1);
var bounds = new L.LatLngBounds(southWest, northEast);
// add the image overlay,
// so that it covers the entire map
L.imageOverlay(url, bounds).addTo(map);
// tell leaflet that the map is exactly as big as the image
map.setMaxBounds(bounds);
var marker = L.marker([1000, 1000]).addTo(map);
</script>
</div>
</body>