Hack 23. Find a Place to Live

Why slog through endless listings of apartments that all look the same, when you can pick and choose based on where you actually want to live?

Finding a place to live, particularly in large cities, can be a huge pain. Locating a place at a price you can afford is enough of a challenge, but, even when you can locate such places, they're often not situated where you actually want to live. Real estate and rental listing sites like Craigslist.org go a long way towards easing this pain by offering searches against listings based on keywords and price brackets, but often even the search results themselves are still daunting. Where the heck are all these places? How close are each of these apartments to the grocery store? To public transit? To my friends' houses? The listings often include neighborhood names, or even street addresses or nearby intersections, but if you're not particularly familiar with the area, these names might not mean anything to you.

Paul Rademacher's HousingMaps site offers an inventive start on a solution to this problem: take one part Craigslist.org real estate listings, one part Google Maps API, and stir!

3.8.1. What to Do?

The front page of HousingMaps, which you can find at http://housingmaps.com/, shows a Google Maps view of the United States and Canada, as seen in Figure 3-13. The green icons on the map mark many of the major urban areas served by Craigslist, and clicking one opens a call-out, from which you can select real estate for sale, rentals, rooms for rent, and sublets or temporary housing for that city.

If you find this view a bit confusingor find the icons hard to click, as in the northeastern United States, where the icons are bunched a bit close togetherthen you can select the metropolitan area of your choice from the drop-down box at the top left, and then use the links above to narrow your search. (Alternatively, you can recenter with a mouse drag or double-click, and then zoom in! This is Google Maps, after all.) Finally, another drop-down box at the top allows you to indicate price ranges of properties to show on the map.

Figure 3-13. Why live anywhere when you could live, er, anywhere?

After selecting a type of listing for a given city, you're taken to a view of the available properties of that type in that city. Since I've been looking for a cheap short-term sublet in north Brooklyn, I select sublets in New York City, and then use the zoom and pan controls to focus in on that area. Yellow icons identify listings with photos, while red icons identify those without. I started by clicking one of the yellow icons on the map, as shown in Figure 3-14.A Google Maps info window pops up, showing the details of the property, including contact details and any photos.

Figure 3-14. A search for rentals in north Brooklyn using HousingMaps

A list of identifiable properties for that city and type is shown on the right side, sorted by price. Clicking on one of the icons recenters the map on that property and opens its call-out, while clicking on the adjacent link takes you directly to that entry in Craigslist. Additionally, you can apply the same filters to your search that Craigslist offers, such as keywords, pets permitted, and the presence of photos in a listing. Finally, there's a "permalink" option that allows you to bookmark a particular search for future use once you've zeroed in on the part of town and the search filters you're interested in. Does this beat paging through mind-numbing lists of rentals that all look the same or what?

3.8.2. How It Works

How does this miracle of modern technology function? Part of the answer lies in the RSS feeds offered by Craigslist for each category they provide. The Brooklyn sublets, for example, are listed at http://newyork.craigslist.org/brk/sub/. At the bottom of the page, there's a link labelled RSS, which points to http://newyork.craigslist.org/brk/sub/index.rss. This file contains an XML document that provides a machine-readable version of the 15 most recent listings for that category. Here's a snippet:

***Bedroom Avail in Apt with Garden- Aug Sublet*** (Williamsburg) $650 3bdhttp://newyork.craigslist.org/brk/sub/87294481.html Copyright 2005, craigslist.org en-us 2005-07-27T14:52:39-04:00 text

The main thing to note, of course, is the URL in the

element. That HTML page is the rental listing itself and, buried within it, are a few choice bits of HTML comments that Craigslist puts in every page:

These comment tags, of course, contain enough information to plot the approximate location of the rental on a map! We'll show how to do this for U.S. street addresses with Geocoder.us in "Find the Latitude and Longitude of a Street Address" [Hack #62]. The practical upshot is that, on the server side, the HousingMaps web site periodically spiders the Craigslist RSS feeds, finds new listings, and scrapes the location data out of each one. (The downside is that if there isn't any location information in the listing, it's awfully difficult to show it on the map!)

Finally, the site produces its own data file containing the listing information, links to photos, and, of course, the location data, which is then fed into the Google Maps interface in your web browser to produce the lovely maps you see before you, using XMLHttpRequest. Of course, now that Google has released a proper API for Google Maps, there are easy ways to do this yourself, as we'll also see later on in the book.

3.8.3. See Also

Категории