gpt4 book ai didi

android - 如何在 Android 的 mapView 上使用 kml 文件

转载 作者:行者123 更新时间:2023-11-30 04:41:52 25 4
gpt4 key购买 nike

我想知道如何以编程方式将已经创建的 kml 文件加载到 map View 中?kml 文件存储在 SD 卡中。我已经设置了一个 mapActivity。我是否只使用 SAX 解析 kml 文件并使用 draw 方法创建边界?这是存储在手机上的 kml 文件的 fragment

<?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 的新手所以非常感谢任何帮助谢谢

最佳答案

您可以使用 SAXParser 之类的工具解析 KML 文件并获取路径点的坐标。

然后,您可以在 MapActivity 上绘制它们:Link

关于android - 如何在 Android 的 mapView 上使用 kml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5848445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com