Search nearby in iOS Maps

前端 未结 1 1111
没有蜡笔的小新
没有蜡笔的小新 2021-02-11 01:49

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).

1条回答
  •  礼貌的吻别
    2021-02-11 02:52

    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
    }];
    

    0 讨论(0)
提交回复
热议问题