如何在Android中使用的图形页面KML文件 [英] How to use kml file on mapView in Android

查看:125
本文介绍了如何在Android中使用的图形页面KML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何加载一个已经创建的KML文件到的MapView编程? KML文件存储在SD卡。我有一个mapActivity已经成立。 难道我只是SAX解析KML文件,并使用绘图方法创建的边界? 下面是KML文件存储在手机上的一个片段

I was wondering how to load an already created kml file into the mapview programatically? The kml file is stored in the SDcard. I have a mapActivity already set up. Do I just SAX parse the kml file and use the draw method to create the boundary? Here is a snippet of the kml file stored on the phone

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com    
/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org
/2005/Atom">
<Document>
      <name>TY09-46.kml</name>
      <open>1</open>
           <Style id="sn_ylw-pushpin594">
            <LineStyle>
               <color>ff0000ff</color>
            </LineStyle>
            <PolyStyle>
               <fill>0</fill>
            </PolyStyle>
           </Style>

     <Folder>
          <name>PLOTS</name>
          <Placemark>
            <name>4</name>
            <styleUrl>#m_ylw-pushpin</styleUrl>
            <ExtendedData>
              <SchemaData schemaUrl="#PLOTS">
                <SimpleData name="PLOT">4</SimpleData>
                <SimpleData name="SUB">43376H-3</SimpleData>
                <SimpleData name="RADIUS">10</SimpleData>
                <SimpleData name="DATE"></SimpleData>
             </SchemaData>
           </ExtendedData>
          <Point>

                       <coordinates>-8.153864327053929,52.6070098595707,0</coordinates>
          </Point>
          </Placemark>
          <Schema name="PLOTS" id="PLOTS">
              <SimpleField name="Name" type="string"></SimpleField>
              <SimpleField name="Description" type="string"></SimpleField>
              <SimpleField name="NAME" type="string"></SimpleField>
              <SimpleField name="PLOT" type="string"></SimpleField>
              <SimpleField name="SUB" type="string"></SimpleField>
              <SimpleField name="RADIUS" type="string"></SimpleField>
              <SimpleField name="DATE" type="string"></SimpleField>
 </Schema>
</Folder>
<Folder>

    <name>SP</name>
    <Placemark>
        <styleUrl>#sn_ylw-pushpin595</styleUrl>
        <ExtendedData>
            <SchemaData schemaUrl="#SP">
                <SimpleData name="SP">TY09-46</SimpleData>
                <SimpleData name="NAME">KILMORE</SimpleData>
                <SimpleData name="COMPARTMENT">43376H</SimpleData>
                <SimpleData name="Area(ha)">4.77</SimpleData>
            </SchemaData>
        </ExtendedData>
        <Polygon>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>

        -8.15152443718635,52.6069634555448,0 -8.15167900295852,52.60657535116457,0 
        -8.151997904722112,52.60666572906325,0 -8.152255500913864,52.60666952493089,0 
        -8.152465748159944,52.60670226784825,0 -8.152723330249888,52.60670193605101,0 
        -8.153001520996146,52.60677998372832,0 -8.153272487636542,52.60673011345997,0 
        -8.153604662035111,52.60673793654373,0 -8.153855465839483,52.60673761107371,0 
        -8.154113091575701,52.6067496561955,0 -8.154316446061474,52.60674939146879,0 
        -8.154526680695481,52.60677800407948,0 -8.1547909107514,52.6067405191218,0 
        -8.155129659842043,52.60669055601552,0 -8.155665012923913,52.60664858708871,0 
        -8.155733134253261,52.60674341087193,0 -8.156426186040738,52.60720468431717,0 
        -8.156426744752794,52.60736149687183,0 -8.156521747808993,52.60739025804426,0 
        -8.156589327562957,52.60733239541656,0 -8.156691359613109,52.60743130047566,0 
        -8.157027610874598,52.60752553463963,0 -8.157125642906603,52.60761798596194,0 
        -8.15722677605071,52.60792549492925,0 -8.15739480599737,52.60838296370868,0 
        -8.157313665670758,52.60861291590776,0 -8.156795853691008,52.60870383700606,0 
        -8.156713746651064,52.60870381194006,0 -8.156458403249635,52.60863659457699,0 
        -8.156152800676889,52.60848018453881,0 -8.156112216224379,52.60850499801612,0 
        -8.156281949476131,52.60857905418559,0 -8.156160049140089,52.60861222825434,0 
        -8.155949863296714,52.60860012514034,0 -8.155867521806488,52.60831962030564,0 
        -8.155772502523375,52.60828673196865,0 -8.155684554771863,52.60833636755914,0 
        -8.155494969642607,52.60839851652946,0 -8.155433654194548,52.60831193703474,0 
        -8.155250701618023,52.60833281026391,0 -8.154734951121416,52.60817254511656,0 
        -8.154375157507616,52.60802445458578,0 -8.154015337366687,52.60786810966418,0 
        -8.153703186916681,52.60777360178353,0 -8.153316199110874,52.60760078331938,0 
        -8.152623934011123,52.60735820397802,0 -8.152115040280407,52.60721442523652,0 
        -8.151944890877582,52.60701656365475,0 -8.151741221358709,52.60692603807063,0 
        -8.151788884937805,52.60698787699173,0 -8.151809448800298,52.60705387728972,0 
        -8.151762056143543,52.60707044467551,0 -8.151646678543326,52.60702932577333,0 
        -8.15152443718635,52.6069634555448,0 
                    </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
    </Placemark>

<Schema name="Subs" id="Subs">
    <SimpleField name="Name" type="string"></SimpleField>
    <SimpleField name="Description" type="string"></SimpleField>
    <SimpleField name="COMPARTMENT" type="string"></SimpleField>
    <SimpleField name="SUB" type="string"></SimpleField>
    <SimpleField name="Area(ha)" type="string"></SimpleField>
    <SimpleField name="SPECIE" type="string"></SimpleField>
    <SimpleField name="PLAN_YEAR" type="int"></SimpleField>
    </Schema>
</Folder>
<Folder>
    <name>PHOTOS</name>
    <open>1</open>
    <GroundOverlay>
        <name>TY09-46 COM.43376H</name>
        <color>a3ffffff</color>
        <Icon>
            <href>Z:/Alex/Maps_and_layers/Ireland/Coillte forest/S2
                              /TYPPERARY/TY09-46/Layers/Google/TY09-46-2.TIF</href>
            <viewBoundScale>0.75</viewBoundScale>
        </Icon>
        <altitudeMode>clampToGround</altitudeMode>
        <gx:altitudeMode>clampToSeaFloor</gx:altitudeMode>
        <LatLonBox>
            <north>52.61133873114665</north>
            <south>52.60348773114665</south>
            <east>-8.145864564106052</east>
            <west>-8.163791564106058</west>
        </LatLonBox>
    </GroundOverlay>

    </Folder>
</Document>
</kml>

我是一名学生,是新到Android因此任何帮助是极大的AP preciated 谢谢

I am a student and am new to android so any help be greatly appreciated Thanks

推荐答案

您可以解析使用类似一个SAXParser的KML文件,并得到了坐标的方式点。

You could parse the KML file using something like a SAXParser and get the coordinates for your way-points.

然后,你可以把它们画在MapActivity:链接

Then, you could draw them on the MapActivity: Link

这篇关于如何在Android中使用的图形页面KML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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