simplemap icon indicating copy to clipboard operation
simplemap copied to clipboard

Searching via address string doesn't return any results

Open Decipher-Webmaster opened this issue 4 years ago • 2 comments

Description

When carrying out a proximity search using an address string, no results are returned. However, when searching using co-ordinates, results are returned as expected. Here is an example snippet of the query I'm trying to implement:

{% set locationParam = craft.app.request.getParam('location') %}
{% set searchRadParam = craft.app.request.getParam('search-radius') ?? 100 %}

{% set retailersQuery = craft.entries().location({
    location: locationParam,
    radius: searchRadParam,
    country: 'UK',
    unit: 'mi'
}) %}

{% paginate retailersQuery as pageInfo, retailers %}

{% for retailer in retailers %}
    ...
{% endfor %}

The plugin is configured using 'Google Maps: Terrain' as the Map Style and 'Google Maps' as the GeoService. Both are confirmed to be working correctly via the Google Cloud Platform. When searching a comma-separated town & post code identical to that set in some example entries maps field, no results are returned. When searching the equivalent co-ordinates, all expected results are returned.

Steps to reproduce

  1. Add an entry containing a location field, add the address to the 'Maps' field and publish/save the entry.
  2. Execute maps proximity search query, with the location parameter set to an address string.

Additional info

  • Craft version: 3.6.5.1
  • Maps version: 3.9.0.2
  • PHP version: 7.3.3
  • Database driver & version: MySQL 5.7.25
  • Other Plugins:
    • Amazon S3 - 1.2.11
    • Craft Commerce - 3.2.14.1
    • Eager Beaver - 1.0.4
    • FeedMe - 4.3.5.1
    • Freeform - 3.10.7
    • Linkit - 1.1.12.1
    • Minify - 1.2.10
    • Navigation - 1.4.13
    • Redactor - 2.8.5
    • SEOMatic - 3.3.32
    • Store Hours - 2.1.1.1
    • Super Table - 2.6.7
    • Wish List - 1.4.4
    • Wordsmith - 3.3.0.1

Decipher-Webmaster avatar Feb 15 '21 18:02 Decipher-Webmaster

I had the same issue, but my problem was in the configuration of the Google API key used for the Geocoding API. The value of the "Application restrictions" was set to "HTTP referrers (web sites)" which means Craft CMS could not reach it (as a server). When you set it to "None" or "IP adresses (web servers, cron jobs, etc)", then Craft CMS is also possible to connect to the API.

I would expect though that SimpleMap would output some error logs on failures, but I couldn't find any in the logs of Craft CMS.

ctigelaar avatar Jul 16 '21 22:07 ctigelaar