Reputation: 18810
Using the Google Maps SDK, is it possible to get a list of all the POI's currently visible as "icons" on the map?
I know I can use the Places API to do something similar, but in my case I really just want to get the exact POI's that are currently visible as icons on the users screen at this moment.
I also know that I can listen for when the user taps on a POI, but this won't help in my case.
Upvotes: 0
Views: 552
Reputation: 13353
Seems its impossible via Google Maps SDK, but anyway you can use workaround:
a) create JSON file src\main\res\raw\map_style.json like this:
[
{
featureType: "poi",
elementType: "labels",
stylers: [
{
visibility: "off"
}
]
}
]
b) add map style to your GoogleMap:
`googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(getContext(), R.raw.map_style));`
Get coordinates of area visible on screen:
LatLngBounds visibleAreaBounds = googleMap.getProjection().getVisibleRegion().latLngBounds;
Get information about POI's "manually" (by kinds of them) near screen center coordinates via Places SDK for Android and parse information about each place.
4.For each POI's coordinates check if it exactly inside bounds:
for (LatLng poiCoords : PoisCoords) {
if (visibleAreaBounds.contains(poiCoords)) {
// POI is visible on screen
}
}
Upvotes: 0