How To Add Kmllayer To Android Googlemap
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 =
Solution 1:
You need to get map and then add a KML layer on top of it. Something like that:
...
privateGoogleMap mMap;
...
@OverridepublicvoidonMapReady(GoogleMap googleMap) {
mMap = googleMap;
...
}
...
publicvoidaddKML() {
KmlLayer layer = newKmlLayer(mMap, R.raw.kmlFile, getApplicationContext());
layer.addLayerToMap();
}
...
Solution 2:
To get rid of the getMap() error, you need to create a Google Map object and pass it in. The code Andrii provided would solve the problem.
To get rid of the error at 'R.raw.kmlFile', you need to create a raw folder.
Right-click the res folder, then go to New -> Android resource directory. Set the Directory name and Directory type as "raw", then click OK. Here is a more detailed guide.
Post a Comment for "How To Add Kmllayer To Android Googlemap"