Partager via


MapLocationFinder Class

Note

Bing Maps SDK for Android and iOS retirement

Bing Maps SDK for Android and iOS is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps SDK for Android and iOS until June 30th, 2025. Enterprise account customers can continue to use Bing Maps SDK for Android and iOS until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps SDK for Android and iOS will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type.

Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.

Forms and sends geocoding requests.

Static Methods

FindLocations

Forms and sends a geocoding request by string query.

See also:

Android

These methods return a Future object that can be used to work with the asynchronous operation including canceling the operation.
See also MapLocationFinderResult.

// Default overload: takes string query, options (nullable), and callback.
Future<MapLocationFinderResult> findLocations(String query, @Nullable MapLocationOptions options, OnMapLocationFinderResultListener callback)

// Overload that takes a reference geopoint in addition to the default set of parameters. When you specify this parameter, the location is taken into account and the results returned may be more relevant to the user.
Future<MapLocationFinderResult> findLocations(String query, @Nullable Geopoint referencePoint, @Nullable MapLocationOptions options, OnMapLocationFinderResultListener callback)

// Overload that takes a reference geobounding box in addition to the default set of parameters. When you specify this parameter, the geographical area is taken into account when computing the results of a location query.
Future<MapLocationFinderResult> findLocations(String query, @Nullable GeoboundingBox referenceBoundingBox, @Nullable MapLocationOptions options, OnMapLocationFinderResultListener callback)

// Overload that takes both geopoint and geobounding box as reference in addition to the default set of parameters.
Future<MapLocationFinderResult> findLocations(String query, @Nullable Geopoint referencePoint, @Nullable GeoboundingBox referenceBoundingBox, @Nullable MapLocationOptions options, OnMapLocationFinderResultListener callback)

iOS

// Default overload: takes string query, options (nullable), and callback handler.
+ (void)findLocations:(NSString*)query withOptions:(MSMapLocationOptions* _Nullable)options handleResultWith:(MSMapLocationFinderResultHandler)handler

// Overload that takes a reference geopoint in addition to the default set of parameters. When you specify this parameter, the location is taken into account and the results returned may be more relevant to the user.
+ (void)findLocations:(NSString*)query withReferencePoint:(MSGeopoint* _Nullable)referencePoint withOptions:(MSMapLocationOptions* _Nullable)options handleResultWith:(MSMapLocationFinderResultHandler)handler

// Overload that takes a reference geobounding box in addition to the default set of parameters. When you specify this parameter, the geographical area is taken into account when computing the results of a location query.
+ (void)findLocations:(NSString*)query withReferenceBoundingBox:(MSGeoboundingBox* _Nullable)referenceBoundingBox withOptions:(MSMapLocationOptions* _Nullable)options handleResultWith:(MSMapLocationFinderResultHandler)handler

// Overload that takes both geopoint and geobounding box as reference in addition to the default set of parameters.
+ (void)findLocations:(NSString*)query withReferencePoint:(MSGeopoint* _Nullable)referencePoint withReferenceBoundingBox:(MSGeoboundingBox* _Nullable)referenceBoundingBox withOptions:(MSMapLocationOptions* _Nullable)options handleResultWith:(MSMapLocationFinderResultHandler)handler

FindLocationsAt

Forms and sends a reverse geocoding request by geopoint.

See also:

Android

// Takes geopoint query, options (nullable), and callback.
void findLocationsAt(Geopoint location, @Nullable MapLocationOptions options, OnMapLocationFinderResultListener callback)

iOS

// Takes geopoint query, options (nullable), and callback handler.
+ (void)findLocationsAt:(MSGeopoint*)location withOptions:(MSMapLocationOptions* _Nullable)options handleResultWith:(MSMapLocationFinderResultHandler)handler

Examples

Android

MapServices.SetCredentialsKey("...");

MapLocationOptions options = new MapLocationOptions()
    .setCulture("de")
    .setRegion("DE")
    .setMaxResults(20);

MapLocationFinder.findLocations("space needle", options, new OnMapLocationFinderResultListener() {
    @Override
    void onMapLocationFinderResult(MapLocationFinderResult result)
    {
        if (result.getStatus() == MapLocationFinderStatus.SUCCESS) {
            List<MapLocation> resultLocations = result.getLocations();
            // ...
        }
    }
});

iOS

[MSMapServices setCredentialsKey:@"..."];

MSMapLocationOptions *options = [[MSMapLocationOptions alloc] init];
[options setCulture:@"de"];
[options setRegion:@"DE"];
[options setMaxResults:20];

[MSMapLocationFinder findLocations:@"space needle" withOptions:options handleResultWith:^void(MSMapLocationFinderResult *result) {
    if ([result status] == MSMapLocationFinderStatusSuccess) {
        NSArray<MSMapLocation*>* resultLocations = [result locations];
        // ...
    }
}];

See Also