Git Product home page Git Product logo

googlemapsapi's Introduction

Bolden Google Maps API plugin for Craft CMS 3.x

Google Maps API plugin for Craft CMS 3.x

A simple wrapper for Google Maps server-side web services to access through AJAX calls.

Requirements

This plugin requires Craft CMS 3 or later and a valid/active Google Maps API key.

Overview

Use this wrapper to access Google Maps web services that are only accessible with a server-side connection. At the moment the following endpoints are supported with this plugin:

  • Geocode
  • Timezone
  • Places
  • Autocomplete
  • Input
  • Details
  • Elevation
  • Distance

Configuration

Enter a valid/active Google Maps API key in the plugin settings, easy does it.

Usage

Use HTTP GET request to access the endpoints

  • api/googleMaps/geocode/<latitude>,<longitude>
    Return the places given the latitude and longitude
    See more info at Google Geocoding API
  • api/googleMaps/timezone/<latitude>,<longitude>,<timestamp>
    Return the timezone of a place given the latitude, longitude and timestamp
    See more info at Google Timezone API
  • api/googleMaps/place/autocomplete/<input>
    Return place autocomplete suggestions given the text input (it can be an address, a place name etc)
    See more info at Places Autocomplete API
  • api/googleMaps/place/text/<input>/<fields>
    Return places given the text input (it can be an address, a place name etc). You can also define a comma sereparted list of the fields to return See more info at Places Search API
  • api/googleMaps/place/details/<placeId>
    Return place details given the place id . See more info at Places Details API
  • api/googleMaps/elevation/<lat>,<lon>
    Return elevation information given the latitude and longitude of a location
    See more info at Elevation API
  • api/googleMaps/distance/<originLat>,<originLon>,<destinationLat>,<destinationLon>,<mode>
    Return elevation information given the latitude and longitude of origin and destination. You can optionaly specify the mode (choose between driving, bicycling, walking, transit)
    See more info at Distance Matrix API

Example

Request
GET https://www.example.com/api/googleMaps/geocode/52.3679843,4.903561399999944

Response

[
  {
    "address_components": [
      {
        "long_name": "662",
        "short_name": "662",
        "types": [
          "street_number"
        ]
      },
      {
        "long_name": "Waterlooplein",
        "short_name": "Waterlooplein",
        "types": [
          "route"
        ]
      },
      {
        "long_name": "Amsterdam-Centrum",
        "short_name": "Amsterdam-Centrum",
        "types": [
          "political",
          "sublocality",
          "sublocality_level_1"
        ]
      },
      {
        "long_name": "Amsterdam",
        "short_name": "Amsterdam",
        "types": [
          "locality",
          "political"
        ]
      },
      {
        "long_name": "Amsterdam",
        "short_name": "Amsterdam",
        "types": [
          "administrative_area_level_2",
          "political"
        ]
      },
      {
        "long_name": "Noord-Holland",
        "short_name": "NH",
        "types": [
          "administrative_area_level_1",
          "political"
        ]
      },
      {
        "long_name": "Netherlands",
        "short_name": "NL",
        "types": [
          "country",
          "political"
        ]
      },
      {
        "long_name": "1011 PG",
        "short_name": "1011 PG",
        "types": [
          "postal_code"
        ]
      }
    ],
    "formatted_address": "Waterlooplein 662, 1011 PG Amsterdam, Netherlands",
    "geometry": {
      "location": {
        "lat": 52.3680461000000008198185241781175136566162109375,
        "lng": 4.90357839999999978175537762581370770931243896484375
      },
      "location_type": "ROOFTOP",
      "viewport": {
        "northeast": {
          "lat": 52.369395080291496924473904073238372802734375,
          "lng": 4.9049273802915021036596954218111932277679443359375
        },
        "southwest": {
          "lat": 52.36669711970849760973578668199479579925537109375,
          "lng": 4.90222941970849834802947952994145452976226806640625
        }
      }
    },
    "place_id": "ChIJ5zzsu70JxkcRQR-0VFl8Bl0",
    "plus_code": {
      "compound_code": "9W93+6C Amsterdam, Netherlands",
      "global_code": "9F469W93+6C"
    },
    "types": [
      "street_address"
    ]
  }
]

Credits

Made with ❤️ by Bolden and free to use.

googlemapsapi's People

Contributors

boldenamsterdam avatar cole007 avatar

Watchers

James Cloos avatar  avatar David Wood 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.