我可以解析kml文件以显示Android中的路径或点吗?请你能帮助我吗?
这是kml示例代码,我想在android谷歌地图中显示:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Paths</name>
<description>Examples of paths. Note that the tessellate tag is by default
set to 0. If you want to create tessellated lines, they must be authored
(or edited) directly in KML.</description>
<Style id="yellowLineGreenPoly">
<LineStyle>
<color>7f00ffff</color>
<width>4</width>
</LineStyle>
<PolyStyle>
<color>7f00ff00</color>
</PolyStyle>
</Style>
<Placemark>
<name>Absolute Extruded</name>
<description>Transparent green wall with yellow outlines</description>
<styleUrl>#yellowLineGreenPoly</styleUrl>
<LineString>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<coordinates> -112.2550785337791,36.07954952145647,2357
-112.2549277039738,36.08117083492122,2357
-112.2552505069063,36.08260761307279,2357
-112.2564540158376,36.08395660588506,2357
-112.2580238976449,36.08511401044813,2357
-112.2595218489022,36.08584355239394,2357
-112.2608216347552,36.08612634548589,2357
-112.262073428656,36.08626019085147,2357
-112.2633204928495,36.08621519860091,2357
-112.2644963846444,36.08627897945274,2357
-112.2656969554589,36.08649599090644,2357
</coordinates>
<LineString>
</Placemark>
</Document>
</kml> …Run Code Online (Sandbox Code Playgroud) 我有一个按钮,通过意图在我的设备上启动谷歌地图应用程序.我希望能够传递一个生成KML文件的php页面.
我在使用JS中的googlemaps api之前在网站上做过这个 - 但它似乎不适用于Android.
我的php文件如下;
<?php
echo '<kml xmlns="http://www.google.com/earth/kml/2">';
echo '<Placemark>';
echo '<name>Google Inc.</name>';
echo '<description>1600 Amphitheatre Parkway, Mountain View, CA 94043</description>';
echo '<Point>';
echo '<coordinates>-122.0841430, 37.4219720, 0</coordinates>';
echo '</Point>';
echo '</Placemark>';
echo '</kml>';
?>
Run Code Online (Sandbox Code Playgroud)
启动时间:
final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=http://website.com/kml_gen.php"));
startActivity(myIntent);
Run Code Online (Sandbox Code Playgroud)
它启动地图,找到文件 - 但不会显示它'因为它包含错误'.
这是不可能的,还是有其他方法来构建可能有用的意图?