简体   繁体   中英

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.

But, I load style from local filesystem, like below: (Sorry, I'm Xamarin user, so write in 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

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? (From file, DB, or memory..)

In Android,

First, declare a map_style.json inside assets folder

Then in Java code

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

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

MapBox have a plan to implement local interface:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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