Giter Site home page Giter Site logo

rmnblm / graphhoppergeocoder Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 2.0 51 KB

πŸ” The GraphHopper Geocoding API wrapped in an easy-to-use Swift framework.

Home Page: https://www.graphhopper.com

License: MIT License

Swift 97.39% Ruby 2.61%
geocoding graphhopper openstreetmap swift

graphhoppergeocoder's Introduction

GraphHopperGeocoder

πŸ” 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 ❀️ by @rmnblm and @iphilgood during the Bachelor thesis at HSR University of Applied Sciences in Rapperswil.

graphhoppergeocoder's People

Contributors

iphilgood avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.