Sorry, you need to enable JavaScript to visit this website.

Display Photos and add POI Details

Display Photos and add POI Details

POI Details API allows you to provide more useful information about POIs in your app with additional details. As you can see in the documentation of POI Details service ( Points of Interest Details) the information it provides includes:

  1. Current Rating

  2. Price Range

  3. 5 to 10 most relevant user reviews

  4. Social Media details (Facebook, Instagram and Twitter), if available

  5. The Photo IDs that can be used in order to fetch images related to given POI

This what you need to do to get details of a POI:

  1. Search for a POI using any of the POI-searches including Fuzzy, Geometry, or Along Route Search (see SEARCH API reference ) → The response includes a POI ID for each POI in the results.

  2. Call POI Details with the POI ID for the place you want to get details of → The response include rating, priceRange, socialMedia, photos IDs, or reviews.

  3. Done! You can use these details in your app to provide more information about places.

POI Photos API provides photos of the POI.

This what you need to do to get photos of POIs

  1. Search for a POI using any of the POI-searches including Fuzzy, Geometry, or Along Route Search (see SEARCH API reference) → The response includes a POI ID for each POI in the results.

  2. Call POI Details with the POI ID for the place you want to get photos of → The response includes up to 5 Photos IDs.

  3. Call POI Photos with the Photo ID for the place you want to get photos of.

  4. Done! You can display a photo of the POI you need.

For more details and background have a look at the detailed documentation of POI Photos service

Sample use case: You would like to plan a trip to Amsterdam and find a pleasant hostel and choose a pizza restaurant in your neighborhood. Thanks to POI Details you are provided with information including pricing ranges, ratings, reviews, social media details, contact information. Thanks to POI Photos, you can have a look at photos to feel the atmosphere of the places. Foursquare provide dozens of updates every day, so you can count on accurate, reliable information.

Use the following code snippets to try this in your app:

First, create a service:

_

let searchAPI = TTSearch(key: Key.Search)
self.searchAPI = [[TTSearch alloc] initWithKey:Key.Search];

Then using our Search API obtain POI objects

_

let searchQuery = TTSearchQueryBuilder.create(withTerm: "Restaurant").withPosition(TTCoordinate.AMSTERDAM()).withLimit(200).withOpeningHours(.nextSevenDays).build()
searchAPI.search(with: searchQuery) { [weak self] response, _ in
TTSearchQuery *searchQuery = [[[[[TTSearchQueryBuilder createWithTerm:@"Restaurant"] withPosition:TTCoordinate.AMSTERDAM] withLimit:200] withOpeningHours:TTOpeningHoursNextSevenDays] build];
[self.searchAPI searchWithQuery:searchQuery
               completionHandle:^(TTSearchResponse *_Nullable response, TTResponseError *_Nullable error) {

Then based on additionalDataSources in TTSearchResult you need to find Foursquare datasource and grab it’s ID.

_

guard let dataSourceID = additionalDataSources.poiDetailsDataSources.first(where: { $0.sourceName == "Foursquare" })?.dataSourceID else {
    return
}
for (TTPoiDetailsDataSource *poiDetailsDataSources in additionalData.poiDetailsDataSources) {
    if ([poiDetailsDataSources.sourceName isEqualToString:@"Foursquare"]) {
        dataSourceID = poiDetailsDataSources.dataSourceID;
    }
}

Based on that ID you need to get given data source details:

_

let poiDetailsSpecification = AnnotationPoiDetailsSpecification(poiDetailsID: dataSourceID as String)
poiDetailsAPI.fetchPoiDetails(specification: poiDetailsSpecification) { [weak self] poiDetailsResponse, error in
AnnotationPoiDetailsSpecification *poiDetailsSpecification = [[AnnotationPoiDetailsSpecification alloc] initWithPoiDetailsID:dataSourceID];
[self.poiDetailsAPI fetchPoiDetailsWithSpecification:poiDetailsSpecification
                                          completion:^(PoiDetails *_Nullable poiDetailsResponse, NSError *_Nullable error) {

If you want to get photos of given POI:

_

let photoIdArray = poiDetailsResponse.photos.map { PoiPhoto(photoID: $0.photoID) }
self.poiPhotosAPI.get(photos: photoIdArray) { [weak self] images, error in
[self.poiPhotosAPI getWithPhotos:poiPhotoArray
                      completion:^(NSArray<UIImage *> *_Nullable images, NSError *_Nullable error) {

Important: You shall attribute all results delivered by the Extended Search API Points of Interest Details endpoint and Points of Interest Photos endpoint as being ‘powered by Foursquare'.

Screen shots presenting how the POI Details service works:

image