I Container google android Karte api -Zugang KMLAbrufen von Daten aus einem verschachtelten Containern in KML-Datei
https://developers.google.com/maps/documentation/android-api/utility/kml#clear
Für den Zugriff auf Container lesen, die in einem KmlLayer oder KmlContainer verschachtelt sind:
Iterable containers = layer.getContainers();
public void accessContainers(containers) {
for (KmlContainer container : containers) {
// Do something to container
if (container.hasContainers()) {
accessContainers(container.getContainers());
}
} }
Wo sollte ich diese Methode in das Programm einfügen?
In der Demo progrma, fand ich diese, aber ich weiß noch nicht, wie es zu benutzen
//Retrieve the first container in the KML layer
KmlContainer container = kmlLayer.getContainers().iterator().next();
//Retrieve a nested container within the first container
container = container.getContainers().iterator().next();
mein Programm Hier
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback{
private GoogleMap mMap;
private KmlLayer layer;
private KmlContainer container;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap)
{
mMap = googleMap;
try {
layer = new KmlLayer(mMap, R.raw.canberra, getApplicationContext());
layer.addLayerToMap();
containers = layer.getContainers();
} catch (XmlPullParserException e)
{e.printStackTrace();}
catch (IOException e)
{ e.printStackTrace();}
LatLng sydney = new LatLng(-34, 151);
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}