Bing Search API Test
An example of the Bing Search PI Phonebook SearchType.
Requested 25 results. Getting 10.
HTML
<script src="http://maps.google.com/maps/api/js?sensor=false&.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<div id="map"></div>
CSS
#map{
width: 400px;
height: 500px;
}
JavaScript
var centre = new google.maps.LatLng(51.672738, -4.703579);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: centre,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow({
content: "holding..."
});
var markers = [];
function GetModel (query, location, radius) {
alert(query + "," + location + "," + radius);
var model = {
"AppId": "AIzaSyA5KP9qS6gJTgQWaso9XOJtiMUgHDPMoZY",
"Query": query,
"Sources": "Phonebook",
"Version": "2.0",
"Market": "en-gb",
"UILanguage": "en",
"Latitude": location.lat(),
"Longitude": location.lng(),
"Radius": radius,
"Phonebook.Count": 20,
"Phonebook.Offset": 0,
"Phonebook.SortBy": "Distance",
"JsonType": "callback"
};
return model;
}
function GetPlaces (map, query) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode
(
{ 'address': 'Plymouth MN'}
,
function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
alert("location : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.lng());
}
else
{
alert("Something got wrong " + status);
}
var radiusCenter = new google.maps.LatLng(results[0].geometry.location.lat(),results[0].geometry.location.lng());
alert("radiusCenter ~> " + radiusCenter);
var url = "http://api.bing.net/json.aspx?JsonCallback=?";
var model = GetModel(query, radiusCenter, 100);
console.log(model);
$.ajax({
traditional: true,
type: 'GET',
url: url,
data: model,
context: self,
dataType: "jsonp",
contentType: 'application/json',
success: GetPlacesSuccess,
error: GetPlacesError
});
}
);
}
function...