Using custom map image tiles in LeafletJS?

后端 未结 2 686
清酒与你
清酒与你 2020-12-07 08:44

Do my tiles need to adhere to any particular specs?

I have a large image file which I\'d like to turn into a map with LeafletJS. I am going to be using the Python Im

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 08:57

    You are looking for a TileLayer. In this TileLayer, you give the URL for the to-be-fetched images to leaflet with a template like this:

    http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png
    

    When you are at the specified zoom, x and y level, Leaflet will automatically fetch the tiles on the URL you gave.

    Depending on the image you want to show, the bigger part of the work will however be in the tile generation. Tiles by default have a 256x256px size (can be changed in the TileLayer options), and if you are using geodata the used projection is Mercator projection. It may take some time to get the tile ids right. Here is an example on how the tile ids work.

提交回复
热议问题