0

I use autocomplete for two textboxes. That works fine using this code:

$('[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");
        }
    });
});

});

That works fine. Then i want bing map to draw a line between the locations on a map.

  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 });

I use this to set the waypoints to the bing map:

 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();

The first two ajaxpost works just fine and gives me the "statusCode":200 which i read is supposed to be good :) But then when i do the bingDirections.calculateDirections(); it returns this:

microsoftMapsNetworkCallback({"resolvedWaypoints":[[{"failed":true,"invalidCredentials":false,"inputType":0,"latitude":0,"longitude":0,"rooftopLatitude":0,"rooftopLongitude":0,"address":null,"disambiguation":null,"locationIdentifier":null},{"failed":true,"invalidCredentials":false,"inputType":0,"latitude":0,"longitude":0,"rooftopLatitude":0,"rooftopLongitude":0,"address":null,"disambiguation":null,"locationIdentifier":null}]]}, 'd6392');

Daniel Gustafsson
  • 1,725
  • 7
  • 37
  • 78

1 Answers1

0

Check the response header. There might be a property called X-MS-BM-WS-INFO set to 1. This would indicate that your request was rate limited. If you make a lot of requests using a basic key (non-Enterprise/licensed account) and your account is generating transactions at a rate that will exceed the free terms of use your account is rate limited. This results in requests coming back empty. This is done to ensure that basic accounts don't affect the service for Enterprise users. Note that doing autocomplete is not within the terms of use and is likely the cause of the rate transactions being outside the free terms of use.

Also see this documentation: http://msdn.microsoft.com/en-us/library/ff701703.aspx

rbrundritt
  • 16,570
  • 2
  • 21
  • 46