百度地图JavaScript API /static/images/transparent.gif 404

我在使用百度地图计算驾车距离的时候,用2个点的名称的方式,就时灵时不灵,不灵的时候,会有一个很奇怪的请求,这个请求是基于你调用百度地图的域的,哪怕在lbs开放平台上也一样,比如在本地就是http://localhost:4000/static/images/transparent.gif

例如:

计算驾车时间与距离这一块,在本地的时候,就时灵时不灵。

var map = new BMap.Map("allmap");
	map.centerAndZoom(new BMap.Point(116.404, 39.915), 12);
	var output = "从上地到西单驾车需要";
	var searchComplete = function (results){
		if (transit.getStatus() != BMAP_STATUS_SUCCESS){
			return ;
		}
		var plan = results.getPlan(0);
		output += plan.getDuration(true) + "\n";                //获取时间
		output += "总路程为:" ;
		output += plan.getDistance(true) + "\n";             //获取距离
	}
	var transit = new BMap.DrivingRoute(map, {renderOptions: {map: map},
		onSearchComplete: searchComplete,
		onPolylinesSet: function(){        
			setTimeout(function(){alert(output)},"1000");
	}});
	transit.search("上地", "西单");

后来我查了一下,没找到解决方法。

这个问题我的解决方法是:

var map = new BMap.Map("allmap");
	map.centerAndZoom(new BMap.Point(116.404, 39.915), 12);
	var output = "从上地到西单驾车需要";
	var searchComplete = function (results){
		if (transit.getStatus() != BMAP_STATUS_SUCCESS){
			return ;
		}
		var plan = results.getPlan(0);
		output += plan.getDuration(true) + "\n";                //获取时间
		output += "总路程为:" ;
		output += plan.getDistance(true) + "\n";             //获取距离
	}
	var transit = new BMap.DrivingRoute(map, {renderOptions: {map: map},
		onSearchComplete: searchComplete,
		onPolylinesSet: function(){        
			setTimeout(function(){alert(output)},"1000");
	}});
        var p1 = new BMap.Point(116.301934,39.977552);
        var p2 = new BMap.Point(116.508328,39.919141);
	transit.search(p1,p2); // 将地址名变成了经纬度

相关推荐