百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

BruTile

> 编程语言
开源

BruTile 是一个 .NET 库,用于访问诸如 OpenStreetMap、MapBox 或 GeodanMaps 等瓦片服务。

373 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

BruTile 是一个 .NET 库,用于访问诸如 OpenStreetMap、MapBox 或 GeodanMaps 等瓦片服务。

Status
Build
NuGet BruTile
NuGet BruTile.MbTiles

BruTile

BruTile is a .NET Standard 2.0 library to access tile services like OpenStreetMap and Bing. Such tile services store pre-rendered tiles for a certain area and for various levels of detail. BruTile helps to determine which tiles to fetch for a certain viewport of a map. BruTile returns tiles as raw image streams and has no dependency on a specific client platform. BruTile does not display those tiles. You need to use a mapping library like SharpMap, ArcBruTile or Mapsui or write your own code to display tiles.

What BruTile does is:

  1. Helps to construct a tile source, an object that has all information about a tile service.
  2. Helps to calculate which tiles you need, given a certain map extent and a map resolution (units per pixel).
  3. Helps you fetch those tiles.

BruTile is a .NET Standard library

BruTile V4 consists of 2 nugets that support .NET Standard 2.0.

Library Targeted Framework
BruTile .NET Standard 2.0
BruTile.MbTiles .NET Standard 2.0
  • Support for .NET Framework 4.5 has been removed (also the samples and tests have moved to .NET Core).
  • BruTile.Desktop and BruTile.Desktop.DbCache have been deleted and their content has moved to the BruTile nuget.

Demo

For a demo showing various data sources download the source code and run BruTile.Demo in the Samples folder

Getting Started

1) Create an app and add the BruTile NuGet package

Create a .NET Console app in Visual Studio. Add the BruTile NuGet package. Use the package manager tools in Visual Studio or add it from the package manager console:

PM> install-package BruTile 

2) Create a tile source

csharp
// This is an example that creates the OpenStreetMap tile source:
var tileSource = new HttpTileSource(new GlobalSphericalMercator(0, 18),
    "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
    new[] {"a", "b", "c"}, "OSM");

3) Calculate which tiles you need

csharp
// the extent of the visible map changes but lets start with the whole world
var extent = new Extent(-20037508, -20037508, 20037508, 20037508);
var screenWidthInPixels = 400; // The width of the map on screen in pixels
var resolution = extent.Width / screenWidthInPixels;
var tileInfos = tileSource.Schema.GetTileInfos(extent, resolution);

4) Fetch the tiles from the service

csharp
Console.WriteLine("Show tile info");
foreach (var tileInfo in tileInfos)
{
    var tile = await tileSource.GetTileAsync(tileInfo);

    Console.WriteLine(
        $"tile col: {tileInfo.Index.Col}, " +
        $"tile row: {tileInfo.Index.Row}, " +
        $"tile level: {tileInfo.Index.Level} , " +
        $"tile size {tile.Length}");
}

Output:

bash
    tile col: 0, tile row: 0, tile level: 1 , tile size 11276
    tile col: 0, tile row: 1, tile level: 1 , tile size 3260
    tile col: 1, tile row: 0, tile level: 1 , tile size 10679
    tile col: 1, tile row: 1, tile level: 1 , tile size 4009

5) Try some of the known tile sources

csharp
// You can easily create an ITileSource for a number of predefined tile servers
// with single line statements like:
var tileSource1 = KnownTileSources.Create(); // The default is OpenStreetMap
var tileSource2 = KnownTileSources.Create(KnownTileSource.BingAerial);
var tileSource3 = KnownTileSources.Create(KnownTileSource.BingHybrid);
var tileSource4 = KnownTileSources.Create(KnownTileSource.StamenTonerLite);
var tileSource5 = KnownTileSources.Create(KnownTileSource.EsriWorldShadedRelief);

The predefined tile sources are defined in a single file. Take a look at that file here to learn how you could create any tile source.

6) Use MBTiles, the sqlite format for tile data, to work with tiles stored on your device.

csharp
var mbtilesTilesource = new MbTilesTileSource(new SQLiteConnectionString("Resources/world.mbtiles", false));
var mbTilesTile = await mbtilesTilesource.GetTileAsync(new TileInfo { Index = new TileIndex(0, 0, 0) });
Console.WriteLine($"This is a byte array of an image file loaded from MBTiles with size: {mbTilesTile.Length}");

Output:

bash
This is a byte array of an image file loaded from MBTiles with size: 27412

The above code can also be found in the BruTile sample called BruTile.GettingStarted in the Samples folder of this repository.

Supported tile service protocols:

  • WMTS
  • TMS
  • OSM (Like TMS with inverted y-axis)
  • WMS (tiled requests to a regular WMS)
  • ArcGIS Tile Server
  • WMS-C

Roadmap

  • Stability is currently our primary focus.

Projects that use BruTile

  • ArcBruTile a plugin for ArcGIS
  • SharpMap a GIS library
  • Mapsui a MapComponent for Xamarin.Android. Xamarin.iOS, UWP and WPF
  • DotSpatial a GIS library that is used in HydroDesktop

License

Apache 2.0

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#brutilemapmappingosm

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言