使用OsmBonusPack解析和查看geojson [英] Parse and view geojson with OsmBonusPack

查看:164
本文介绍了使用OsmBonusPack解析和查看geojson的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解析geojson并查看osmbonuspack&上的数据osmdroid mapview.我使用了这个教程:

I want to parse geojson and view data on osmbonuspack & osmdroid mapview. I used this totorial:

https://code.google.com/p/osmbonuspack/wiki/Tutorial_4

有什么方法可以解析kml这样的geojson文件吗?

IS there any way to parse a geojson file like kml?

谢谢

推荐答案

这是我如何使用给定的GeoJSON文件和相关链接创建新的叠加层.

Here is how I created a new overlay using a given GeoJSON file and the link given in question.

private void addAdditionalLayer () {
    String jsonString = null;
    try {
        InputStream jsonStream = getAssets().open("myLocations.geojson");
        int size = jsonStream.available();
        byte[] buffer = new byte[size];
        jsonStream.read(buffer);
        jsonStream.close();
        jsonString = new String(buffer,"UTF-8");
    } catch (IOException ex) {
        ex.printStackTrace();
        return;
    }

    KmlDocument kmlDocument = new KmlDocument();
    kmlDocument.parseGeoJSON(jsonString);
    FolderOverlay myOverLay = (FolderOverlay)kmlDocument.mKmlRoot.buildOverlay(mapView,null,null,kmlDocument);
    mapView.getOverlays().add(myOverLay );
    mapView.invalidate();

}

这篇关于使用OsmBonusPack解析和查看geojson的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆