Giter Site home page Giter Site logo

applemaps-go's Introduction

A Go client library for the Apple Maps Server API

header_img

To learn about the Apple Maps Server API and all its methods, check the official documentation here: https://developer.apple.com/documentation/applemapsserverapi

Installation

go get github.com/jweckschmied/applemaps-go

Getting Started

An Apple Developer account is required to use the Apple Maps Server API. If you have a Developer Account, you can learn more about how to get a Maps Identifier, Private Key and Auth Token in the Apple MapKit JS Documentation: https://developer.apple.com/documentation/mapkitjs/creating_a_maps_identifier_and_a_private_key

The only information you need to provide to use this package is the JWT Auth Token.

Generating the JWT

Since the JWT will expire at some point, it needs to be regenerated on a regular basis. You can do this however you like, for example using one of the available golang JWT packages.

Details on the JWT creation can be found here: https://developer.apple.com/documentation/mapkitjs/creating_and_using_tokens_with_mapkit_js

Use the SetAuthToken() method to set a new token for an already existing client.

Usage Example

import (
    "context"
    "net/http"
	
    "github.com/jweckschmied/applemaps-go"
)

func main() {
    ctx := context.Background()
    httpClient := http.DefaultClient
    client := applemaps.NewAppleMaps(httpClient, "<your-auth-token>")
    result, err := client.Search(
        ctx,
        "Tour Eiffel",
        applemaps.WithLanguage(language.French),
        applemaps.WithResultTypeFilter("Poi"),
        applemaps.WithUserLocation(applemaps.NewLocation(48.858093, 2.294694)),
    )
}

Request Options

The following options are available for the different methods provided by the API. Please check the docs for details on which parameters can be used for each API method.

WithExcludePoiCategories
WithIncludePoiCategories
WithLimitToCountries
WithResultTypeFilter
WithLanguage
WithArrivalDate
WithDepartureDate
WithRequestsAlternateRoutes
WithTransportType
WithSearchLocation
WithAvoid
WithSearchRegion
WithUserLocation

For example, if you wanted to set the userLocation, along with includePoiCategories=Bank,Bakery, the function call should look like this:

client.Search(
    "Search Query",
    applemaps.WithUserLocation(applemaps.NewLocation(51.08097475066115, 13.76077443357895)),
    applemaps.WithIncludePoiCategories(applemaps.Bank, applemaps.Bakery),
)

applemaps-go's People

Contributors

jweckschmied avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

haveblue-io

applemaps-go's Issues

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.