Android的URL访问KML路线 [英] android url to access KML route
问题描述
我想提请通过以下网址在谷歌地图上两点间的路径,
I am trying to draw path between two points on google map using url below,
<一个href="http://maps.google.com/maps?f=d&hl=en&saddr=13.005621,77.577531&daddr=13.005621,77.579531&ie=UTF8&0&om=0&output=kml" rel="nofollow">http://maps.google.com/maps?f=d&hl=en&saddr=13.005621,77.577531&daddr=13.005621,77.579531&ie=UTF8&0&om=0&output=kml
这是工作正常,但现在它显示异常之前,
before it was working properly, but now it shows exception,
I/System.out(461): Unexpected end of document
商务部将返回空值,为什么? 我的code是波纹管,
doc is returning null why? my code is bellow,
谢谢
推荐答案
这些链接帮助ü为$ C $下图:
These links help u to code for maps:
MAPS导师
<一href="http://stackoverflow.com/questions/1542252/how-to-find-the-route-between-two-places-in-blackberry">Maps地点
地图API
如果妳希望只有网址,然后用这个:
的http:// code .google.com /原料药/ KML /
这是完整的源$ C $下图位置。
MAPS Tutor
Maps Location
Maps Api
If u want url only then use this :
http://code.google.com/apis/kml/
These Is complete source code for maps location .
public class MapRouteActivity extends MapActivity {
LinearLayout linearLayout;
MapView mapView;
private Road mRoad;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
new Thread() {
@Override
public void run() {
double fromLat = 49.85, fromLon = 24.016667;
double toLat = 50.45, toLon = 30.523333;
String url = RoadProvider
.getUrl(fromLat, fromLon, toLat, toLon);
InputStream is = getConnection(url);
mRoad = RoadProvider.getRoute(is);
mHandler.sendEmptyMessage(0);
}
}.start();
}
Handler mHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
TextView textView = (TextView) findViewById(R.id.description);
textView.setText(mRoad.mName + " " + mRoad.mDescription);
MapOverlay mapOverlay = new MapOverlay(mRoad, mapView);
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
mapView.invalidate();
};
};
private InputStream getConnection(String url) {
InputStream is = null;
try {
URLConnection conn = new URL(url).openConnection();
is = conn.getInputStream();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return is;
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
查看全部code在 J2MEMapRouteAndroidEx 对谷歌code
这篇关于Android的URL访问KML路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!