【问题标题】:Osmdroid render not expected like that - TileSource PublicTransportOsmdroid 渲染不会像那样 - TileSource PublicTransport
【发布时间】:2015-04-24 05:09:46
【问题描述】:

我遇到了一些需要使用 OSMPublicTransport tilesource 的应用程序的问题。

点击here查看奇怪的 MapView。那么,为什么在我的应用中出现这种丑陋的东西? 其他 tilesource 的工作就像一个魅力。

我不知道为什么它会这样显示地图视图。 我在等官方website这样的结果

这是我的 XML 文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <org.osmdroid.views.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tilesource="OSMPublicTransport" />
</RelativeLayout>

以及我如何声明我的观点

protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            mapView = FindViewById<MapView> (Resource.Id.mapview);

            mapView.SetTileSource (TileSourceFactory.PublicTransport);

            mapView.SetBuiltInZoomControls (true);
            mapView.SetMultiTouchControls (true);
       }

提前谢谢你!

【问题讨论】:

    标签: android osmdroid


    【解决方案1】:

    OSMPublicTransport 瓦片是叠加瓦片。它们旨在显示在现有图像之上。所以使用常规的瓦片源,然后为叠加图像添加一个新的 TilesOverlay:

    // Add tiles layer
    MapTileProviderBasic provider = new MapTileProviderBasic(getApplicationContext());
    provider.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);
    TilesOverlay tilesOverlay = new TilesOverlay(provider, this.getBaseContext());
    mapView.getOverlays().add(tilesOverlay);
    

    【讨论】:

      【解决方案2】:

      osmdroid PublicTransport 的磁贴 url 是:http://openptmap.org/tiles/

      你提到的tiles url(osm官方公交地图)结构如下:http://b.tile.thunderforest.com/transport/

      您可能会在 osmdroid 中提出问题,因为它们的 url 似乎已过时。

      您还可以构建自己的图块源。很简单,通过查看osmdroid TileSourceFactory 源来获取示例。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多