Thumbnail
Macareux Google Map Attribute

Developed by

Beginner
Beginner
Version 9 Ready!

A Concrete CMS package to add a new attribute type to set location for objects with google map interface.

How to use

This package installs the "Google Map" attribute type.

You can set a location to objects like pages, users, express entries, etc. Please add an attribute key for objects. You have to get a Google Cloud Platform API Key that enables Places API and Maps Static API for it.

You can display the attribute value by using Page Attribute Display block with no coding.
It'll be displayed as a static map image instead of an iframe embed map.

 

Example: Get coordinates by code

/* @var \Concrete\Core\Page\Page $page */
// Display Static MAP
echo $page->getAttribute('your_attribute_handle');
/** @var \Macareux\Package\GoogleMapAttribute\Entity\GoogleMapValue $value */
$value = $page->getAttribute('your_attribute_handle');
if ($value) { // Get values manually $location = $value->getLocation(); $latitude = $value->getLatitude(); $longitude = $value->getLongitude(); $zoom = $value->getZoom(); $showMarker = $value->getMarker(); }

 

Example: Sort ItemList the nearest item first

use Concrete\Core\Page\PageList;
use Macareux\Package\GoogleMapAttribute\Utility\QueryApplier;

$list = new PageList();
$currentLatitude = 35.6681625;
$currentLongitude = 139.6007834;
QueryApplier::applySortByNearest($list, 'your_attribute_handle', $currentLatitude, $currentLongitude);
$pages = $list->getResults();

If you don't familiar with PageList class, please check the official documentation: Searching and Sorting with the PageList object

 

Example: Customize Static MAP

You can customize Static MAP by overriding Macareux\Package\GoogleMapAttribute\Utility\GoogleMapRenderer class.

use Macareux\Package\GoogleMapAttribute\Utility\GoogleMapRendererInterface;

$app->bind(GoogleMapRendererInterface::class, 'CustomRendererClassName');

 

License

This package is published under the MIT License. Please feel free to make a pull request if you find some bugs.

https://github.com/MacareuxDigital/md_google_map_attribute

Current Version: 1.1
Fully Translatable: Yes
Needs External Libraries: No
Compatible 9.0.0+
License: MIT
Support Response: Replies to tickets every few days.
Support Hosted: On marketplace.concretecms.com
Needs extra server permissions: No
Needs Internet: No
Marketplace Tests:
Passed Automated Tests
Passed PRB Review