Filter Geocoder multi-map based on field info

By 4cdg - September 8, 2011

I have a geocoder multi-map and proximity search on the same page at http://stoddardmls.com/proximity.orig.php

When the page loads it shows all the records in the listings table, I need it to show only the records where category = For Sale.

Once i do a proximity search i filter the results with a hidden field in the search form, but the map that loads initially i don't know how to only show records marked for sale.

I have attached the page
Attachments:

proximity-orig.php 17K

Re: [4cdg] Filter Geocoder multi-map based on field info

By Jason - September 8, 2011

Hi,

For your first issue, you can manually add that condition to your WHERE clause like this:

list($addressRecords, $addressMetaData) = getRecords(array(
'tableName' => 'listings',
'addSelectExpr' => geocoder_getSelectExprForDistance($myLat, $myLng, '_distance', $kmOrMiles), // adds '_distance' field to output records
'where' => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles)." AND status = 'For Sale'", // optimization: remove results outside of minimum bounding rectangle
'having' => "_distance <= " . $maxDist, // only show results within max distance
'orderBy' => 'ISNULL(_distance), _distance', // sort nearest records first -and- unknown or undefined distances last
));


For your second issue, you can set the plugin so that it doesn't automatically overwrite/set the lat and long field when you save but setting this in the plugin:

$GLOBALS['GEOCODER_AUTOSET_LAT_LNG_FIELDS'] = false;

Please note that this means that you will either have to manually enter your lat and long values, or use the "Geocode Table" function from the plugins page.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Filter Geocoder multi-map based on field info

By 4cdg - March 23, 2012

the code you provided above won't work in my case because the website is auto coding thousands of records being input by multiple users. It is a real estate multi listing website and sometimes we have cases of google not having the correct location on a map such as a new sub-division or a really rural area or some acreage for sale and need to enter lat and long manually. This is something that we need a fix for. May require second level support or an update to the geocoder, which by the way is awesome.

Re: [4cdg] Filter Geocoder multi-map based on field info

By (Deleted User) - March 26, 2012

Hi 4cdg,

Which part of the code isn't working for you - the "for sale" filter or disabling the lat/long auto-overwrite for the geocoder?

If it's the former we'd need to see the script that's generating the page and the input method for the data so we can make some more suggestions - please submit a second level support request https://www.interactivetools.com/support/email_support_form.php.

If the latter - we would need to look at customizing the geocoder to not overwrite extant lat/long (eg only complete those that are not already present). This would be a consulting job so you'd have to send details to consulting@interactivetools.com so we can spec up what needs to be done for you.

Let me know if this helps,

Tom

Re: [Tom P] Filter Geocoder multi-map based on field info

By 4cdg - March 26, 2012

It is disabling the lat/long auto-overwrite. I will send info to consulting.