# Problem with the GeoKit plug

**URL:** <https://www.ruby-forum.com/t/problem-with-the-geokit-plug/125272>\
**Category:** Rails\
**Created:** [January 7, 2008, 6:12pm UTC](https://www.ruby-forum.com/t/problem-with-the-geokit-plug/125272 "2008-01-07T18:12:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![naevity](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9a140/32.png) [@naevity](https://www.ruby-forum.com/u/naevity)\
**Post date:** [January 7, 2008, 6:12pm UTC](https://www.ruby-forum.com/t/problem-with-the-geokit-plug/125272/1 "2008-01-07T18:12:36Z")

</div>

I’m currently using the GeoKit plugin for a Rails web application I’m  
building, and I’m having a problem with the “find all locations within  
a distance from this location” aspect of it.

I have a browse form, which takes a distance, and a zipcode, and  
returns all locations that fit. However, it seems to only be returning  
the first location for each zipcode it finds.

For example, I have 5 locations:

Loc1 - 02110

Loc2 - 02110

Loc3 - 02360

Loc4 - 02110

Loc5 - 02360

The search function only returns two results, Loc1 and Loc3. My search  
function in the controller looks like this:

def search  
if params[:zip]  
@location = Location.find(:all, :origin =\>  
params[:zip], :within =\> params[:miles]  
@location = @location.sort\_by { |location| location.name }

---

<div class="post-metadata">

**Author:** ![naevity](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9a140/32.png) [@naevity](https://www.ruby-forum.com/u/naevity)\
**Post date:** [January 7, 2008, 6:13pm UTC](https://www.ruby-forum.com/t/problem-with-the-geokit-plug/125272/2 "2008-01-07T18:13:12Z")

</div>

I hit enter and cut my search function off.

def search  
if params[:zip]  
@location = Location.find(:all, :origin =\>  
params[:zip], :within =\> params[:miles]  
@location = @location.sort\_by { |location| location.name }  
@pages, @location = paginate(@location)  
end  
end

---

<div class="post-metadata">

**Author:** ![naevity](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9a140/32.png) [@naevity](https://www.ruby-forum.com/u/naevity)\
**Post date:** [January 7, 2008, 7:06pm UTC](https://www.ruby-forum.com/t/problem-with-the-geokit-plug/125272/3 "2008-01-07T19:06:40Z")

</div>

Never Mind, I’m an idiot,

I forgot that the first 2/3 of my test data was inputting before I had  
geomapping working correctly, so there wasn’t any lat/lng to test  
against.

case closed!
