android自定义离线地图,MapBox GL Android:已下载但未使用的自定义磁贴源的离线地图...

对于我们的应用程序,我目前正在将地图框与自定义地图图块集成(如

here所述).使用OfflineManager和OfflineTilePyramidRegionDefinition,一切都运行正常,我可以下载磁贴并在mbgl-offline.db中找到它们,但它们似乎没有在应用中使用.据报道,离线区域已完成,但只是没有显示.据我了解

offline documentation,在下载瓷砖后,其他一切都是“放手”.

我已经尝试了几种不同的来源(例如,OpenMapTiles.org),因为我们仍然在设置我们自己的地图图块服务器.

我在这里错过了什么吗?我非常感谢任何线索.

最好,

菲尔

更新:

以下是一些更多信息:

XML布局

android:id="@+id/mapView"

android:layout_width="match_parent"

android:layout_height="match_parent"

mapbox:center_latitude="51"

mapbox:center_longitude="7"

mapbox:style_url="http://demo.tileserver.org/styles/klokantech-basic.json"

mapbox:zoom="1"/>

下载地图数据的代码:

// Set up the OfflineManager

OfflineManager offlineManager = OfflineManager.getInstance(context);

// Create a bounding box for the offline region

LatLngBounds latLngBounds = new LatLngBounds.Builder()

.include(new LatLng(6,50))

.include(new LatLng(8,52))

.build();

// Define the offline region

OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(

mapView.getStyleUrl(),latLngBounds,9,// also tried other zoom levels

context.getResources().getDisplayMetrics().density);

// Set the metadata

byte[] metadata;

try {

JSONObject jsonObject = new JSONObject();

jsonObject.put(JSON_FIELD_REGION_NAME,"Cologne");

String json = jsonObject.toString();

metadata = json.getBytes(JSON_CHARSET);

} catch (Exception exception) {

Log.e("Failed to encode metadata: " + exception.getMessage());

metadata = null;

}

// Create the region asynchronously

offlineManager.createOfflineRegion(

definition,metadata,new OfflineManager.CreateOfflineRegionCallback() {

@Override

public void onCreate(OfflineRegion offlineRegion) {

offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);

// Monitor the download progress using setObserver

offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() {

@Override

public void onStatusChanged(OfflineRegionStatus status) {

// Calculate the download percentage and update the progress bar

double percentage = status.getRequiredResourceCount() >= 0

? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :

0.0;

if (status.isComplete()) {

// Download complete

Log.d("Region downloaded successfully.");

ReadOSRMRouteTask readOSRMRouteTask = new ReadOSRMRouteTask();

readOSRMRouteTask.execute();

} else if (status.isRequiredResourceCountPrecise()) {

// Switch to determinate state

Log.d((int) Math.round(percentage) + "% downloaded");

}

}

@Override

public void onError(OfflineRegionError error) {

// If an error occurs,print to logcat

Log.e("onError reason: " + error.getReason());

Log.e("onError message: " + error.getMessage());

}

@Override

public void mapboxTileCountLimitExceeded(long limit) {

// Notify if offline region exceeds maximum tile count

Log.e("Mapbox tile count limit exceeded: " + limit);

}

});

}

@Override

public void onError(String error) {

Log.e("Error: " + error);

}

});

在下载地图数据时,日志基本上只是垃圾邮件大量的HTTP 200s,所以一切看起来都很好.此外,脱机包报告完成,sqlite-db似乎也很好.

在离线模式下启动应用程序时,这基本上就是日志:

D/mbgl: [JNI]: nativeCreate

/com.mapbox.mapboxsdk.maps.MapView: MapView start Telemetry…

/MapboxEventManager: Telemetry initialize() called…

/MapboxEventManager: Mapbox Telemetry has already been initialized.

D/mbgl: [JNI]: nativeInitializeDisplay

D/mbgl: [JNI]: nativeInitializeContext

I/MapboxEventManager: flushEventsQueueImmediately() called…

D/MapboxEventManager: turnstile event pushed.

W/MapboxEventManager: Not connected to network,so empty events cache

and return without attempting to send events

I/com.mapbox.mapboxsdk.http.HTTPRequest: Request failed due to a

connection error: No Internet connection available.

D/mbgl: [JNI]: nativeViewResize

D/mbgl: [JNI]: nativeCreateSurface

D/mbgl: [JNI]: nativeFramebufferResize

I/TelemetryService: onStartCommand() called

D/mbgl: [JNI]: nativeViewResize

D/mbgl: [JNI]: nativeFramebufferResize

I/Timeline: Timeline: Activity_idle id:

android.os.BinderProxy@41bd28b8 time:609768

W/MapboxEventManager: Not connected to network,so empty events cache

and return without attempting to send events

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好,针对您的问题,我可以为您提供一些思路和参考。 首先,您可以使用Mapbox GL JS库来创建室内地图Mapbox GL JS是一个开的JavaScript库,它可以帮助您创建交互式、高性能的地图应用程序。此外,Mapbox还提供了丰富的地图数据和API,可以帮助您快速构建地图应用。 其次,您可以使用Three.js库来创建3D模型和动画。Three.js是一个轻量级的JavaScript库,它可以帮助您在网页上呈现3D图形和动画。您可以使用Three.js来创建室内场景和模型,然后将其集成到Mapbox GL JS地图中。 下面是一些具体的步骤和参考资料: 1. 创建Mapbox GL JS地图:您可以参考Mapbox官方文档来学习如何创建Mapbox GL JS地图。文档链接:https://docs.mapbox.com/mapbox-gl-js/api/ 2. 创建Three.js场景和模型:您可以使用Three.js来创建室内场景和模型。首先,您需要创建一个Three.js场景,然后向其中添加模型和光。您可以参考Three.js官方文档来学习如何创建场景和模型。文档链接:https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene 3. 将Three.js场景和模型集成到Mapbox GL JS地图中:您可以使用Mapbox GL JS的自定义图层功能来将Three.js场景和模型集成到地图中。首先,您需要创建一个自定义图层,并在其中嵌入Three.js场景。然后,您可以使用Mapbox GL JS的渲染回调函数来更新场景和模型。您可以参考Mapbox GL JS官方文档来学习如何创建自定义图层。文档链接:https://docs.mapbox.com/mapbox-gl-js/example/custom-style-layer/ 4. 其他参考资料:以下链接提供了一些关于Mapbox GL JS和Three.js集成的示例和教程,您可以参考它们来学习如何使用这些库来创建室内地图。 - Mapbox GL JS + Three.js 实现室内地图:https://zhuanlan.zhihu.com/p/157280541 - Threebox:一个将Three.js集成到Mapbox GL JS的库:https://github.com/jscastro76/threebox - 在Mapbox GL JS中使用Three.js来创建3D建筑物:https://blog.mapbox.com/using-three-js-to-build-complex-3d-buildings-in-mapbox-gl-js-8e7d3c444f4c 希望这些信息能够帮助到您!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值