Search by location

  • Hi,


    Has anyone developed any location search for Perch that anyone knows about?


    I'm looking to setup a store locator type of structure.


    I have a number of locations setup in perch and would like to link it up to Google Places / Maps so someone can enter a place name or postcode and it returns the nearest listing.


    Thanks in advance.

  • Is there anything in the Perch Debug output? The geocoding actually happens with the perch scheduled tasks so I doubt it has anything to do with the API key or geocoding.


    Have the DB tables been created? Should be looking for {DB_PREFIX}_root_locator_addresses, {DB_PREFIX}_root_locator_index, {DB_PREFIX}_root_locator_tasks

  • The tables haven't been created.


    The front end gives the below error message when searching for an address.


    Warning: array_map(): Expected parameter 2 to be an array, bool given in addons/apps/root_locator/lib/RootLocator_Addresses.class.php on line 400


    Warning: count(): Parameter must be an array or an object that implements Countable in addons/apps/root_locator/lib/RootLocator_Addresses.class.php on line 402


    I'm using Perch3, but the code in the files is showing the below.


    $sql .= '

    loc.locationTitle,

    loc.locationBuilding,

    loc.locationStreet,

    loc.locationTown,

    loc.locationRegion,

    loc.locationCountry,

    loc.locationPostcode,

    loc.locationDynamicFields,

    mkr.markerLatitude,

    mkr.markerLongitude,

    err.errorMessage

    FROM perch2_jw_locator_locations loc

    LEFT JOIN perch2_jw_locator_markers mkr ON loc.markerID = mkr.markerID

    LEFT JOIN perch2_jw_locator_failed_jobs err ON loc.locationID = err.locationID

    ';


    If I make the database tables, might that work? Starting to get complicated for me. Would I also need to add every row?


    If so, is there a way to find out what db structure needs to be manually entered?


    Thanks for your time.

  • I think the errors are unrelated to why the addresses won't add, as those lines are for retrieving the location, which as none have been added yet is probably why the errors are showing.


    The error 'Sorry, that location could not be created.' appears when the Factory create method failed. This is normally always an error in the DB, where the query is invalid or there are missing required fields. If you have PERCH_DEBUG set to true, there should be an error in that debug which should explain why it's failing

  • Sorry for the late reply, I was away from the office yesterday.


    I enabled debugging and it was bringing up that the tables were not found.


    I found the sql file and inserted that manually and it worked.


    The Google API key also needs added to the main index file on the front-end, as it was in the code as https://maps.googleapis.com/ma…ck=initMap&key=XXXXXXXXXX and didn't pull the api key from the main settings.


    Thank you very much for your time and information, it was a great help.