I'm working on an estate agents website and am looking to create a 'find properties near me' feature.
Any ideas on how I might do this will be gratefully received!
Thanks in advance,
Tom
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.
Sign up to join this communityI'm working on an estate agents website and am looking to create a 'find properties near me' feature.
Any ideas on how I might do this will be gratefully received!
Thanks in advance,
Tom
Geofinder add-on will help you here: http://devot-ee.com/add-ons/geofinder
Docs: http://mightybigrobot.com/docs/geofinder/
Then each of the properties is an entry which has a longitude and latitude reference for the location.
Example search form:
{exp:geofinder:simple_form id="findhome" result_page="/home-search" class="group"}
<fieldset>
<legend>Search for a home</legend>
<input type="hidden" name="radius" value="1000" />
<label for="searchhome">Search for a home</label>
<input type="text" name="geoquery" id="searchhome" class="required" title="Enter a search location" value="" />
<button type="submit">Search</button>
</fieldset>
{/exp:geofinder:simple_form}
Example results page:
{exp:geofinder:location_results channel="content" limit="6" geoquery="{segment_2}" radius="1000" latitude="latitude" longitude="longitude" disable="member_data|category_fields|trackbacks"}
{if no_results}No results can be found for that location. Please try a different search term: either a postcode, city or town{/if}
<div class="homeresult group">
<div class="summary">
<h2><a href="{page_uri}">{if alternative-title}{alternative-title}{if:else}{title}{/if} <em>{location-details}{town}, {county}{/location-details}</em></a></h2>
<h3>{distance} miles from {exp:markup_master:replace find="+" replace=" "}{segment_2}{/exp:markup_master:replace}
<a href="#?custom=true&width=600&height=400" rel="popup-map" class="button">Show on a map
<span class="longitude">{longitude}</span>
<span class="latitude">{latitude}</span>
</a>
</h3>
{if "{excerpt}"}{excerpt}{if:else}{exp:trunchtml chars="150" inline="..."}{content-text}{/exp:trunchtml}{/if}
</div>
</div><!--/.homeresult-->
{/exp:geofinder:location_results}
Update
The above example is where you prompt the user for a location, if you want to allow for mobile devices and automatically defaulting to the users location based on IP, you could use IPGeo http://devot-ee.com/add-ons/ipgeo. Although a great add-on, it does have a fair overhead and needs to be updated every few months to ensure all the latest IP address database.
On the initial search form you would add hidden fields like so:
{exp:ipgeo}
<input type="hidden" name="user_lat" value="{latitude}">
<input type="hidden" name="user_lng" value="{longitude}">
<input type="text" name="geoquery" id="searchhome" class="required" title="Enter a search location" value="{city}" />
{/exp:ipgeo}
I've only entered the automatic City entry above so that the user has something to submit to.
I understand that the Google Maps for ExpressionEngine add-on is a go-to addon for "geofinding," based on this examples page in which there is a "store locator" example. As luck would have it, that particular example is borked right now (I get an "out of memory error" when I go to access the particular example).
It sounds like it would be worth it to write the developer, ask them about the add-on's compatibility with the latest EE version, and see if they can't fix the issue on the examples page so you can see how it performs.
I have this addon running on a site I'm using and I like it (it performs far better than other addons have, in my experience), but so far, I've only used it to display maps.
Rob