它不会查看。我试着按照我在网上找到的所有说明,比如在stackoverflow或github中,但它仍然无法工作。它不会查看我的瓷砖。我有一个在MOBAC中创建的OSMPublicTransport Map。我将其重命名为PUBLIC_TRANSPORT.zip,然后将其放在我的sdcard / osmdroid /上的LG手机上。我尝试运行它,但它不查看磁贴,只查看网格。这是我的代码:
package com.example.android.paths;
import org.osmdroid.ResourceProxy;
import org.osmdroid.api.IMapController;
import org.osmdroid.tileprovider.tilesource.ITileSource;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.tileprovider.tilesource.XYTileSource;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import java.io.File;
public class MainActivity extends Activity {
public static File OSMDROID_PATH = new File(Environment.getExternalStorageDirectory(), "osmdroid");
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView map = (MapView) findViewById(R.id.map);
map.setTileSource(new XYTileSource("PUBLIC_TRANSPORT", 14, 16, 256, ".png", new String[] {
"http://otile1.mqcdn.com/tiles/1.0.0/map/",
"http://otile2.mqcdn.com/tiles/1.0.0/map/",
"http://otile3.mqcdn.com/tiles/1.0.0/map/",
"http://otile4.mqcdn.com/tiles/1.0.0/map/"}));
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
map.setUseDataConnection(false); //optional, but a good way to prevent loading from the network and test your zip loading.
IMapController mapController = map.getController();
mapController.setZoom(14);
GeoPoint startPoint = new GeoPoint(121.026764, 14.566305);
mapController.setCenter(startPoint);
}
}
我的xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.osmdroid.views.MapView android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
答案 0 :(得分:0)
打开zip文件,其中应该有一个文件夹。这是瓷砖源名称。我敢打赌它与源实例上设置的不匹配
重命名zip文件夹或更新代码以匹配源名称