simplemap icon indicating copy to clipboard operation
simplemap copied to clipboard

location query not returning any data

Open thom-moresoda opened this issue 1 year ago • 6 comments
trafficstars

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 avatar Jun 19 '24 10:06 thom-moresoda

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

thom-moresoda avatar Jun 27 '24 12:06 thom-moresoda

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 avatar Jul 17 '24 09:07 kevinmu17

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.

kevinmu17 avatar Jul 31 '24 10:07 kevinmu17

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'

wvgogh avatar Aug 13 '24 10:08 wvgogh

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...

remcoov avatar Aug 29 '24 10:08 remcoov

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.

kevinmu17 avatar Aug 29 '24 11:08 kevinmu17