Reputation: 135
so I have a KML layer which I create like so:
inputStream = new URL("url here").openStream();
layer = new KmlLayer(mMap, inputStream, getApplicationContext());
The layer no contains many different placemarks which I can retrieve by using layer.getPlacemarks()
. MY issue is that I want a why to somehow iterate through the placemarks, check if they are a certain distance from my current location and if they are then display that marker on the map. I'm fine finding the distance, I just don't understand how to access the placemarks and use specific information from it to calculate the distance etc.
Upvotes: 0
Views: 635
Reputation: 114787
for (KmlPlacemark placemark: layer.getPlacemarks()) {
if (placemark instanceof KmlPoint) {
KmlPoint point = (KmlPoint) placemark;
LatLng latLng = point.getGeometryObject();
// https://github.com/googlemaps/android-maps-utils/tree/master/library/src/com/google/maps/android/kml
}
}
Placemarks can be other types too. Check the source on github on how to get the coords from the other types.
Upvotes: 1