AuthorTopic: Proximity Search (Read 6093 times)

Want to plan a pubcrawl, but you don't know the city you're planning to crawl?

Want to find the closest beer store to stop at after leaving the next brewpub you plan to visit?

Well, possibly, a new feature that I'm working on will help out with that!

Currently, you can view the search page by city, state, or zip. But now I have added three new links under each location.

As you can see, you now have an option to click "1 mile", "5 miles" or "10 miles". Each of these does about what you would expect. Which is return all locations within that distance (note: this is not traveling distance, but a direct line radius distance - as the crow flies).

The fact that I got this to work, means that eventually I will set it up so there will be a link on the results page that will actually map out all locations that are returned as a result.

Please let me know what you think or if you find this useful!

Note: the current page is horribly ugly (edit: I have redirected the page to a prettier page - you can disregard this "note"). It simply grabs the correct locations and puts them on a plain white page with very little text formatting at all. I will work on the "prettyness" of this page when I get a break (not today unless I start procrastinating on my other stuff )

By the way, just in case someone out there is working on their own map stuff (I know kp does some), here is the code for the distance algorithm. I found it online and I barely know what the math does, but I had to rework it to fit with the beermapping stuff.

$sql = "SELECT * FROM ($baseSql) AS filteredTable WHEREdistanceFromOrigin <= $filterSize ORDER BY name";?>Basically, a variable in the query string ($dist) is used to filter the locations in the database that have a latitude and longitude that are within a certain value range depending on the original location's lat/long. Most of the heavy math goes into the SQL query that actually goes out and builds a table with the locations that fit the criteria. Enjoy!

This would also be useful with the marker clustering to automatically cluster markers within x miles of each other at a y zoom level.

I think this would be a good tool for the city maps that beermapping has. At the moment I am "approving" towns that go along with each city map. Giving each City map a 50 or so mile radius would make that part of the mapping process much easier. I could also make it so the radius could be expanded or contracted if a user wanted to see more or less depending on the center of the search.

I'm not exactly sure what formula they are using for the clustering, but it does have something to do with setting the bounds of the map depending on the lat/long. It's probably much simpler math since the lat/long wouldn't need to be converted to miles for the map to be able to cluster points.

But simply having these options will open up a lot of different options for future beer maps.

Also, I'm wondering when the features will be added to actually show a route map with directions. Enter starting location (brewery, pub, ...), ending location, and perhaps radius or a list of places to include, specify walking / driving / public transportation, press enter, and ... Presto Chango! ... you get a map, a route, times between locations, recommended beers, food pairings, proper glassware and serving temperature suggestions, ... (ok, getting carried away here)

It is likely that I will never be able to add direction functionality directly into beermapping's maps. Google is not releasing that information as far as I know. And I wouldn't begin to tell you how hard or costly it would be for me to figure out how to get directional information to work inside beermapping's maps.

Also, I'm wondering when the features will be added to actually show a route map with directions. Enter starting location (brewery, pub, ...), ending location, and perhaps radius or a list of places to include, specify walking / driving / public transportation, press enter, and ... Presto Chango! ... you get a map, a route, times between locations, recommended beers, food pairings, proper glassware and serving temperature suggestions, ... (ok, getting carried away here)

It is likely that I will never be able to add direction functionality directly into beermapping's maps. Google is not releasing that information as far as I know. And I wouldn't begin to tell you how hard or costly it would be for me to figure out how to get directional information to work inside beermapping's maps.

Find me a few million dollars and I'll look into it.

Google is not releasing it yet, but their verbiage kinda sounded like they might in the future. I'd like an API that would just give me travel time between two locations.The direction I'm going with http://AtlantaBeer.com/ is to try and put together beer tours with direction information between each of the stops. I've kinda got this going by having a manual preplanned itinerary and then linking to Google's page for the actual routing. The Carolina set is the most complete example right now (since it was the last big trip that I made and I'm doing these for myself as I take trips).

By the way, I have capped the "proximity search" at 75 miles (this only really applies to anyone who might have been playing around with the url string). I don't want someone entering in 1,000,000 miles and ending up with a list of every single location in the database on that page.

The distance calculation also works for decimal numbers as well, so for locations that are in highly metropolitan areas, you might want to do a .5 or .75 distance radius.

I believe, that the direction I am planning to take with this is to give users two options. One would be to find a location on either the map or through the search and give them the ability to search for locations within a certain radius. The results would be able to be shown in a map or printed in a fairly clean results page.

The other option will be for the user to be able to enter a new location that will not be stored in the database. This new location will act as the center of the radius and it can be a location of any type (hotel, house, street corner...) as long as it is a mappable address. So you could enter in the address of the hotel that you are planning to stay at in San Diego and that location will act as the center of your search radius. Hopefully this should prove useful for travelers.

Ok, this feature is still in "live beta" simply because I suck really bad at testing.

The mapping functions are active at this point. There is a link on the proximity page that will allow you to "map" the locations that are listed there. Here is an example, using The Map Room at a one mile radius;

When you click that link, you will get a "custom map" that has the same radius as the search/proxy page. The radius that was chosen is drawn in a circle around the center point. This helps to show a user exactly the distance between the center and the outer edge of the circle.

Here again is an example using The Map Room at a one mile radius (click the example image to jump to the actual map);

Hopefully someone will find this useful. I'm pretty sure that whenever I set it up so you can choose a custom center point it will become even more useful.

I think I have most of the bugs worked out on these maps at the moment.

Internet Explorer 7 (and possibly IE6) was broken for a while, but it is fixed at the moment. The "bookmarking options" were broken for a while, but they are fixed at the moment. Otherwise I think I have tested most everything (I'm sure I neglected something...) and it all seems to be working.