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 APIapi/googleMaps/timezone/<latitude>,<longitude>,<timestamp>
Return the timezone of a place given the latitude, longitude and timestamp
See more info at Google Timezone APIapi/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 APIapi/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 APIapi/googleMaps/place/details/<placeId>
Return place details given the place id . See more info at Places Details APIapi/googleMaps/elevation/<lat>,<lon>
Return elevation information given the latitude and longitude of a location
See more info at Elevation APIapi/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 – free to use and feedback in much appreciated!
Installation Instructions
To install this plugin, copy the command above to your terminal.
Reviews
This plugin doesn't have any reviews.
Active Installs
24
License
MIT
Last release
July 9, 2019
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs