Search code examples
google-mapsapple-maps

What is the recommended format for search query in Google and Apple maps?


I want to show the direction from my React Native app to the specific address in Google or Apple maps application depending on the Platform. Are there any requirements for address query format so I can get better search results?

I've found following for Google https://developers.google.com/maps/faq#geocoder_queryformat. Any ideas for Apple Maps?


Solution

  • Here what I’ve found in official docs

    Google

    How should I format my geocoder queries to maximise the number of successful requests? The geocoder is designed to map street addresses to geographical coordinates. We therefore recommend that you format geocoder requests in accordance with the following guidelines to maximize the likelihood of a successful query:

    • Specify addresses in accordance with the format used by the national postal service of the country concerned.
    • Do not specify additional address elements such as business names, unit numbers, floor numbers, or suite numbers that are not included in the address as defined by the postal service of the country concerned. Doing so may result in responses with ZERO_RESULTS.
    • Use the street number of a premise in preference to the building name where possible.
    • Use street number addressing in preference to specifying cross streets where possible.
    • Do not provide ‘hints’ such as nearby landmarks.

    https://developers.google.com/maps/faq#geocoder_queryformat

    Apple

    Use the CLGeocoder class with a dictionary of Address Book information or a simple string to initiate forward-geocoding requests. There is no designated format for string-based requests: Delimiter characters are welcome, but not required, and the geocoder server treats the string as case-insensitive. For example, any of the following strings would yield results:

    • “Apple Inc”
    • “1 Infinite Loop”
    • “1 Infinite Loop, Cupertino, CA USA”

    The more information you can provide to the forward geocoder, the better the results returned to you. The geocoder object parses the information you give it and if it finds a match, returns some number of placemark objects. The number of returned placemark objects depends greatly on the specificity of the information you provide. For this reason, providing street, city, province, and country information is much more likely to return a single address than providing only street and city information. The completion handler block you pass to the geocoder should be prepared to handle multiple placemarks, as shown below.

    [geocoder geocodeAddressString:@"1 Infinite Loop" completionHandler:^(NSArray* placemarks, NSError* error){ for (CLPlacemark* aPlacemark in placemarks) { // Process the placemark. } }];

    https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/LocationAwarenessPG/UsingGeocoders/UsingGeocoders.html