导入KML的地图API V2 [英] Import KML in Maps API V2

查看:159
本文介绍了导入KML的地图API V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有被画在谷歌地球,并包含不同的路线多个KML文件。现在,我试图用地图API V2显示那些在我的Andr​​oid项目。

I have multiple KML files which are drawn in google earth and contain different routes. Now I'm trying to display those in my android project with Maps API V2.

有没有导入你的Andr​​oid项目的KML文件,并在地图中显示它们现有的库? 我发现堆栈溢出一些code(<一href="http://stackoverflow.com/questions/3109158/how-to-draw-a-path-on-a-map-using-kml-file/3109723#3109723">How使用KML文件来绘制地图上的道路?)这不是一个图书馆。

Is there an existing library for importing KML files in your android project and displaying them in maps? I found some code on stack overflow ( How to draw a path on a map using kml file? ) which isn't a library.

如果没有可用的,我只是要从头开始构建这个库。

If there's no library available I'm just going to build this from scratch.

推荐答案

现在生病只是假设孤单,这是否给我们,所以我将使用谷歌的code到折线和多边形添加到任何公共图书馆我的分析数据在我的KML文件后,地图。 如果库被发现会更新这个答案。

For now Ill just assume that theres no public library that does this for us so I'm going to use Google's code to add polylines and polygons to my map after parsing the data in my KML file. Will update this answer if a library is found.

创建折线和多边形:

// Instantiates a new Polyline object and adds points to define a rectangle
PolylineOptions rectOptions = new PolylineOptions()
        .add(new LatLng(37.35, -122.0))
        .add(new LatLng(37.45, -122.0))  // North of the previous point, but at the same longitude
        .add(new LatLng(37.45, -122.2))  // Same latitude, and 30km to the west
        .add(new LatLng(37.35, -122.2))  // Same longitude, and 16km to the south
        .add(new LatLng(37.35, -122.0)); // Closes the polyline.

// Set the rectangle's color to red
rectOptions.color(Color.RED);

// Get back the mutable Polyline
Polyline polyline = myMap.addPolyline(rectOptions);

这篇关于导入KML的地图API V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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