添加KML层一个Android地图应用程序 [英] Adding a KML layer to an Android maps application

查看:548
本文介绍了添加KML层一个Android地图应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始在Android开发的世界最近和我工作的这显示了使用谷歌API SDK的地图应用程序,这是pretty的许多原始的例子,但编辑的一点点。它的工作原理一种享受,但我希望做更多的它。我的问题是:

I have been starting out in the world of Android development recently and I am working on an application which shows a map using the Google API SDK, it is pretty much the original example but edited a little bit. It works a treat but I wish to do more with it. My question is:

你如何添加一个KML层呢?我没有找到许多例子在那里,他们都不是很清楚。我知道如何做到这一点的JavaScript的网站,但不是机器人。

How do you add a KML layer to this? I've not found many examples out there and none of them are very clear. I know how to do this with Javascript on websites but not in android.

谁能帮助?

推荐答案

谷歌在其效用lib中添加了支持KML最近。您可以实例化一个KMLLayer如下:

Google added a support to KML recently in its utility lib. You can instantiate a KMLLayer as below:

KmlLayer layer = new KmlLayer(getMap(), R.raw.kmlFile, getApplicationContext());

或者,如果你有一个流(也许你需要的KML是一个远程服务器上):

Or if you have a stream (maybe the kml you need is on a remote server):

KmlLayer layer = new KmlLayer(getMap(), kmlInputStream, getApplicationContext());

在此,你必须图层添加到地图:

After this you have to add the layer to the map:

layer.addLayerToMap();

谷歌地图的KML导入实用程序的更多信息。 该库是在这里:谷歌地图Android的API实用程序库(需要0.4+版)

More info on Google Maps KML Importing Utility. The library is here: Google Maps Android API utility library (you need 0.4+ version)

注意:在当时,这是一个测试版的功能。事实上,它似乎你不能做任何修改多边形,改变他们的风格,等等...

CAUTION: At the time, it's a Beta feature. In fact it seems you can't make any modifications to polygons, changing their styles, and so on...

我希望它帮助。

这篇关于添加KML层一个Android地图应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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