简体   繁体   English

如何在MapBox iOS / Android SDK中使用离线样式定义或地图图块?

[英]How to use offline style definitions or map tiles in MapBox iOS/Android SDK?

I want to make offline map applications using mapbox iOS/Android SDK. 我想使用mapbox iOS / Android SDK制作离线地图应用程序。

But, I load style from local filesystem, like below: (Sorry, I'm Xamarin user, so write in c#) 但是,我从本地文件系统加载样式,如下所示:(对不起,我是Xamarin用户,所以用C#编写)

var bundlePath = NSBundle.MainBundle.BundlePath; 
var filePath = Path.Combine(bundlePath, "gsimaps.json"); 
var styleURL = NSUrl.CreateFileUrl (filePath, null);
var mapView = new MapView (Bounds, styleURL);

Then error shows: 然后错误显示:

[ERROR] {Map}[Setup]: loading style failed: response class is not NSHTTPURLResponse [错误] {地图} [设置]:加载样式失败:响应类不是NSHTTPURLResponse

Are there any way to load styles from local data? 有什么方法可以从本地数据加载样式? From file, from DB, from memory, any means are OK, I want to know the way to use local data. 从文件,从数据库,从内存,任何方式都可以,我想知道使用本地数据的方式。

And also, are there any ways to use local raster tile in MapBox SDK? 而且,还有什么方法可以在MapBox SDK中使用本地栅格图块? (From file, DB, or memory..) (来自文件,数据库或内存。)

In Android, 在Android中,

First, declare a map_style.json inside assets folder 首先,在资产文件夹中声明一个map_style.json

Then in Java code 然后用Java代码

mapView.setStyleUrl("asset://map_style.json");

您应该看一下我的github项目(适用于Android / iOS / UWP的标题),但这些瓷砖的更新存在问题->瓷砖的双重更新。

MapBox have a plan to implement local interface: MapBox有实现本地接口的计划:

https://github.com/mapbox/mapbox-gl-native/issues/7471 https://github.com/mapbox/mapbox-gl-native/issues/7471

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM