我正在升级项目从使用bing地图v7 ajax api到使用v8 api。我遇到了一个问题,我收到一条消息,指出“您输入的航点无法找到。”所以我备份并修改了一个示例屏幕来做我正在做的事情,并且它工作正常。所以我把它缩小了(用小提琴)到REST调用,这是为每个航点提供的错误,说第一种情况userMapView超出范围,但在第二种情况下正常工作。我不确定为什么这可能会在示例代码与我的实际应用程序中有所不同。以下是两个网址。第一个是失败的一个:bing地图从v7升级到v8错误与userMapView
如果我更换与第二的第一URL的参数userMapView,第一URL也工作。似乎很明显,“-180”度的部分是不正确的,但我不知道它是如何到达那里的。
顺便说一句,这两个URL都是使用我的开发密钥生成的。
感谢您的帮助!
编辑: 这是大量的代码遇到麻烦。在此之前,我已经新建了地图。此代码是来自Directions模块的loadModule的回调。这个代码稍微有点复杂,但我从表单中插入了起源和目的地。还要注意,并不是说它有很大的区别,userAddress被传递给这个函数为true。
function createDrivingRoute(useAddress) {
directionsManager = new Microsoft.Maps.Directions.DirectionsManager(bmap);
locs = [];
var fromWayPoint;
fromWayPoint = new Microsoft.Maps.Directions.Waypoint({ address: fromAddressSearch });
locs.push(fromWayPoint);
directionsManager.addWaypoint(fromWayPoint);
if (toLocationArray != null) {
if (toLocationArray.length == 1) {
if (toLocationArray[0] == false) {
toLocationArray = [];
}
}
}
if (useAddress) {
if (toLocationArray != null) {
for (i = 0; i < toLocationArray.length; i++) {
//var toWayPointLoc = new Microsoft.Maps.Directions.Waypoint({ location: toLocationArray[i] });
var toWayPointLoc = new Microsoft.Maps.Directions.Waypoint({ address: toLocationArray[i] });
locs.push(toWayPointLoc);
directionsManager.addWaypoint(toWayPointLoc);
}
for (i = 0; i < toAddressArray.length; i++) {
var toWayPoint = new Microsoft.Maps.Directions.Waypoint({ address: toAddressArray[i] });
locs.push(toWayPoint);
directionsManager.addWaypoint(toWayPoint);
}
} else {
for (i = 0; i < toAddressArray.length; i++) {
var toWayPoint = new Microsoft.Maps.Directions.Waypoint({ address: toAddressArray[i] });
locs.push(toWayPoint);
directionsManager.addWaypoint(toWayPoint);
}
}
} else {
if (toLocationArray != null) {
for (i = 0; i < toLocationArray.length; i++) {
//var toWayPointLoc = new Microsoft.Maps.Directions.Waypoint({ location: toLocationArray[i] });
var toWayPointLoc = new Microsoft.Maps.Directions.Waypoint({ address: toLocationArray[i] });
locs.push(toWayPointLoc);
directionsManager.addWaypoint(toWayPointLoc);
}
}
for (i = 0; i < toAddressArray.length; i++) {
var toWayPoint = new Microsoft.Maps.Directions.Waypoint({ address: toAddressArray[i] });
locs.push(toWayPoint);
directionsManager.addWaypoint(toWayPoint);
}
}
if ($get("<%= chkReturnOrigin.ClientID %>").checked) {
var returnWayPoint = new Microsoft.Maps.Directions.Waypoint({ address: fromAddressSearch });
directionsManager.addWaypoint(fromWayPoint);
}
// Set the element in which the itinerary will be rendered
directionsManager.setRenderOptions({ itineraryContainer: '#directions' });
// Specify a handler for when the directions are calculated
if (directionsUpdatedEventObj) {
Microsoft.Maps.Events.removeHandler(directionsUpdatedEventObj);
directionsUpdatedEventObj = null;
}
directionsUpdatedEventObj = Microsoft.Maps.Events.addHandler(directionsManager, 'directionsUpdated', onDirectionsDisplayedEvent);
if (directionsErrorEventObj) {
Microsoft.Maps.Events.removeHandler(directionsErrorEventObj);
directionsErrorEventObj = null;
}
directionsErrorEventObj = Microsoft.Maps.Events.addHandler(directionsManager, 'directionsError', onDirectionsErrorEvent);
loadedRoute = null;
loadedSteps = [];
directionsManager.calculateDirections();
var destAddress = $get("<%= DestAddressList.ClientID %>").value;
if (destAddress == null || destAddress == "") {
document.getElementById("DistTotal").innerHTML = '';
}
}
我很感谢您看一看。我将编辑我的问题以添加正在完成此工作的代码的主要部分。我没有使用搜索,但我没有对LocationRect做任何事情。我基本上只是用DirectionsManager添加航点和计算方向。 –
感谢您对此进行研究。你能想一想我能做些什么来解决这个问题吗? –
我相信当请求中有-180时,REST服务会失败。计算方向时尽量让地图放大一点。这应该会导致正在使用的较小的边界框不包含-180。 – rbrundritt