Search nearby in iOS Maps

前端 未结 3 1498
轻奢々
轻奢々 2021-02-11 01:57

I am trying to build a simple application using MapKit that will automatically search for a specific place when the app launches and drop pin(s) on the map at the locations(s).

3条回答
  •  滥情空心
    2021-02-11 02:48

    iOS >= 6.1 provides MKLocalSearch, MKLocalSearchRequest to search for natural language points of interest. Sample

    MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
    request.region = regionToSearchIn;
    request.naturalLanguageQuery = @"restaurants"; // or business name
    MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request];
    [localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
        // do something with the results / error
    }];
    

提交回复
热议问题