I'm trying to retrieve the value of the jsonso state object passed as a custom paramter into the Bing Maps REST Geo Location (http://dev.virtualearth.net/REST/v1/Locations/...). I can see the value returned as a second parameter in the response method call (Using network monitor), but can't seem to access it in code. Here's what the return method looks like (excerpted):
jsonp1301929429652({"authenticationResultCode":"ValidCredentials", ...more data... ,"traceId":"41a7523951964ae9a76ca4ea91c4e80f|CH1M001467|02.00.82.2800|CH1MSNVM001383"}, "My Custom Value")
I'm trying to pick it up in the anonymous method, like this:
$.getJSON(geocodeRequest, function (d, customParam) {
if (d != null && d.resourceSets.length > 0) {
var coordinates = d.resourceSets[0].resources[0].point.coordinates;
var loc = new Microsoft.Maps.Location(coordinates[0], coordinates[1]);
....
}
}
Unfortunately, the customParam is always undefined. How can I get that value?
Okay, here is a testable example:
$(function () {
var mapOptions = {
credentials: "Your API Key"
}
var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/US/Your State Abbrev/Your Zip/Your City/Your Street Address?jsonso=ABC123&jsonp=?&key=" + mapOptions.credentials;
$.getJSON(geocodeRequest, function (d, arg1, arg2, arg3) {
if (d != null && d.resourceSets.length > 0) {
var readMyCustomParam = arg1;
}
});
});
If you break on the first line inside the getJSON request you can monitor the traffic you will see the result of the request returns the jsonso parameter properly. My problem is then reading that in javascript. The whole purpose for this is to loop through a list of dealers, async geo locate, then use the returned identifier to lookup the dealer in the array to load it's description, etc for the pushpoint mouseover.