Osmdroid脱机文件 [英] Osmdroid offline file
问题描述
我有一个osmdroid图,我想无论从MOBAC的osmdroid zip或gemf文件加载离线瓷砖。我看着它,无论去哪它说,只是把它放在SD卡/ osmdroid。但它不工作,我是否需要改变某些事情了code?
I have an osmdroid map, and i want to load offline tiles from either MOBAC's osmdroid zip or gemf file. I looked into it and everywhere i go it says just put it in sdcard/osmdroid. But it doesnt work, do i need to change something in the code?
public class Map extends Activity {
private IMapView mMapView;
private static IMapController mMapController;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
mMapView = (MapView) findViewById(R.id.mapview);
((MapView) mMapView).setBuiltInZoomControls(true);
mMapController = mMapView.getController();
mMapController.setZoom(13);
GeoPoint geoPecs = new GeoPoint(46.070833,18.233056);
mMapController.setCenter(geoPecs);
mProvider = new MapTileProviderBasic(getApplicationContext());
mCustomTileSource = new XYTileSource("Turaterkep", null, 13, 15, 256, ".png", "http://users.atw.hu/perzsa/map/Turaterkep/");
mProvider.setTileSource(mCustomTileSource);
mTilesOverlay = new TilesOverlay(mProvider,this.getBaseContext());
mMapView.getOverlays().add(mTilesOverlay);
更新:
我好不容易从网上加载瓷砖样品包括到osmdroid,我更新了code作为嗯,我想我要开始这个样品,也许我可以从加载本地主机?病检查回来
update: I managed to load the tiles from online with the samples included to osmdroid, i updated the code as well, i guess i have to start with this sample, maybe i can load from localhost? ill check back
图:
http://i.stack.imgur.com/CoZT1.png
推荐答案
我经历了同样的问题,我用网上的瓷砖从Mapnik的解决了这个问题。这样一来,我的应用程序中创建自己的移动设备的路径(手机/ osmdroid /瓷砖/ Mapnik的)。
I experienced the same problem and I solved it by using online tiles from Mapnik. This way, my application created the path in my mobile device (phone/osmdroid/tiles/Mapnik).
mMapView.setTileSource(TileSourceFactory.Mapnik);
您还可以通过添加以下内容到XML的文件,并在你的图形页面添加tilesouce:
You can also add the tilesouce by adding this to your xml-file and in your mapview:
tilesource="Mapnik"
不要忘记指定您不希望通过添加下载数据的应用程序:
Dont forget to specify that you don't want the application to download data by adding:
mMapView.setUseDataConnection(false);
做完这些后,你可以得到应用程序脱机使用瓷砖,只要按照本指南: HTTP: //www.haakseth.com/?p=30
这篇关于Osmdroid脱机文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!