Tsu*_*aze 3 android map mapbox
如何在Android上显示MapBox图块?我尝试将它与OSMDroid一起使用,而Nutiteq则没有成功.MapBox有一个android库吗?
例如,我使用此代码在OSMDroid上实现MapBox:http://blog.spatialnetworks.com/post/2012/07/using-mbtiles-on-android-with-osmdroid
XYTileSource MBTILESRENDER = new XYTileSource("mbtiles", ResourceProxy.string.offline_mode, 1, 20, 256, ".png", "http://example.org/");
DefaultResourceProxyImpl mResourceProxy = new DefaultResourceProxyImpl(this.getApplicationContext());
SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(this.getActivity());
File f = new File(Environment.getExternalStorageDirectory(), "mymbtilesfile.mbtiles");
IArchiveFile[] files = { MBTilesFileArchive.getDatabaseFileArchive(f) };
MapTileModuleProviderBase moduleProvider = new MapTileFileArchiveProvider(simpleReceiver, MBTILESRENDER, files);
MapTileProviderArray mProvider = new MapTileProviderArray(MBTILESRENDER, null, new MapTileModuleProviderBase[] { moduleProvider });
this.mMapView = new MapView(this, 256, mResourceProxy, mProvider);
Run Code Online (Sandbox Code Playgroud)
但它没有用,我想直接从网上加载MbTiles.
pt2*_*121 16
编辑
对于那些投票的人,我在sdk存在之前回答了这个问题.
=============================================
我认为Nutiteq看起来很有前途.他们的API有很多功能.此外,他们的演示项目也是内联评论.你可以查看这个项目.特别是,MBTilesMapActivity可能是您正在寻找的东西.该课程展示了如何使用mbtiles:
// 1. Get the MapView from the Layout xml
mapView = (MapView) findViewById(R.id.mapView);
// 2. create and set MapView components
Components components = new Components();
mapView.setComponents(components);
// 3. Define map layer for basemap
MBTilesMapLayer dbLayer = new MBTilesMapLayer(new EPSG3857(), 0, 19, file.hashCode(), file, this);
mapView.getLayers().setBaseLayer(dbLayer);
...
// 4. Start the map - mandatory
mapView.startMapping();
// 5. zoom buttons using Android widgets - optional
// get the zoomcontrols that was defined in main.xml
ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
Run Code Online (Sandbox Code Playgroud)
您还可以查看我的玩具项目,该项目是从他们的演示中修改的.基本上,我的应用程序允许用户输入mbtiles文件的URL.然后,它下载文件并将其加载到MapView.
如果你真的必须坚持使用OSMDroid,这可能会有所帮助.我没有机会尝试它.
希望这可以帮助.
MapBox有一个android库吗?
在Android上使用Mapbox的最佳方式是Mapbox Android SDK!它是官方代码库,一个支持矢量切片,地图动画和其他一系列的开源项目 - 它也被设计为易于从系统默认地图过渡到.
回覆:
但它没有用,我想直接从网上加载MbTiles.
由于MBTiles文件是一组通常非常大的磁贴 - 并且无法单独请求 - 因此通常不会直接加载它来显示地图.SDK采用的方法是动态缓存,如本例所示.该示例使用Mapbox,但缓存机制是通用的,可以与任何磁贴服务器一起使用.
披露:我为Mapbox工作,偶尔会处理我们的本机代码的核心,包括Android SDK.
| 归档时间: |
|
| 查看次数: |
11471 次 |
| 最近记录: |