Skip to content

2 A dynamic tile provider in ASP.NET

Oliver Heilig edited this page Apr 21, 2024 · 7 revisions

The basic technique to visualize our own data is to implement a "dynamic tile provider". This means we build our own web service that renders images. On the client side, we "inject" these images between the xMapServer back- and foreground layer. A big advantage of the xMapServer rendering engine is that the labels of the basemap are still topmost.

I'm using ASP.NET for my custom imagery service, but the same practice can also be applied to Java or JavaScript (via node). Here is a tutorial for node.

Our first tile provider does nothing else but to render an image with the tile key as text, like https://spatialtutorial.azurewebsites.net/02-DynamicTilesHandler.ashx?x=1&y=2&z=3.

Plain Tile

The code-behind for the ASP.NET handler

At leaflet we can add an additional TileLayer using our own handler:

// add dymamic tile layer
var myTileLayer = new L.TileLayer('02-DynamicTilesHandler.ashx?x={x}&y={y}&z={z}', {
 maxZoom: 20, minZoom: 0, zIndex: 100}).addTo(map);

The result: https://spatialtutorial.azurewebsites.net/02-DynamicTileProvider.html