This feature request was first mentioned here: http://drupal.org/node/321114#comment-1694654
Regarding ZIP/postcodes for proximity searching in a View. I think it would be a valuable feature to also add functionality for a larger proximity scope, such as for Country + City?
An alternative could be to enter ZIP or Country+City - then a method to convert to the central ZIP for that city.
Here in Europe we don't have that many huge cities so using a ZIP code is often too specific. For example, I live in the 7th largest city in Italy - which has an area of only 55 square miles. So for us to implement a ZIP codes method seems a little unusual.
What does everyone else think about this?
Comments
Comment #1
fallsemo commentedBig +1 for this one. I'm surprised this has not been implemented. Any reason for that? Are there other Drupal methods to achieve this?
Comment #2
ioskevich commentedVery interested as well.
Comment #3
juicytoo commentedsomething like this would be great.
the search box on the left of this page.
http://www.trulia.com/NY/Bronx/
Comment #4
dpatte commentedsubscribe
Comment #5
dufferin commentedOn top the ZIP is kind of useless... who knows them? I have a hard time to remind mine!
Comment #6
summit commentedSubscribing, interested in this also! Martijn
Comment #7
jastylr commented+1 for this. I'm looking for proximity search by City/State myself. I have implemented Zip Code search but as others have mentioned, who knows the Zip Codes of all the cities they could potentially be searching for. I know my own zip code but if I want to find nodes in other cities, I would first need to look up the zip somewhere and then enter it.
Comment #8
dargente commentedjust got proximity search working from views. same functionality as Spatial Solr except in views we are able to configure the search results in a customized format. Problem with both solutions is that they search with zip code input, rather than City, State. i have limited knowledge about module codes, but this doesn't seem like a difficult endeavor to patch up, whereas we take City, State (default country) input and do a node proximity search. The zipcodes database already includes the following fields:
(zip, city, state, latitude, longitude, timezone, dst, country)
so city and state already matched to lat/long,
the problem might be that there are multiple lat/longs for some zips or cities:
('48103', 'Ann Arbor', 'MI', '42.280887', '-83.791470', -5, 1, 'us'),
('48104', 'Ann Arbor', 'MI', '42.266805', '-83.722970', -5, 1, 'us'),
('48105', 'Ann Arbor', 'MI', '42.307288', '-83.704430', -5, 1, 'us'),
('48106', 'Ann Arbor', 'MI', '42.253502', '-83.836571', -5, 1, 'us'),
('48107', 'Ann Arbor', 'MI', '42.253502', '-83.836571', -5, 1, 'us'),
('48108', 'Ann Arbor', 'MI', '42.232807', '-83.726710', -5, 1, 'us'),
('48109', 'Ann Arbor', 'MI', '42.291637', '-83.718310', -5, 1, 'us'),
in this case can we take the median of each lat/long, and specify one point for all?
for me, it would even suffice just to take the first instance of the city/state.
anybody know if there is a patch for this yet?
Comment #9
jpowell commentedSimilar to the request to do City/State proximity searching, it would be great to use the HTML 5 getCurrentPosition tag to get the GPS coordinates of the user through a mobile browser like Safari on the iPhone and do a proximity search based on the latitude/longitude of the user.
Comment #10
jcarnett commentedIf you're comfortable coding and you're using both Location and Gmap modules, it's pretty easy to make proximity search much better than the simple zip-only lookup provided by Location. The idea is that we can pass off the source to Google for geocoding, which allows us to search on street addresses, cities, states, zip codes, even landmark names.
Change the view's proximity filter to latitude/longitude input and then create a module with something like this:
Notes:
Comment #11
dargente commentedthanks for this jcarnett,
seems like i almost got it working after doing the following:
- created new module
- changed my_view_name to my view name
results
it hides the previous proximity input fields as intended,
and adds the new input field,
but i'm not getting any search results when using any proximity filter now,
unless i enter in a static lat/lon or zipcode in the filter setup.
i have it configured as Lat / Long input (map)
proximity (rectangular)
distance 100 miles
i am testing with US zipcodes, cities, states to no avail.
am i missing something?
Comment #12
dargente commenteddisregard above ,
i was getting no results when testing in Views,
but it is working in the actual page, nice!
although, how to set the location input as optional,
right now, if field is blank then there are no results,
it would be nice to show ALL keyword-based results if location is not set.
checking-off the exposed filter as Optional has no effect.
Comment #13
jcarnett commentedThat's an open issue with the location module (http://drupal.org/node/505596). The "fix" without patching anything is to clear the default search radius in your view. If you still want a search radius, you can modify the above code to set it along with the latitude and longitude when it updates $form_state.
Comment #14
yesct commented#505596: Optional Proximity Value does not seem to be optional (just linking the issue from #13 using the bracket #505596 bracket notation)
Comment #15
dargente commentedhow do i modify the above code to set it along with the latitude and longitude when it updates $form_state?
thanks
Comment #16
agreenwood13 commentedI have got this working - as inthe long and lat co-ordinates are coming back.
But for some reason the search is not working.
Did a bit of fiddling and if the long/lat information is manually inputted it is not work. A postcode search works fine but long/lat does not.
Any ideas?
Comment #17
dargente commentedSame here, Search is not working.
Anyone have a fix for this?
Comment #18
xpersonas commentedFailed post. I'm an idiot.
Comment #19
Anonymous (not verified) commentedany update on this, or input on how to implement this for 7.x-3.x-dev? this would definitely be a great feature to be able to proximity search by city name. thanks for any advice/help!
Comment #20
sumitk commentedDuplicate #1109240 but I can confirm location 3.x is not working with latest version of views. Proximity search with zip is broken there.
Comment #21
clashar commented+1, would like to see at least in D7
Comment #22
HippoOnDiet commentedHi Guys,
Just an idea of tackling this issue...
I am thinking of using Location: Distance / Proximity exposed filter with Postal Code and Distance (Country set to default).
Basically I will label Postal code with Location Near or City (so I will do a bit form Alter on the Postal Code field itself)
Now the idea is...
User will enter a city in Postal_code field, for example "Melbourne" and search then I will run Database query:
db_query("SELECT zip FROM {zipcodes} WHERE city = '%s'", Melbourne);
In order to get the Postal_Code number.
Once we have the postal code number, then we can set the value to postal_code field and we will have result around that area.
the only issue is I am not really with coding :(
Thank you.
Update... this is what I come up with for function yourmodule_form_alter.
I hide two fields and change label of Postal Code to Location Near:
Then this is during validation:
NOTE: I use this for my particular state only, therefore no duplication of city name in database table.
Comment #23
damienmckennaI'm working on this for an existing D6 site. While digging through the code to see why Canadian searches weren't working I ran across the following in location.views.inc:
This indicates that the postal code proximity search is limited to only working with US values. This is kinda silly :-)
Instead of this the postal code value should be checked against the 'zipcodes' table to find the appropriate country name.
Comment #24
damienmckennaNever mind, someone had used the wrong 'origin' on the filter on my site. Gah.
Comment #25
damienmckennaOh. Wait. Someone set the proximity filter to the "Postal Code (assume default country)" origin rather than "Postal Code / Country". Dangit.
Comment #26
legolasboClosing old D6 issues as D6 is end of life