Get business type/industry from Bing Phonebook API
The below example shows how I'm building the query string that will return a bunch of addresses for the search parameters defined in the query string (in this case, Starbuck's)...I'm wondering if it's possible to use the Bing Phonebook API to define a type of entity that you're looking for e.g. Cafe, Gas Station, Software Company, etc...?
function Search(position) {
// note a bunch of this code uses the example code from
// Microsoft for the Phonebook API
var requestStr = "http://api.bing.net/json.aspx?"
// Common request fields (required)
+ "AppId=" + _appId
+ "&Query=starbucks开发者_Python百科"
+ "&Sources=Phonebook"
// Common request fields (optional)
+ "&Version=2.2"
+ "&Market=en-us"
+ "&UILanguage=en"
+ "&Latitude=" + position.coords.latitude
+ "&Longitude=" + position.coords.longitude
+ "&Radius=100.0"
+ "&Options=EnableHighlighting"
// Phonebook-specific request fields (optional)
// Phonebook.Count max val is 25
+ "&Phonebook.Count=25"
+ "&Phonebook.Offset=0"
// YP = Commercial Entity, WP = Residential
+ "&Phonebook.FileType=YP"
+ "&Phonebook.SortBy=Distance"
// JSON-specific request fields (optional)
+ "&JsonType=callback"
+ "&JsonCallback=?";
$.getJSON(requestStr, function (data) {
SearchCompleted(data);
});
}
I'm not 100% sure, but I don't think the API has a category option. However, I think if you simply included the category in the search query, you would get better results. It's essentially a standard google(bing in this case, obviously) search so you can have it search for any number of terms.
So to find starbucks and define that it should be coffee:
"&Query=starbucks coffee"
Another tip: Unless distance is absolutely important, use:
SortBy=Relevance
This seems to help reduce dumb results
I have confirmed the above answer is right, but I wanted to add that you can sort on both the relevance and the distance
精彩评论