【问题标题】:Leaflet rendering tiles from device's local storage来自设备本地存储的传单渲染图块
【发布时间】:2013-11-13 19:08:11
【问题描述】:

我正在尝试使用传单构建一个 android 应用程序,该应用程序可以使用本地存储在设备 sd 卡上的图块离线工作。这可能吗,是否有推荐的方法来引用 url 中的本地驱动器?我已经尝试了所有组合,但无法加载瓷砖。我确实有一个使用 OSMdroid 构建的类似应用程序,它可以很好地检索本地存储的图块。我只是想使用传单获得相同的工作。

有什么建议吗?或者这是不可能的? 谢谢!

我的应用活动的 onCreate:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mWebView= (WebView)findViewById(R.id.mapview);
        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.loadUrl("file:///android_asset/map.html");
    }

我在 assets 文件夹中有 map.html 和 leaflet.js。下面是我的 map.html 的 sn-p:(我认为问题出在 url - /sdcard/osmdroid/...)

<script>

    var map = L.map('map');

    L.tileLayer('/sdcard/osmdroid/', {
        attribution: 'Map data from MOBAC',
        maxZoom: 18
    }).addTo(map);
    map.locate({setView: true, maxZoom: 16});
    function onLocationFound(e) {
        var radius = e.accuracy / 2;

        L.marker(e.latlng).addTo(map)
        .bindPopup("You are within " + radius + " meters from this point").openPopup();

        L.circle(e.latlng, radius).addTo(map);
    }

</script>

【问题讨论】:

    标签: android leaflet osmdroid


    【解决方案1】:

    这是一个例子,特别是putMapsOnSd 将它保存在 sd https://github.com/tomkincaid/PathExample/blob/master/src/com/example/pathexample/MainActivity.java

    他在onCreate阅读了这个文件

    【讨论】:

    猜你喜欢
    • 2018-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    • 2022-11-15
    • 2017-07-28
    • 1970-01-01
    • 2013-01-10
    相关资源
    最近更新 更多