Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

location query not returning any data #394

Open
thom-moresoda opened this issue Jun 19, 2024 · 6 comments
Open

location query not returning any data #394

thom-moresoda opened this issue Jun 19, 2024 · 6 comments

Comments

@thom-moresoda
Copy link

Description

After upgrading to craft 5 the location query no longer returns any data

{% set retailers = craft.entries.section('retailers').mapAddress({
	location: "london",
	radius: 20, 
	unit: 'mi',
}).all %}

Previously I could loop over this & get a list of retailers, after upgrading to craft 5 I'm not getting anything back

Additional info

  • Craft version: 5.1.7
  • Maps version: 5.0.0
  • PHP version: 8.2
  • Database driver & version: mariadb 10.5
  • Other Plugins: ckeditor, commerce, feed-me, postmark, snapshot, craft-retour, seomatic, templatecomments, freeform, scout, hyper, navigation, super-table, wishlist
@thom-moresoda
Copy link
Author

update:

I can get the location query to return data if I wrap the location term in the craft search wildcard syntax - this isn't particularly helpful for what I'm trying to do but it could suggest that something may have changed with the plugin?

{% set retailers = craft.entries.section('retailers').mapAddress({
	location: "*london*",
	radius: 20, 
	unit: 'mi',
}).all %}

any suggestions would be appreciated

@kevinmu17
Copy link

This issue is not only by upgrading to Craft 5.
we run a Craft 4.10.5 with the plugin version 4.0.8 where this is also the case

@kevinmu17
Copy link

Any news on this? we can't downgrade due to the polyfill issues so any help would be appreciated.

location: "*london*" this isn't helping, still getting 0 results back.

@wvgogh
Copy link

wvgogh commented Aug 13, 2024

Same issue here, I'm not getting any data back from location query.

Also getting this error when I'm trying to sort it on distance:

Exception (Database Exception) 'yii\db\Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance' in 'order clause' The SQL being executed was: SELECT elements.id, elements.canonicalId, elements.fieldLayoutId, elements.uid, elements.enabled, elements.archived, elements.dateLastMerged, elements.dateCreated, elements.dateUpdated, elements_sites.idASsiteSettingsId, elements_sites.siteId, elements_sites.title, elements_sites.slug, elements_sites.uri, elements_sites.content, elements_sites.enabledASenabledForSite, entries.sectionId, entries.fieldId, entries.primaryOwnerId, entries.typeId, entries.postDate, entries.expiryDateFROM (SELECTelements.idASelementsId, elements_sites.idASsiteSettingsIdFROMelements elementsINNER JOINentries entriesONentries.id=elements.idINNER JOINelements_sites elements_sitesONelements_sites.elementId=elements.id WHERE (entries.sectionId=2) AND (JSON_UNQUOTE(JSON_EXTRACT(elements_sites.content, '$.\"1a70323a-31e5-45ce-92c3-d9dab2bd9317\"')) IN (51.272154, 0.514951)) AND (((elements.enabled=TRUE) AND (elements_sites.enabled=TRUE)) AND (entries.postDate <= '2024-08-13 10:20:59') AND ((entries.expiryDate IS NULL) OR (entries.expiryDate > '2024-08-13 10:20:59'))) AND (elements.archived=FALSE) AND (elements.dateDeleted IS NULL) AND (elements.draftId IS NULL) AND (elements.revisionIdIS NULL) ORDER BYdistance) subqueryINNER JOINelements elementsONelements.id=subquery.elementsIdINNER JOINelements_sites elements_sitesONelements_sites.id=subquery.siteSettingsIdINNER JOINentries entriesONentries.id=subquery.elementsIdORDER BYdistance'

@remcoov
Copy link

remcoov commented Aug 29, 2024

Ok, so here is the weird thing. It also broke in my project. Now.. locally I updated everything to the latest version (Craft 4.11.4 and Ether maps 4.0.8). It is working.

I pushed everything to online (so I have the versions mirrored) .. doesn't work. Checking my Google Cloud Console afterwards I noticed the Geocoding API only stacking up with 4XX errors (no clue as where to find what error that is). So.. I'm guessing it's either a db/query error or Google API related? Or a combo of both, where the wrong db data is sent to the Google API.

Ether, please update people...

@kevinmu17
Copy link

Based on what @remcoov said, i checked my cloud configs. So i deleted the Set an application restriction (had it configured with Websites) and all is working perfectly fine again.

So my guess is that Google changed something here with the restrictions. More info here

We saw our metrics from the Geocoding api going rogue with errors...

I've battletested every bit from our end (craft version, plugin version, DB comparison with working vs not working, loaded the not working into local install where it worked, refreshed api keys without any configs etc)

Now i wonder HOW to restrict the API key, since every single domain option I add here is making sure it DOENS'T work. So only with the restrictions to none it delivers results.

Tam added a commit that referenced this issue Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants