Я использую автозаполнение для двух текстовых полей. Это прекрасно работает с использованием этого кода:Bing-карты получают геолокацию между двумя местами сбоями
$('[id$=PlaceOfDeparture]:not(.ui-autocomplete-input), [id$=PlaceOfArrival]:not(.ui-autocomplete-input)').live('focus', function() {
$(this).autocomplete({
source: function (request, response) {
$.ajax({
url: "http://dev.virtualearth.net/REST/v1/Locations",
dataType: "jsonp",
data: {
key: 'mykey',
q: request.term
},
jsonp: "jsonp",
success: function (data) {
var result = data.resourceSets[0];
if (result) {
if (result.estimatedTotal > 0) {
response($.map(result.resources, function(item) {
return {
data: item,
label: item.name + '(' + item.address.countryRegion+ ')',
value: item.name
};
}));
}
}
}
});
},
minLength: 1,
select: function (event, ui) {
$(this).val(ui.item.value);
travel = $(this).closest('div').parent();
$(this).change();
updateMap();
},
open: function() {
$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
},
close: function() {
$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
}
});
});
});
Это хорошо работает. Затем я хочу, чтобы карта bing рисовала линию между местоположениями на карте.
bingMap = new Microsoft.Maps.Map(document.getElementById("map_canvas"), {
credentials: "mykey",
mapTypeId: Microsoft.Maps.MapTypeId.auto,
enableSearchLogo: false,
enableClickableLogo: false,
showDashboard: false,
center: new Microsoft.Maps.Location(55.7, 13.1833333),
zoom: 10
});
Microsoft.Maps.loadModule("Microsoft.Maps.Directions", { callback: directionsModuleLoaded });
Я использую это, чтобы установить путевые точки к Бинг карте:
var startwaypoint = new Microsoft.Maps.Directions.Waypoint({ address: placeOfDeparture });
bingDirections.addWaypoint(startwaypoint);
// end
var endwaypoint = new Microsoft.Maps.Directions.Waypoint({ address: placeOfArrival });
bingDirections.addWaypoint(endwaypoint);
// Calculate directions, which displays a route on the map
bingDirections.calculateDirections();
Первые два ajaxpost прекрасно работает и дает мне «StatusCode»: 200, который я прочитал должен быть хорошим :) Но тогда, когда я делаю bingDirections.calculateDirections(); он возвращает это:
microsoftMapsNetworkCallback ({"resolvedWaypoints": [["failed": true, "invalidCredentials": false, "inputType": 0, "широта": 0, "longitude": 0, "rooftopLatitude ": 0," rooftopLongitude ": 0," адрес ": нулевой," неоднозначность ": нулевая," locationIdentifier ": нулевая}, {" не ": правда," invalidCredentials "ложь" inputType ": 0," широта ": 0," longitude ": 0," rooftopLatitude ": 0," rooftopLongitude ": 0," address ": null," disamiguation ": null," locationIdentifier ": null}]]}, 'd6392');