Geocoder
2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: February 14, 2012 (RSS)
By design9 - February 10, 2012
Is it possible to use the geocoder on a page and have it work within two sections? Here is my geocoder coding:
I am pulling from the same table ( 'dir_listings') but have a regular section and a premium section.
list($dir_listingsRecords, $dir_listingsMetaData) = getRecords(array(
and
list($premium_listRecords, $premium_listMetaData) = getRecords(array(
They both use the dir_listings table.
Could I put the two section into an array merge?
$allListings = array_merge($dir_listingsRecords, $premium_listRecords);
I am having an issue with the miles coding because since my geocoder coding is set up to work with my dir_listingsRecords section, I get an undefined index error when working with my premium_listRecords. So I am looking for a way to have it work with both on the same page.
Thanks!
April
$addressRecords = array();
if ($myLat && $myLng) {
$maxDist = floatval(@$_REQUEST['maxDistance']);
list($dir_listingsRecords, $dir_listingsMetaData) = getRecords(array(
'tableName' => 'dir_listings',
'addSelectExpr' => geocoder_getSelectExprForDistance($myLat, $myLng, '_distance', $kmOrMiles), // adds '_distance' field to output records
'where' => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles), // 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
));
}
I am pulling from the same table ( 'dir_listings') but have a regular section and a premium section.
list($dir_listingsRecords, $dir_listingsMetaData) = getRecords(array(
and
list($premium_listRecords, $premium_listMetaData) = getRecords(array(
They both use the dir_listings table.
Could I put the two section into an array merge?
$allListings = array_merge($dir_listingsRecords, $premium_listRecords);
I am having an issue with the miles coding because since my geocoder coding is set up to work with my dir_listingsRecords section, I get an undefined index error when working with my premium_listRecords. So I am looking for a way to have it work with both on the same page.
Thanks!
April
Re: [design9] Geocoder
By Jason - February 14, 2012
Hi April,
You need to use the same geocoding function on your premium listing query as you did on the first query, that way you will have the _distance field created for both record sets. You can append something to the WHERE clause if necessary.
For example:
Hope this helps
You need to use the same geocoding function on your premium listing query as you did on the first query, that way you will have the _distance field created for both record sets. You can append something to the WHERE clause if necessary.
For example:
'where' => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles) . "AND premium_listing = 1",
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/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/