2017-12-01 15 views
1

저는 js에별로 좋지는 않지만 웹 사이트에서 Bing지도를 사용하려하지만지도를 거의 보여주지 않으며 대부분지도를 표시하지 않습니다. 다음은로드 맵 함수의 코드는, 누군가가 나이 기능에 무슨 잘못 알려 주시기 바랍니다 수 있습니다, 나는 다른 응용 프로그램에서이를 사용하고 있습니다 :bing지도 창 크기를 조정 한 후에 만로드

function loadMap(storeData) { 
     var coordinates = {}; 
     var map; 
     var stores = storeData.stores; 
     if((typeof stores !== 'undefined') && (typeof stores[0].coordinates !== 'undefined')) { 
      coordinates.lat = stores[0].coordinates.lat; 
      coordinates.lng = stores[0].coordinates.lng; 
     }else { 
      coordinates.lat = 33.74831008911133; 
      coordinates.lng = -84.39111328125; 
     } 

     map = new Microsoft.Maps.Map($('#bingMap')[0], { 
      credentials: 'mykey', 
      liteMode: true, 
      enableClickableLogo: false, 
      center: new Microsoft.Maps.Location(coordinates.lat, coordinates.lng) 
     }); 

     self.center = new Microsoft.Maps.Location(coordinates.lat, coordinates.lng);   
     map.setView({zoom: 13}); 

     return map; 
     } 

나는 다른 유래 쿼리에서 가져온 몇 단계 만 아래 시도 이 문제는 당신 setTimeout 전화에

setTimeout(this.loadMap(storeData), 2000); Microsoft.Maps.Events.addHandler(map,'resize') 
+0

'에서는 setTimeout (this.loadMap.bind (이), 2000, storeData) ; ' – Sysix

+0

이 작업은되었지만 이제는 핀이 사라지고 있습니다.이 함수를 호출하는 순서가 잘못되었습니다. this.bingMap = this.loadMap (storeData); this.loadPins (this.bingMap, storeData, true); setTimeout (this.loadMap.bind (this), 2000, storeData); – Sam

답변

0

:-(도와 didnt는 :

: 당신이 볼

, setTimeout 2 개 매개 변수를 수신

  1. 함수당신은의 setTimeout로 기능하지만, 실행 결과를 전달하지 않습니다 setTimeout(this.loadMap(storeData), 2000);을 사용, 귀하의 경우 MS

  • 시간 제한을 실행합니다. 또한이 코드는 즉시 this.loadMap을 실행하며 2 초가 경과되지 않습니다.

    이 문제를 해결하기 위해, 당신은 사용할 수 있습니다

    setTimeout(function() { this.loadMap(storeData)}, 2000);

    나 : (Sysix의 솔루션 @) setTimeout(this.loadMap.bind(this), 2000, storeData);

  • +0

    이것은 효과가 있었지만 현재는 핀이 사라지고 있습니다.이 순서에서는이 함수를 호출하고 있습니다. 뭔가 잘못하고 있습니다. this.bingMap = this.loadMap (storeData); this.loadPins (this.bingMap, storeData, true); setTimeout (this.loadMap.bind (this), 2000, storeData); – Sam