1
我正在为My CRM项目创建解决方案(Web资源)。为此,我使用Bing API在java脚本中编写了地图优化代码。Java脚本未调用函数
retrieveAccountsCallBack
正在从CRM中检索地址。然后我使用这些地址找到他们的地理代码。 问题是当代码到达点map.getCredentials(MakeGeocodeRequest)
时,它不会进入定义的map.getCredentials(MakeGeocodeRequest)
函数。它只是像它的注释那样通过这条线。但是有些时候它的作用是扭曲的,但没有明确的模式。
下面是代码:
function retrieveAccountsCallBack(retrievedAccounts) {
totalAccountCount = totalAccountCount + retrievedAccounts.length;
for (var i = 0; i < retrievedAccounts.length; i++) {
var account = retrievedAccounts[i];
//retLoc.push(account.new_address);
waypoint = retrievedAccounts[i].new_address;
map.getCredentials(MakeGeocodeRequest);
///////////////////////////////////////////
}
}
代码MakeGeocodeRequest()
function MakeGeocodeRequest(cred) {
var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations?query=" + encodeURI(waypoint) + "&output=json&jsonp=GeocodeCallback&key=" + cred;
CallRestService(geocodeRequest);
}
您需要为您的'MakeGeocodeRequest'调用添加一个参数,否则它只是将函数本身传递给'map.getCredentials()'。 – Phylogenesis 2015-01-21 09:07:57