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 4cdg - September 8, 2011

Also some of our records are not coding correctly, like some in other states or other towns completely. We tried to go to google earth and get exact lat and lon and enter manually, but when you save it reverts back to the geocoded lat and lon

any way to manually enter the latitude and longitude when geocoder is activated?

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: [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.