【发布时间】:2016-10-17 07:24:14
【问题描述】:
它不会显示。我尝试遵循我在网上找到的所有说明,例如在 stackoverflow 或 github 中,但它仍然无法正常工作。它不查看我拥有的瓷砖。我有一个在 MOBAC 中创建的 OSMPublicTransport 地图。我将它重命名为 PUBLIC_TRANSPORT.zip,然后将其放在我的 LG 手机上的 sdcard/osmdroid/ 上。我尝试运行它,但它不查看磁贴,只查看网格。这是我的代码:
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>
【问题讨论】:
-
评论不会碰撞。对问题进行编辑,但也不要仅仅为了添加“bump”而进行编辑
-
@cricket_007 好吧,对不起