doublesecretagency / craft-googlemaps
Maps in minutes. Powered by the Google Maps API.
Installs: 55 953
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 6
Forks: 10
Open Issues: 20
Type:craft-plugin
- dev-v5-dev
- v5.x-dev
- 5.1.0
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 5.0.0-beta.2
- 5.0.0-beta.1
- v4.x-dev
- 4.6.1
- 4.6.0
- 4.5.2
- 4.5.1
- 4.5.0
- 4.4.0
- 4.3.11
- 4.3.10
- 4.3.9
- 4.3.8
- 4.3.7
- 4.3.6
- 4.3.5
- 4.3.4
- 4.3.3
- 4.3.2
- 4.3.1
- 4.3.0
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.9
- 4.1.8
- 4.1.7
- 4.1.6
- 4.1.5
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.11
- 4.0.10
- 4.0.9
- 4.0.8.1
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 4.0.0-rc.2
- 4.0.0-rc.1
- dev-v4-dev
This package is auto-updated.
Last update: 2024-12-12 20:00:19 UTC
README
Google Maps plugin for Craft CMS
Maps in minutes. Powered by the Google Maps API.
Address Fields • Dynamic & Static Maps • Proximity Searching • IP-based GeolocationIncludes easy-to-use Address Fields
When managing your Craft data, each location can be set with a convenient Address field...
Create flexible Dynamic & Static Maps
Add markers, use info windows, style maps, change marker icons, apply KML layers, and much, much more...
Universal API
The plugin features a powerful universal API which works nearly identically across JavaScript, Twig, and PHP!
Search for the Nearest Locations
Find the closest locations, and sort the results from nearest to furthest...
Simple IP-based Visitor Geolocation
Locate your visitors based on their device's IP address...
How to Install the Plugin
Installation via Plugin Store
See the complete instructions for installing via the plugin store...
Installation via Console Commands
To install the Google Maps plugin via the console, follow these steps:
- Open your terminal and go to your Craft project:
cd /path/to/project
- Then tell Composer to load the plugin:
composer require doublesecretagency/craft-googlemaps
- Then tell Craft to install the plugin:
./craft plugin/install google-maps
Alternatively, you can visit the Settings > Plugins page to finish the installation. If installed via the control panel, you will automatically be redirected to configure the plugin after installation is complete.
Once installed, you will need to add Google API keys...
Simple Code Examples
These examples barely scratch the surface of what is possible!
For complete details, check out the official plugin documentation...
Adding a Dynamic Map
{# Get the entries #} {% set entries = craft.entries.section('locations').all() %} {# Place them on a dynamic map #} {{ googleMaps.map(entries).tag() }}
Adding a Static Map
{# Get the entries #} {% set entries = craft.entries.section('locations').all() %} {# Place them on a static map #} {{ googleMaps.img(entries).tag() }}
Or use the src
attribute directly...
{# Get only the image URL of a static map #} {% set src = googleMaps.img(entries).src() %} {# Display the image tag manually #} <img src="{{ src }}">
Conducting a Proximity Search
{# Set the geocoding lookup target #} {% set target = '123 Main St' %} {# Get a set of entries, sorted by closest to target #} {% set entries = craft.entries.myAddressField(target).orderBy('distance').all() %}
Conducting a Geocoding Address Lookup
{# Set the geocoding lookup target #} {% set target = '123 Main St' %} {# Get a set of geocoding results #} {% set results = googleMaps.lookup(target).all() %}
Geolocating Visitors
{# Get location data based on each visitor's IP address #} {% set visitor = googleMaps.visitor %}
Further Reading
If you haven't already, flip through the complete plugin documentation. The examples above are just the tip of the iceberg, there is so much more that is possible!
And if you have any remaining questions, feel free to reach out to us (via Discord is preferred).
On behalf of Double Secret Agency, thanks for checking out our plugin! 🍺