getLocationsByViewPort

abstract suspend fun getLocationsByViewPort(upperLeftLatitude: Double, upperLeftLongitude: Double, lowerRightLatitude: Double, lowerRightLongitude: Double, filter: AdvancedLocationFilter = AdvancedLocationFilter()): LocationsPage

Retrieves advanced location markers within a viewport rectangle - the full place record, filterable by category, type, amenity and status.

Use it to fill a map with what the visible region shows as the member pans or zooms - it replaces map().getFacilitiesByViewPort(...). When your map hands you south-west / north-east corners, prefer the LocationBounds overload, which maps the corners for you. Build the AdvancedLocationFilter once and reuse it.

Android (Kotlin)

lifecycleScope.launch {
try {
val page = AFCore.locations().getLocationsByViewPort(
upperLeftLatitude = 37.80, upperLeftLongitude = -122.52,
lowerRightLatitude = 37.70, lowerRightLongitude = -122.35,
filter = AdvancedLocationFilter(categoryCodes = listOf(FavoriteLocation.FITNESS_CATEGORY))
)
mapView.showMarkers(page.items)
if (page.truncated) showZoomInHint()
} catch (t: Throwable) {
showRetry(t) // a failure is not "no places here"
}
}

iOS (Swift)

Task {
do {
let filter = AdvancedLocationFilter(
categoryCodes: ["FITNESS"], categoryIds: [], includeChildCategories: true,
typeCodes: [], typeIds: [], amenities: [], amenitiesMode: "any", status: [],
favoritesOnly: false, excludeMuted: false, query: nil, limit: 200
)
let page = try await AFCore.shared.locations().getLocationsByViewPort(
upperLeftLatitude: 37.80, upperLeftLongitude: -122.52,
lowerRightLatitude: 37.70, lowerRightLongitude: -122.35,
filter: filter
)
mapView.showMarkers(page.items)
if page.truncated { showZoomInHint() }
} catch {
showRetry(error)
}
}

Return

The requested LocationsPage.

Parameters

upperLeftLatitude

Latitude of the viewport's northwest corner.

upperLeftLongitude

Longitude of the viewport's northwest corner.

lowerRightLatitude

Latitude of the viewport's southeast corner.

lowerRightLongitude

Longitude of the viewport's southeast corner.

filter

What to include; see AdvancedLocationFilter. Its defaults return every unfiltered marker, muted ones included.

Throws

if the markers cannot be retrieved - an upstream failure answers as an error, never as a map with no pins.


open suspend fun getLocationsByViewPort(bounds: LocationBounds, filter: AdvancedLocationFilter = AdvancedLocationFilter()): LocationsPage

Retrieves advanced location markers within bounds - the same query as getLocationsByViewPort, addressed by a south-west / north-east box.

The two corner conventions differ, and mapping one to the other by hand is easy to get backwards - an inverted box returns nothing and reports no error. Pass the LocationBounds straight through instead, including one grown by LocationBounds.expandedBy for prefetching; use LocationBounds.contains to skip a fetch the loaded box already covers.

Android (Kotlin)

val visible = LocationBounds(
southWestLat = 37.70, southWestLng = -122.52,
northEastLat = 37.80, northEastLng = -122.35
)
lifecycleScope.launch {
try {
val page = AFCore.locations().getLocationsByViewPort(visible.expandedBy(0.25))
mapView.showMarkers(page.items)
} catch (t: Throwable) {
showRetry(t)
}
}

iOS (Swift)

let visible = LocationBounds(
southWestLat: 37.70, southWestLng: -122.52,
northEastLat: 37.80, northEastLng: -122.35
)
Task {
do {
// mapFilter: an AdvancedLocationFilter built once, every argument spelled out
let page = try await AFCore.shared.locations().getLocationsByViewPort(
bounds: visible.expandedBy(factor: 0.25), filter: mapFilter
)
mapView.showMarkers(page.items)
} catch {
showRetry(error)
}
}

Return

The requested LocationsPage.

Parameters

bounds

The box to search, corner to corner.

filter

What to include; see AdvancedLocationFilter. Its defaults return every unfiltered marker, muted ones included.

Throws

if the markers cannot be retrieved - an upstream failure answers as an error, never as a map with no pins.