Jump to:
| Project: | Location |
| Version: | 5.x-3.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hi all, thank you thank you thank you for developing these modules all together! Please forgive me for not touching the status of this, as I do not know how to commit a patch. my locations and geo-encoding works, views: check, gmap:check - everything all happy, except with the proximity option when making a view of locations, like a store locator:
Problem:
I had a problem with my Proximity filter working on my drupal site when searching with views. I installed all the modules required, and added the zipcodes into my database and still nothing on my views search. I read for the better part of this afternoon and could not figure out for the life of me what was going on. I ran into a post: http://drupal.org/node/132181 and http://drupal.org/node/326749#comment-1155243 but none of these solutions seemed to work, but they were all pointing ultimately to the right direction in solving the over all problem. No output, just my "empty text" message from my view.
Solution:
Ok, long story short - what was happening for me is that the $filter['value']['latitude'] and $filter['value']['longitude'] were always populating with a value, specifically the first number of the queried postalcode. So if the zip was 8xxxxx, then the $filter['value']['latitude'] and $filter['value']['longitude'] value was populated with 8 - weird huh?
So, what I did was this on approx line 948:
if (!empty($filter['value'])) {
$zip = $filter['value'];
// @@@ This needs to factor in country.
$result = db_query("SELECT * FROM {zipcodes} WHERE zip = '%s'", $zip);
while ($arr = db_fetch_array($result)) {
$lat = $arr['latitude'];
$lon = $arr['longitude'];
}
}
else {
$lat = $filter['value']['latitude'];
$lon = $filter['value']['longitude'];
}So that if the postal code is empty, then use the lat an lon from wherever that comes from.
if the postal code is populated, then it takes that. Bam, everything works as expected.
I can't see anything that is being affected by my change, so if you guys think it's cool i would humbly suggest making this change.
My environment:
Drupal 5.12
Location: 5.x-3.0
GMAP 5.x-1.x-dev
CCK 5.x-1.10
Location CCK 5.x-3.0
Views 5.x-1.6
Thanks for taking a look at this!
Comments
#1
i just read this again - and realized I forgot to specify which file, which is location_views.module
#2
This worked for me too.
I just replaced
if (isset($filter['value']['latitude'])) {$lat = $filter['value']['latitude'];
$lon = $filter['value']['longitude'];
}
else {
$zip = $filter['value'];
// @@@ This needs to factor in country.
$result = db_query("SELECT * FROM {zipcodes} WHERE zip = '%s'", $zip);
while ($arr = db_fetch_array($result)) {
$lat = $arr['latitude'];
$lon = $arr['longitude'];
}
}
with
if (!empty($filter['value'])) {$zip = $filter['value'];
// @@@ This needs to factor in country.
$result = db_query("SELECT * FROM {zipcodes} WHERE zip = '%s'", $zip);
while ($arr = db_fetch_array($result)) {
$lat = $arr['latitude'];
$lon = $arr['longitude'];
}
}
else {
$lat = $filter['value']['latitude'];
$lon = $filter['value']['longitude'];
}
#3
list($lat, $lon) = explode(',', $filter['value');
#4
Can you post the code for the section in question? I have not used list() in the whole function - I'm just interested in your solution! Thanks!
#5
Resetting title
#6
subscribe
#7
BTW - it looks like the new GMAP and Location modules resolves these problems - they rock!
#8
Sounds like this was fixed for the original poster by upgrading to the most recent versions. If there is still a bug in the most recent versions, just post back.
#9
Automatically closed -- issue fixed for 2 weeks with no activity.