doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 9 forks source link

Recommended way to access lookup method from a custom module? #97

Closed twosixcode closed 1 year ago

twosixcode commented 1 year ago

Hi, been using this plugin for a long time on several projects. Great work. This is not an issue, but a question, just wasn't sure where to post it for good visibility.

I have a need to use the lookup method of the plugin to geocode some addresses. These are addresses coming into Craft automatically, and I'm planning to geocode them as a queued job. In case that matters.

Is there a recommended way to access the lookup method of the Google Maps plugin from my custom module? I'm flailing a bit and I saw that there was no service for this in the plugin itself, which is what I was hoping to see. Is there another way to accomplish this?

Thanks for any example code or recommendations you can provide!

PS this project is still on Craft v3 and is using v4.1 of the Maps plugin. We're about to update, but need to accomplish this work first. So any advice you have is greatly appreciated.

twosixcode commented 1 year ago

I figured it out

use doublesecretagency\googlemaps\helpers\GoogleMaps;

$coords = GoogleMaps::lookup($address)->coords();
lindseydiloreto commented 1 year ago

Ok awesome, that's exactly right! Glad you got it sorted out. 👍