谷歌地图Android Api KML LineString是不可见的

时间:2017-11-07 13:42:07

标签: android google-maps kml

我做了一些kml文件,它应该根据gps坐标绘制线条。 这是kml文件:

<?xml version="1.0" encoding="UTF-8"?>
<kml>
<Document>
    <Style id="test">
        <LineStyle>
            <color>7fff00ff</color>
            <width>5</width>
        </LineStyle>
        <PolyStyle>
            <color>7fff00ff</color>
        </PolyStyle>
    </Style>
    <Folder id="Routes">
        <Placemark id="ID_00000">
            <name>Start of route</name>
            <description><![CDATA[]]></description>
            <styleUrl>#test</styleUrl>
            <LineString>
                <coordinates>
                    49.8116217,23.9886087 49.8119524,23.9886215 49.81191322,23.98872789 49.81192775,23.98874378 49.81195003,23.98876441 49.81197385,23.98878094 49.81199604,23.98879068 49.81201433,23.98878936 49.81203041,23.98877801 49.81204601,23.98876777 49.81205742,23.98875813 49.81207007,23.98875112 49.8120715,23.98873428 49.81208366,23.98872694 49.81210081,23.98872613 49.81211374,23.98872721 49.81212506,23.98873003 49.81213969,23.98873623 49.81215322,23.98874284 49.8117823,23.9884488 49.81216501,23.98874519 49.81217678,23.98874744 49.81219024,23.98874933 49.81220564,23.9887507 49.81222275,23.98874661 49.8122392,23.98873928 49.81225512,23.98873407 49.81227164,23.98873212 49.81228828,23.98873269 49.812303,23.98873105 49.81231667,23.98872926 49.81233102,23.98872646 49.81234466,23.98872307 49.81235693,23.98872118 49.81236886,23.98872023 49.81238219,23.98871889 49.81239516,23.98872016 49.81240862,23.98872264 49.81242284,23.98872563 49.81243939,23.98873045 49.81245614,23.9887331 49.81247243,23.98873538 49.81248877,23.98873906 49.81250539,23.98874298 49.81252168,23.98874805 49.81253515,23.98875107 49.81254892,23.98875293 49.81256172,23.98875307 49.81257442,23.98874878 49.81258532,23.98874399 49.81259807,23.98874194 49.81261076,23.98874262 49.81262245,23.98874403 49.81263252,23.98874607 49.81264352,23.98874748 49.81265546,23.98874735 49.81266894,23.98874526 49.81268259,23.9887446 49.81269652,23.98874683 49.81271198,23.98874989 49.81272873,23.98874939 49.81274414,23.98875052 49.81275946,23.98875715 49.81277472,23.98876439 49.81278921,23.98877154 49.81280219,23.98877755 49.8128151,23.98878299 49.81282808,23.98878867 49.81283912,23.98879488 49.81285104,23.98880087 49.81286598,23.98880662 49.81287988,23.98881048 49.81289228,23.9888126 49.81290673,23.98881641 49.81292176,23.98882141 49.81294426,23.9888144 49.81296746,23.98880294 49.81298199,23.98879367 49.81298993,23.98878524 49.81300107,23.98878182 49.81301283,23.98878275 49.81302304,23.9887857 49.81303367,23.98878271 49.81304323,23.9887773 49.81306225,23.98877587 49.8130758,23.98878347 49.81308868,23.98879562 49.81309945,23.98880649 49.81311018,23.98881294 49.81312262,23.98881945 49.81313672,23.98882793 49.8131524,23.98883983 49.81316561,23.98885055 49.81317575,23.9888566 49.81318699,23.98886206 49.81319977,23.98886887 49.81321207,23.98887598 49.81322535,23.98888452 49.8132413,23.98888978 49.81325415,23.9888941 49.81326582,23.98889714 49.8132788,23.98889953 49.81329279,23.98890332 49.81330842,23.98891355 49.81332519,23.98892529 49.8133399,23.98893665 49.81335525,23.98894859 49.81337056,23.98896094 49.81338534,23.98896934 49.81339873,23.98897477 49.81341343,23.98897674 49.81342948,23.98897377 49.81344366,23.98896347 49.81345552,23.98894519 49.81346407,23.98892566 49.81346854,23.98890878 49.81347148,23.98888911 49.81347675,23.9888693 49.8134859,23.98885213 49.81349818,23.98883891 49.81350861,23.98882082 49.81351944,23.98880091 49.81352505,23.98877637 49.81352787,23.98875535 49.81353083,23.98873255 49.81353493,23.9887077 49.81353878,23.98868495 49.81354223,23.98866667 49.81354384,23.98865021 49.81353963,23.98862709 49.81353195,23.98860221 49.81355727,23.98860096 49.81357263,23.98859847 49.81358477,23.98859337 49.81359438,23.98859038 49.81360411,23.9885948 49.81361507,23.98860363
                </coordinates>
            </LineString>
        </Placemark>
    </Folder>
</Document>

以及我如何将此文件添加到地图中:

public static void parseFile(Context context, String id, GoogleMap map) throws IOException, XmlPullParserException {
   String file = id + HomeActivity.KML;
   KmlLayer layer = createKmlLayer(map, file);
   layer.addLayerToMap();
}
  private static KmlLayer createKmlLayer(GoogleMap map, String kmlFile) {
    KmlLayer layer = null;

    try {
        InputStream inputStream = GeofenceApplication.getContext().getAssets().open(kmlFile);
        layer = new KmlLayer(map, inputStream, GeofenceApplication.getContext());
    } catch (Exception exception) {
        logger.error("ERROR", exception);
    }

    return layer;
}

当我运行该代码时,我没有看到该行。 那么我犯了错误?

0 个答案:

没有答案