我可以解析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) 这里我的代码我在下面的代码中使用它们的纬度和经度来计算两个位置之间的距离.这是错误的距离.有时候变得正确,有时会变得无关紧要.
我们从数据库获取lat1和lng1.
//getting lat2 and lng2 from GPS as below
public class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc)
{
lat2=loc.getLatitude();
lng2=loc.getLongitude();
String Text = "My current location is: " +"Latitud = "+ loc.getLatitude() +"Longitud = " + loc.getLongitude();
//System.out.println("Lat & Lang form Loc"+Text);
//Toast.makeText( getApplicationContext(), Text,Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderDisabled(String provider)
{
}
@Override
public void onProviderEnabled(String provider)
{
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
//Calculating distance
double earthRadius = …Run Code Online (Sandbox Code Playgroud) 我正在为移动设备制作一个"指南针".我有以下几点:
point 1 (current location): Latitude = 47.2246, Longitude = 8.8257
point 2 (target location): Latitude = 50.9246, Longitude = 10.2257
Run Code Online (Sandbox Code Playgroud)
另外我有以下信息(来自我的android手机):
The compass-direction in degree, wich bears to the north.
For example, when I direct my phone to north, I get 0°
Run Code Online (Sandbox Code Playgroud)
我怎样才能创建一个"指南针"箭头,向我展示指向方向的方向?
这有数学问题吗?
谢谢!
编辑:好的,我找到了一个解决方案,它看起来像这样:
/**
* Params: lat1, long1 => Latitude and Longitude of current point
* lat2, long2 => Latitude and Longitude of target point
*
* headX => x-Value of built-in phone-compass
*
* Returns …Run Code Online (Sandbox Code Playgroud) 有没有人有一个算法来确定从一个纬度/经度到另一个的方向(伪代码):
CalculateHeading( lat1, lon1, lat2, long2 ) returns string heading
Run Code Online (Sandbox Code Playgroud)
标题是NW,SW,E等.
基本上,我在地图上有两个点我希望得到一个方向的一般概念,考虑到东50英里和北一英里只是东方而不是东北.
android ×2
algorithm ×1
direction ×1
geolocation ×1
geospatial ×1
google-maps ×1
kml ×1
location ×1
math ×1
pseudocode ×1