Geocoder - Not working

Re: [shawnpatoka] Geocoder - Not working

Hi,

The geocoder files and example directory should be in a geocoder directory in the plugins section. As in the example files the include for the viewer functions are hard coded to drop down three directories.

To get around this you could either move the geocoder files and example directory into a geocoder directory in the plugins section.

Or you could open the example files and change line 2 from:

<?php require_once "../../../lib/viewer_functions.php"; ?>

to

<?php require_once "../../lib/viewer_functions.php"; ?>

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Geocoder - Not working

thanks greg! if i want to substitute out tables from the sample to my own... would i just change:
$addressRecords = array();
if ($myLat && $myLng) {
$maxDist = floatval(@$_REQUEST['maxDistance']);
list($addressRecords, $addressMetaData) = getRecords(array(
'tableName' => $GLOBALS['GEOCODER_SAMPLE_TABLENAME'],
'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
));
}


to:

$addressRecords = array();
if ($myLat && $myLng) {
$maxDist = floatval(@$_REQUEST['maxDistance']);
list($addressRecords, $addressMetaData) = getRecords(array(
'tableName' => $GLOBALS['participating_bars'],
'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
));
}


because that doesnt seem to be working, as i get an error...
"Notice: Undefined index: participating_bars in /nfs/c06/h05/mnt/94791/domains/seenstream.com/html/sample_search.php on line 27 getRecords() errors
No 'tableName' value specified in options!"

Re: [shawnpatoka] Geocoder - Not working

By Jason - October 17, 2012

Hi,

You shouldn't need the $GLOBALS array. Try this:

$addressRecords = array();
if ($myLat && $myLng) {
$maxDist = floatval(@$_REQUEST['maxDistance']);
list($addressRecords, $addressMetaData) = getRecords(array(
'tableName' => 'participating_bars',
'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
));
}


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] Geocoder - Not working

nice! that seems to work. thank you!