2011-02-04 4 views
4

Bing Maps 7.0 API를 지연로드와 함께 사용하려고합니다.이 기능은 onScriptLoad 매개 변수로 지원되는 것 같습니다.왜 Bing Maps 7 AJAX 컨트롤은 게으른로드가 아닙니까?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title>Bing Maps Test</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
</head> 
<body> 
    <div id='mapDiv' style="position:absolute; width:600px; height:400px;"></div> 
    <script type="text/javascript"> 

     function initMap() { 
      console.log('Callback called'); 
      var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials:"<API KEY>"}); 
     } 

     function loadMapControl() 
     { 
      var script = document.createElement("script"); 
      script.setAttribute("src", "http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&onScriptLoad=initMap"); 
      script.setAttribute("type", "text/javascript"); 
      document.documentElement.firstChild.appendChild(script); 
      console.log('Tag appened'); 
     } 
     setTimeout(loadMapControl, 1000); 

    </script> 
</body> 
</html> 

콜백이 예상대로라고하지만, 방화범이 나에게 Microsoft.Maps.Map is not a constructor 오류가 발생한다 :이 최소한의 테스트 케이스를 사용했다. 이것은 콜백이 setTimeout을 통해 호출 된 후 맵 생성을 10 초 지연시킨다.

빙 문서의 간단한 예를

하지만, 완벽하게 작동된다

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title>Bing Maps Test</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script> 
</head> 
<body> 
    <div id='mapDiv' style="position:absolute; width:600px; height:400px;"></div> 
    <script type="text/javascript"> 
     var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials:",API KEY>"}); 
    </script> 
</body> 
</html> 

은 아무도 지연로드와 함께 작동하도록 API 7.0을 얻는 데 성공 했습니까?

감사합니다.

답변

0

참고로이 문제는 Maps API의 최신 릴리스에서 최종적으로 수정되었습니다. 이 새 버전에서는 모든 것이 예상대로 작동합니다.

+0

위대한 : 이제 그들은 다른 기능을 다시 추가 할 수만 있다면 마침내 고객 프로젝트에서도 6.3을 제거 할 수있었습니다. – wildpeaks

관련 문제