如何将KMLlayer添加到Android GoogleMap [英] How to add KMLlayer to Android GoogleMap
问题描述
基于此链接 https://developers.google。 com / maps / documentation / android-api / utility / kml 我一直跟着它,直到我必须输入这段代码:
KmlLayer图层=新的KmlLayer(getMap(),R.raw.kmlFile,getApplicationContext());
我在'getMap()'和'R.raw.kmlFile'我无法理解他所说的部分内容是什么
***要从本地资源导入和呈现KML数据集,您需要:
要渲染图层的GoogleMap对象。
包含KML数据的本地资源文件。
一个Context对象,它是打开本地资源文件所必需的。***
你能指导我做什么。
您需要获取地图,然后在其上添加KML图层。类似的东西:
...
私有GoogleMap mMap;
...
@Override
public void onMapReady(GoogleMap googleMap){
mMap = googleMap;
...
}
...
public void addKML(){
KmlLayer图层= new KmlLayer(mMap,R .raw.kmlFile,getApplicationContext());
layer.addLayerToMap();
}
...
有关详情,请参阅 this 档案( )。
based on this link "https://developers.google.com/maps/documentation/android-api/utility/kml" I have followed it until to the point where I have to type this code:
KmlLayer layer = new KmlLayer(getMap(), R.raw.kmlFile, getApplicationContext());
I'm having a red line in 'getMap()' and 'R.raw.kmlFile' and I can't understand what it's trying to say in the part where he says
***To import and render a KML dataset from a local resource, you need:
A GoogleMap object where the layer is to be rendered. A local resource file containing the KML data. A Context object, which is required to open a local resource file.***
Can you please guide me on what to do.
You need to get map and then add a KML layer on top of it. Something like that:
...
private GoogleMap mMap;
...
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
...
}
...
public void addKML() {
KmlLayer layer = new KmlLayer(mMap, R.raw.kmlFile, getApplicationContext());
layer.addLayerToMap();
}
...
For details take a look at this file in that repo.
这篇关于如何将KMLlayer添加到Android GoogleMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!