Code Monkey home page Code Monkey logo

geokey-mapbox's Introduction

GeoKey + Mapbox integration

An Android app and library to visualize GeoKeys on a Mapbox map. From their website:

A GeoKey is a 16 letter, four-word key that represents every square meter of the earth’s surface.

Tap on the map to get the GeoKey for a location

Look up GeoKeys on the map

About

This repo contains an Android project with two modules:

  • app: A (Kotlin) Android app that visualizes GeoKeys on a map (see screenshots below).

  • libgeokey: A self-contained (Java) library that you are free to use in your own projects. Because it doesn't have any Android dependencies, you can use it for backend services too.

Usage

You start by initializing the `` client with an access token:

val geoKeyClient = GeoKeyClient("YOUR_TOKEN_GOES_HERE")

To obtain a GeoKey from a location you'd do something like the following:

geoKeyClient.fromPosition(latitude, longitude).enqueue(object : Callback<GeoKeyResponse> {
    override fun onResponse(call: Call<GeoKeyResponse>, response: Response<GeoKeyResponse>) {
        val geoKeyResponse = response.body()
        if (geoKeyResponse == null || geoKeyResponse.isFailure) {
            // GeoKey request failed, check `geoKeyResponse?.failure` for additional information
        } else {
            // GeoKey available in `geoKeyResponse.geoKey`
        }
    }

    override fun onFailure(call: Call<GeoKeyResponse>, t: Throwable) {
        // GeoKey request failed, check `t.message` for additional information
    }
})

Conversely, to obtain a location from a GeoKey:

geoKeyClient.fromGeoKey(geoKey).enqueue(object : Callback<LocationResponse> {
    override fun onResponse(call: Call<LocationResponse>, response: Response<LocationResponse>) {
        val locationResponse = response.body()
        if (locationResponse == null || locationResponse.isFailure) {
            // GeoKey request failed, check `geoKeyResponse?.failure` for additional information
        } else {
            // Location available in `locationResponse.latitude` and `locationResponse.longitude`
        }
    }

    override fun onFailure(call: Call<LocationResponse>, t: Throwable) {
        // GeoKey request failed, check `t.message` for additional information
    }
})

License

See LICENSE.md.

Contributing

If you find any issues or want to suggest any contributions, please cut a ticket and tag @zugaldia.

geokey-mapbox's People

Contributors

zugaldia 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.