Skip to content

sgimp/ktopencage

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ktopencage

CircleCI

OpenCage geocoding client for Android.

How to use:

You will need to sign up for an API key on the OpenCage site. See the full OpenCage Geocoding API documentation

Gradle

Repository

```
repositories {
  maven { url 'https://jitpack.io' }
  maven {
    url "https://dl.bintray.com/andevengimpel/maven/"
  }
}
```

Dependency

```
dependencies {
      implementation 'andev:ktopencage:library_version'
}
```

Code samples

```
var geoCoder = OpenCageGeoCoder(API_KEY)

//forward request

val request = OpenCageRequest("Paris")
request.minConfidence = 1

//Call the handleRequest method in the background

try {
   val response = geoCoder.handleRequst(request)
   if (!response.results.isNullOrEmpty()) {
      val result = response.results!![0]
      Log.d(
          TAG,
          result.geometry!!.lat.toString() + "," + result.geometry!!.lng.toString())
   }
} catch (e: ResponseException) {
   e.printStackTrace()
}

//reverse request
val request = OpenCageRequest(40.698613, -73.972494)

//Call the handleRequest method in the background

try {
  // call handle request from a background thread
  val response = geoCoder.handleRequest(request)
  if (!response.results.isNullOrEmpty()) {
    val result = response.results!![0]
    Log.d(TAG, result.formatted)
  }
} catch (e: ResponseException) {
  e.printStackTrace()
}
```

Libraries

okhttp - https://square.github.io/okhttp/

Gson - https://github.com/google/gson

kotlin-stdlib-jdk7 - https://kotlinlang.org/

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

OpenCage geocoding client for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages