Git Product home page Git Product logo

gmaps11's Introduction

C++11 Client for Google Maps Web Services

Build Status

Description

This library brings the Google Maps API Web Services to your C++11 application.

The C++11 Client for Google Maps Services is a C++11 Client library for the following Google Maps APIs:

Latest Stable Version

The latest stable version of the library can be found at:

Getting started

Building and Installing

Dependencies

After downloading and extracting the source from a tarball to a directory, the commands to build gmaps11 on most systems are:

mkdir build && cd build
cmake ..
cmake --build .

Installing the library and optionally specifying a prefix can be done with:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
cmake --build . --target install

More information on CMake can be found on its FAQ.

Examples

Before we dive into examples, please make sure you have a gmaps11.config configuration file in the root of your project.

gmaps11.config is JSON configuration file used by the C++11 client.

Google Directions API

The Google Directions API is a service that calculates directions between locations using an HTTP request.

gmaps11 comes with a DirectionsService class to help you query The [Google Directions API]:

    #include <gmaps11/directions.hpp>
    #include <boost/scoped_ptr.hpp>
    #include <iostream>

    using namespace googlemaps;

    auto main() -> int {
        boost::scoped_ptr<DirectionsService> directions_service(new DirectionsService());
        // Query the Google Maps Directions API
        // *NOTE* 'waypoint_t' is a typdef for boost::variant which can be a
        // string holding a name (city, place...) or a boost tuple holding lat and long
        // of a position
        std::string response = directions_service->query("Paris", boost::make_tuple(44.051682, 4.643433), "driving");
        // Print the JSON response
        std::cout << response << std::endl;
    }

Notes

You can parse the JSON response using the JSON parser in gmaps11/json/json11.hpp header:

    std::string err;
    json11::Json json_body = json11::Json::parse(response, err);
    if (err.empty()) { // JSON response is valid
        std::string __status__ = json_body["status"].string_value();
    }

Contributing

Bug reports, Pull requests and Stars are always welcome. For bugs and feature requests, please create an issue.

License

The library is available as open source under the terms of the MIT License.

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.