You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With _batch geocoding_, you can perform up to 50 distinct forward or reverse geocoding requests simultaneously and store the results in a private database. Create a ForwardBatchGeocodingOptions or ReverseBatchGeocodingOptions object in Swift, or an MBForwardBatchGeocodingOptions or MBReverseBatchGeocodingOptions object in Objective-C, and pass it into the `Geocoder.batchGeocode(_:completionHandler:)` method.
199
199
200
+
```swift
201
+
// main.swift
202
+
let options = ForwardBatchGeocodeOptions(queries: ["skyline chili", "gold star chili"])
203
+
options.focalLocation = locationManager.location
204
+
options.allowedScopes = .pointOfInterest
205
+
206
+
let task = geocoder.batchGeocode(options) { (placemarksByQuery, attributionsByQuery, error) in
207
+
let nearestSkyline = placemarksByQuery[0][0].location
208
+
let distanceToSkyline = nearestSkyline.distance(from: locationManager.location)
209
+
let nearestGoldStar = placemarksByQuery[1][0].location
210
+
let distanceToGoldStar = nearestGoldStar.distance(from: locationManager.location)
211
+
212
+
let distance = LengthFormatter().string(fromMeters: min(distanceToSkyline, distanceToGoldStar))
213
+
print("Found a chili parlor \(distance) away.")
214
+
}
215
+
```
216
+
217
+
```objc
218
+
// main.m
219
+
MBForwardBatchGeocodeOptions *options = [[MBForwardBatchGeocodeOptions alloc] initWithQueries:@[@"skyline chili", @"gold star chili"]];
Batch geocoding is available to Mapbox enterprise accounts. See the [Mapbox Geocoding](https://www.mapbox.com/geocoding/) website for more information.
0 commit comments