【问题标题】:OSM Public_Transport Tiles won't work from Mobile Atlas Creator when put into Android Studio将 OSM Public_Transport Tiles 放入 Android Studio 时,Mobile Atlas Creator 将无法工作
【发布时间】: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 好吧,对不起

标签: android offline osmdroid


【解决方案1】:

打开 zip 文件,里面应该有一个文件夹。那是瓦片源名称。我敢打赌它与源实例上设置的不匹配

重命名 zip 中的文件夹或更新代码以匹配源名称

【讨论】:

  • .zip 文件中的源代码也称为 PUBLIC_TRANSPORT,但它仍然不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-29
  • 1970-01-01
  • 2021-08-22
  • 2014-04-06
  • 1970-01-01
相关资源
最近更新 更多