Latest 1.0.1
Homepage https://github.com/rmnblm/GraphHopperGeocoder
License MIT
Platforms ios 8.0
Authors ,

[]()
[]()

🔍 The GraphHopper Geocoding API wrapped in an easy-to-use Swift framework.

The Geocoding API is part of the GraphHopper Directions API. Geocoding is the process of finding an address for your geo location or a coordinate for an address. With our API you have a fast and solid way to geocode.

Installation

Use CocoaPods to install the framework. Add this to your Podfile:

pod 'GraphHopperGeocoder'

Then run the following command:

$ pod install

In order to use the framework, you’ll also need a GraphHopper Access Token. You can either set your access token in the Info.plist (Key is GraphHopperAccessToken) or pass it as an argument to the initializer of the Geocoder class.

Example

Basics

Setup the Geocoder class

import CoreLocation
import GraphHopperGeocoder

// use this
let geocoder = Geocoder(accessToken: "YOUR ACCESS TOKEN")
// or if you have set your access token in the Info.plist
let geocoder = Geocoder()

Forward geocoding options

Configure the forward geocoding options

let options = ForwardGeocodeOptions(query: "HSR Rapperswil")
options.limit = 3

Reverse geocoding options

Configure the reverse geocoding options

let coordinate = CLLocationCoordinate2D(latitude: 47.222943, longitude: 8.817238649765951)
let options = ReverseGeocodeOptions(coordinate: coordinate)

Geocode request

Make the async request by calling the calculate(_:completionHandler) method and passing the options.

let task = geocoder.geocode(options, completionHandler: { (placemarks, error) in
    placemarks?.forEach({ placemark in
        print(placemark.name)
        print("(placemark.coordinate.latitude), (placemark.coordinate.longitude)")
        print(placemark.street)
        print(placemark.postalCode)
        print(placemark.city)
        print(placemark.state)
        print(placemark.country)
    })
})

More Information

For more information, consider reading the official documentation to learn more about the options and the result.

License

This project is released under the MIT license.

About

‚ÄčThe GraphHopper Geocoder Swift Framework is crafted with :heart: by @rmnblm and @iphilgood during the Bachelor thesis at HSR University of Applied Sciences in Rapperswil.

Latest podspec

{
    "name": "GraphHopperGeocoder",
    "version": "1.0.1",
    "license": "MIT",
    "homepage": "https://github.com/rmnblm/GraphHopperGeocoder",
    "summary": "ud83dudd0d The GraphHopper Geocoder API wrapped in an easy-to-use Swift framework.",
    "authors": {
        "rmnblm": "[email protected]",
        "iphilgood": "[email protected]"
    },
    "source": {
        "git": "https://github.com/rmnblm/GraphHopperGeocoder.git",
        "tag": "v1.0.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "GraphHopperGeocoder/*.swift",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This