在Google地图应用的KML图层中添加自定义路线或其他替代方法。

huangapple 未分类评论52阅读模式
英文:

Adding custom routes on google map apps kml layer or alternatives

问题

我正在开发Android谷歌地图,我想在两个地点之间添加自定义路线,我已经在谷歌地图上绘制出来并将其导出为KML格式。但是当我尝试将其作为图层添加到地图上时:

layer = new KmlLayer(mapAPI, R.raw.kml_samples, getApplicationContext()); // 创建KML图层
layer.addLayerToMap();

调试器返回mapAPI为null,
结果就是,我得到的地图没有创建图层,
你能帮我解决这个问题吗?或者推荐另一种方法!谢谢
Android,谷歌地图,Java,KmlLayer

英文:

I'm working on Android google maps, I want to add a custom route between 2 places, I started drawing it on google maps I export it as Kml, when I try to add it as a layer to the map :

layer = new KmlLayer(mapAPI,R.raw.kml_samples, getApplicationContext()); // creating the kml layer
layer.addLayerToMap() 

the debugger returns mapAPI:null ,
as a result, I get my map without the layer created,
can you help me with this? or recommend another way to do it! Thank you
Android, Google-maps, Java, KmlLayer

答案1

得分: 0

看起来你的mapAPI正在引用一个空对象。确保mapAPI是你的GoogleMap对象,图层将被渲染到该对象上,因为这是从本地资源文件渲染KML图层所需的内容之一。你可以参考Maps SDK for Android KML导入工具文档获取更多信息。

如果你需要一个导入KML文件并创建图层的示例,可以查看附带该工具库的演示应用中的KmlDemoActivity。要运行演示应用,请查阅这里的设置指南文档。

希望这能帮到你!

英文:

It looks like your mapAPI is referencing to a null object. Make sure that mapAPI is your GoogleMap object where the layer will be rendered as this is one of the things you need to render a KMLlayer from a local resource file. You may refer to the Maps SDK for Android KML Importing Utility for more information.

For an example of importing a KML file and creating a layer with it, take a look at the KmlDemoActivity in the demo app that ships with the utility library. To run the demo app, check the setup guide documentation here.

I hope this helps!

huangapple
  • 本文由 发表于 2020年4月9日 19:56:29
  • 转载请务必保留本文链接:https://java.coder-hub.com/61120607.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定