Before Christmas we pushed the new Search Service out to Beta and then expanded its features in subsequent pushes. At this point, it's pretty much fully baked, and more than complete enough to deserve some blogging. It's taken me a while to pull this post together, mainly because every time I tried to write about the new search service, I was defeated by the amount of functionality, options, and flexibility it possesses. It's not a simple "gimme Pizza in Denver" search (although it can be) - it's a lot more hardcore than that. It's a Spatial Search Service, which allows you to search against different data sets by defining the geographic area within which you want results found.
While the service is easy to implement, it is highly functional and has many capabilities, so please bear with me as I try to explain just some of the things it can do. To make it simple I'm going to break this down into three separate posts: Ways you can search (this post); what data you can search against; and miscellaneous cool stuff it can do.
Ways you can search:
- Radius Search
- This is the most basic search. Give us a point and how far around it you want to search, and we'll return results ordered by their distance from the center. You can tell us the center-point of your search by providing a latitude/longitude, a street address, or an IP address. In fact, if you don't give us a center-point, we'll default to your IP address. See how easy that was? From here, you simply tell us the radius and the units. 10 kilometres? No problem! Half-an-hour driving time? Yes, we can do that too!
- Rectangle Search
- If you give us two points (again, Lat/Lngs, street addresses, IP addresses, or any combination of the three), we'll make a rectangle out of them and search within that box. This is a great way to do a map-based search; Just pass the map bounds every time your user pans or zooms the map, and re-query for updated search results.
- Polygon Search
- Sometimes you need more than just a radius or a bounding box. A lot of companies have custom defined sales territories; or maybe you sell franchise with Areas of Protection, and need to make sure a new franchise territory wouldn't include any previously sold franchises. You can define the polygon by handing us a collection of lat/lng pairs in several different formats: a raw comma-separated set of of pairs, an encoded compressed string, or an OGC standard Simple Feature.
- Corridor Search
- The most obvious use of Corridor Search is to find places along a route (such as gas stations or hotels). You provide the line shape and how wide you want the line to be and we supply the results. For example, if you set a width of "5" and a units of "k" (kilometres) then we'll search for 2.5 km on each side of the line (a total width of 5 km). Corridor Search supports the same line input types as the polygon search does. If you have previously created a route using the Directions Service you can also use the sessionID from that route, instead of providing us the line shape.
- Base or Default Search
- Finally, there is just a base
search?function that sits on top of all the others. Pass us the parameters of your search, and we'll figure out what kind of search you are trying to do. Give us a point and a radius, we'll do a radius search; Give us two points, we'll do a rectangle; Give us a series of points, we'll do a corridor. If the first and last points are the same, then we'll do a polygon search instead. In fact, if you give us absolutely nothing at all, we'll do a 20 mile radius search around your IP address against our default data-set.
Radius search results on a map.
Rectangle search results on a map.
Polygon search results on a map.
Corridor search results on a map.
And that's just part 1! Hopefully you can see how these new capabilities can help you. More details are, as always, available on our Developer Network Beta Release page.
If you haven't tried any of our new services and SDKs in Beta yet, you can sign up for an appKey here.
Stay tuned...more to follow soon.