单张图像映射到景观视口的边界视图 [英] Bounding view of a Leaflet image map to a landscape viewport

查看:45
本文介绍了单张图像映射到景观视口的边界视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方形图像16384x16384,该图像已使用MapTiler切成小块,以在Leaflet中创建6级缩放.

I have a square image 16384x16384 that has been sliced into tiles using MapTiler to create 6 levels of zoom in Leaflet.

我已经在Leaflet中设置了图像,如下所示:

I have set up the image in Leaflet as follows:

var map = L.map('map', {
      maxZoom: 6,
      minZoom: 0,
    }).setView([0, 0],1);

var tilesURL = "_server/tiles/{z}/{x}/{y}.jpg";

L.tileLayer(tilesURL, {
    maxZoom: 6,
    continuousWorld: 'false',
    tms: true
}).addTo(map);

我怎么会

  1. 将这个大正方形图像的视图限制在中间(横向矩形)区域吗?
  2. 生成一组非正方形的矩形图块吗?

另外,Leaflet可以将边界区域自动调整到Map容器​​吗?

Additionally, can Leaflet auto-fit the bounded area to the Map container?

推荐答案

  1. 是的.使用 maxBounds选项.
  2. 不知道,但是为什么要这么做呢?
  3. 是:方法 fitBounds 可以做到.
  1. Yes. Use the maxBounds option.
  2. No idea, but why do you want to do such a thing?
  3. Yes: the method fitBounds does that.

这篇关于单张图像映射到景观视口的边界视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆