2016-10-17 46 views
0

它不會查看。我試着按照我在網上找到的所有說明,比如在stackoverflow或github中,但它仍然不起作用。它沒有查看我擁有的瓷磚。我有一個在MOBAC中創建的OSMPublicTransport地圖。我將它重新命名爲PUBLIC_TRANSPORT.zip,然後將它放在我的sdcard/osmdroid /上的LG手機上。我試着運行它,但它不查看瓦片,只是網格。這裏是我的代碼:OSM Public_Transport瓷磚在放入Android Studio時無法從Mobile Atlas Creator工作

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

@ cricket_007好吧,我很抱歉 – Temmie

回答

0

打開壓縮文件,應該有一個單一的文件夾。這是瓷磚來源名稱。我敢打賭,它不匹配它被設置在源實例

無論是在zip文件夾重命名或更新您的代碼相匹配的源名稱

+0

.zip文件中的源也被稱爲PUBLIC_TRANSPORT,但它仍然不會工作。 – Temmie