如何使用 Leafletjs 从数据库中提供地图图块 [英] How TO serve Map tiles from a database using Leafletjs
本文介绍了如何使用 Leafletjs 从数据库中提供地图图块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Leaflet js 需要以下磁贴源格式:
Leaflet js requires the following tile source format:
http://localhost/tileserver/{z}/{x}/{y}.png
http://localhost/tileserver/{z}/{x}/{y}.png
如何使用 Leafletjs 从数据库而不是文件系统提供平铺图像(和 ASP.net)
How can I serve tile images from a database instead of file system using Leafletjs (and ASP.net)
推荐答案
这可以非常快速且与 Leaflet 无缝衔接:
This works very fast and seamlessly with Leaflet:
显然 Leaflet 只是使用 z,x,y 占位符来请求特定的图块.
Apparently Leaflet just uses the z,x,y place holders to request specific tiles.
生成和返回图块的方式确实非常灵活
How you generate and return the tiles is very flexible indeed
L.tileLayer('**http://localhost/tileserver/tile.aspx?z={z}&x={x}&y={y}**', {
minZoom: 7, maxZoom: 16,
attribution: 'My Tile Server'
}).addTo(map);
在哪里Tiles.aspx
Option Strict On
Partial Class tile
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim z, x, y As Integer
z = CInt(Request.QueryString("z"))
x = CInt(Request.QueryString("x"))
y = CInt(Request.QueryString("y"))
Dim b() As Byte = DB.GetTile(z, x, y)
Response.Buffer = True
Response.Charset = ""
'Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "image/png"
Response.AddHeader("content-disposition", "attachment;filename=" & y & ".png")
Response.BinaryWrite(b)
Response.Flush()
Response.End()
End Sub
这篇关于如何使用 Leafletjs 从数据库中提供地图图块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文