公司网站可以不买域名吗,网站图片设计制作,什么是网站维护,企业管理软件公司本文通过获取在线和离线地图数据#xff0c;使用开源Rust项目搭建瓦片地图服务#xff0c;并使用DevExpress的MapControl控件使用自建地图服务
获取地图数据
获取地图数据有很多种方式#xff0c;这里分别用在线和离线地图数据举例说明
在线下载瓦片地图
打开在线瓦片地…本文通过获取在线和离线地图数据使用开源Rust项目搭建瓦片地图服务并使用DevExpress的MapControl控件使用自建地图服务
获取地图数据
获取地图数据有很多种方式这里分别用在线和离线地图数据举例说明
在线下载瓦片地图
打开在线瓦片地图下载网站【划范围】勾选精度【下载】 下载后得到压缩包“tiles.zip”
下载OpenStreetMap离线地图数据
OpenStreetMap是一个自由的街道级世界地图它由日益壮大的绘图者团体创造。 任何人都可以编辑OpenStreetMap
数据下载地址Geofabrik Download Server 下载后缀为“.bz2”格式的文件使用开源项目工具bzip2处理
比如下载文件为“antarctica-latest.osm.bz2”处理后得到文件“antarctica-latest.osm”
bunzip2 antarctica-latest.osm.bz2接着处理.osm文件使用maperitive打开maperitive软件打开文件“antarctica-latest.osm”
右下角【Map Sources】取消勾选“Web map” 在【Command prompt:】输入如下命令maxzoom设置范围1-5范围最大值越大看到细节更多Tiles文件夹体积也越大
generate-tiles minzoom1 maxzoom5运行过后在maperitive的安装目录下就会多一个Tiles文件夹
搭建开源瓦片地图服务
这里我使用本人用Rust开发的tiles_rs启动服务的命令如下
tiles_rs.exe --tiles-dirC:\Users\Tiles --host0.0.0.0 --port5000 --log_levelwarntiles-dir: 为瓦片地图数据文件夹host: 服务器IP地址port: 端口log_level: 日志级别
更多使用方式查看help命令
tiles_rs.exe --helpOverviewTiles_rs is an open-source project that aims to provide a fast and reliable tile map server implementation using Rust.
Built on top of the Actix web framework, this project offers a modern approach to serving map tiles,
catering to the needs of developers working on geographic information systems (GIS) and web mapping applications.# Examplessh
tiles_rs.exe --tiles-dirC:\Users\Tiles --host0.0.0.0 --port5000 --log_levelwarn
# Api- /tiles/{z}/{x}/{y}{z} - The current zoom level.
{x} - The horizontal (X) index of the requested tile.
{y} - The vertical (Y) index of the requested tile.Usage: tiles_rs.exe [OPTIONS]Options:--tiles-dir TILES_DIRDirectory containing tile images[default: Tiles]--host HOSTHost to bind the server to[default: localhost]--port PORTPort to bind the server to[default: 5000]--log-level LOG_LEVELLog level (error, warn, info, debug, trace)[default: info]-h, --helpPrint help (see a summary with -h)-V, --versionPrint version使用地图数据
这里使用DevExpress v24.1的MapControl控件项目代码在Github只需要修改一行代码修改使用地图的数据接口模板
provider.TileUriTemplate http://IP:PORT/tiles/{1}/{2}/{3};{1} - The current zoom level.{2} - The horizontal (X) index of the requested tile.{3} - The vertical (Y) index of the requested tile.
使用刚刚在线下载的瓦片地图数据效果显示如下 参考
下载OpenStreetMap离线地图数据并搭载瓦片服务器_openstreetmap瓦片下载-CSDN博客OpenStreetMapDataProvider.TileUriTemplate Property | WinForms Controls | DevExpress Documentationhttps://github.com/DevExpress-Examples/winforms-map-connect-to-openstreetmap.githttp://maperitive.net/https://github.com/VinciYan/tiles_rs.githttps://github.com/philr/bzip2-windows.git