首页 文章

如何使用Leaflet从图像中创建 Map

提问于
浏览
5

好的,我找到了一个我认为我需要的例子 . 我无法弄清楚如何为我的图像设置它,我不确定这是否是实现我的目标的最佳方法 .

Intended Result :

http://maps.mixedbredie.net/leaflet/image.html

Example Code:

var map = L.map('map', {maxZoom: 17}).setView([51.495, -0.075], 14);
        /* Instead of a tile layer, use a bitmap image */
        var imageUrl = 'data/TM_pano.jpg';
        var imageBounds = [[51.490, -0.122], [51.510, -0.028]];
        L.imageOverlay(imageUrl, imageBounds).addTo(map);
        L.marker([51.495, -0.075]).addTo(map)
            .bindPopup("This is Table Mountain.");
        var popup = L.popup();
        function onMapClick(e) {
            popup
                .setLatLng(e.latlng)
                .setContent("You clicked the map at " + e.latlng.toString())
                .openOn(map);
        }
        map.on('click', onMapClick);
        map.setMaxBounds(imageBounds);

Questions:

1.) 如何选择经度/纬度,图像边界?

  • ,即.setView([51.495,-0.075],14)

  • var imageBounds = [[51.490,-0.122],[51.510,-0.028]];

2.) 应该缩放0显示我的整个图像?什么是合理的限制?

3.) 我可以用这种方法使用真实坐标吗?即将地下水管映射但使用该管道示意图的自定义.jpg?然后我可以将标记放在管道上一定长/拉 .

1 回答

相关问题