ethercreative / simplemap

A beautifully simple map field type for Craft CMS.
Other
135 stars 48 forks source link

location query not returning any data #394

Open thom-moresoda opened 5 months ago

thom-moresoda commented 5 months ago

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

thom-moresoda commented 4 months ago

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 commented 4 months ago

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 commented 3 months ago

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 commented 3 months ago

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: SELECTelements.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.expiryDate FROM (SELECTelements.idASelementsId,elements_sites.idASsiteSettingsId FROMelements`elements INNER JOIN entries entries ON entries.id = elements.id INNER JOIN elements_sites elements_sites ON elements_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.revisionId IS NULL) ORDER BY distance) subquery INNER JOIN elements elements ON elements.id = subquery.elementsId INNER JOIN elements_sites elements_sites ON elements_sites.id = subquery.siteSettingsId INNER JOIN entries entries ON entries.id = subquery.elementsId ORDER BY distance' `

remcoov commented 2 months ago

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 commented 2 months ago

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.