ethercreative / simplemap

A beautifully simple map field type for Craft CMS.
Other
137 stars 47 forks source link

Craft 5 - query with location #392

Open abm-schuh opened 3 months ago

abm-schuh commented 3 months ago

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

amici-infotech commented 2 months ago

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

stevendierick commented 2 months ago

Same issue here. Any update on this?

thom-moresoda commented 2 months ago

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 commented 1 month ago

Any news on that topic? Still having the same problem

thom-moresoda commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

Ether Creative please give us a feedback!

remcoov commented 1 week ago

See my latest findings. Any update Ether?

RyVeata commented 3 days ago

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 🤞