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

Craft 5 - query with location #392

Open
abm-schuh opened this issue Jun 7, 2024 · 10 comments
Open

Craft 5 - query with location #392

abm-schuh opened this issue Jun 7, 2024 · 10 comments

Comments

@abm-schuh
Copy link

abm-schuh commented Jun 7, 2024

Description

I try to query some entries by lat/lng
My Field handle is "addressCoordinates"

{% set haendler = craft.entries.section("haendler").addressCoordinates({
    location: { 
        lat: 52.3073549, 
        lng: 8.6699708 
    }, 
    radius: 50,
    unit: 'km'
}).orderBy('distance asc').all() %}

Output is:

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`.`id` AS `siteSettingsId`, `elements_sites`.`siteId`, `elements_sites`.`title`, `elements_sites`.`slug`, `elements_sites`.`uri`, `elements_sites`.`content`, `elements_sites`.`enabled` AS `enabledForSite`, `entries`.`sectionId`, `entries`.`fieldId`, `entries`.`primaryOwnerId`, `entries`.`typeId`, `entries`.`postDate`, `entries`.`expiryDate`
FROM (SELECT `elements`.`id` AS `elementsId`, `elements_sites`.`id` AS `siteSettingsId`
FROM `elements` `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`=10) AND (`elements_sites`.`siteId`=1) AND ((`elements_sites`.`content`->>'$.\"5691a8fb-651e-437b-b392-e568ca1955d2\"') IN (50, 'km')) AND (((`elements`.`enabled`=TRUE) AND (`elements_sites`.`enabled`=TRUE)) AND (`entries`.`postDate` <= '2024-06-07 09:31:59') AND ((`entries`.`expiryDate` IS NULL) OR (`entries`.`expiryDate` > '2024-06-07 09:31: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`
Error Info: Array
(
    [0] => 42S22
    [1] => 1054
    [2] => Unknown column 'distance' in 'order clause'
)

Steps to reproduce

  1. Craft 5
  2. Query entries by lat/lng

Additional info

  • Craft version: 5.1.8
  • Maps version: 5.0.0
  • PHP version: 8.3
  • Database driver & version: MySQL 8.1.0
  • Other Plugins: ether/seo, craft commerce, feed-me
@amici-infotech
Copy link

I am having this issue as well. Is there any progress with that or any temporary solution anyone has come up with?

@stevendierick
Copy link

Same issue here. Any update on this?

@thom-moresoda
Copy link

any progress with this one? May not be any help, but I'm having a similar issue with the plugin on craft 5 where the query wont return any data. Only way I can get anything out of it is using crafts search syntax. Eg:

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

returns nothing, but

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

will return all entries with the word 'london' in it. Not particularly helpful in my instance, but may do the job if anyone is just looking to do a simple search by keyword on the map

@abm-schuh
Copy link
Author

Any news on that topic? Still having the same problem

@thom-moresoda
Copy link

I've had no updates. Our client has agreed to keep the map with its reduced functionality for now & we'll likely move to using a different plugin. I can't see that ether are responding to any issues so I'm starting to think simplemap has been abandoned

@knufri
Copy link

knufri commented Jul 15, 2024

The same issue here! A quick fix would be nice @Tam - can't upgrade to Craft 5 because my client site need the search by location feature.

@knufri
Copy link

knufri commented Jul 16, 2024

Hello folks,

I contacted Ether Creative directly by e-mail and received the following reply:

Hi Jan,

It’s still actively mantained and we’re working on a fix which we hope to release soon.

All the best
Alex

So we have to wait a little bit. Thanks to Ether Creative for this excellent plugin 🙏🏼

@knufri
Copy link

knufri commented Aug 16, 2024

Ether Creative please give us a feedback!

@remcoov
Copy link

remcoov commented Aug 29, 2024

See my latest findings. Any update Ether?

@RyVeata
Copy link

RyVeata commented Sep 2, 2024

Also experiencing this since upgrading to Craft 5. Searching by location and distance sort order is a core feature to our product so fingers crossed for an update soon 🤞

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

7 participants