여기에 설명 된 Bing Maps 라이브러리가 포함 된 Durandal/Hot Towel SPA를 사용하고 있습니다. http://soulsolutions.com.au/Blog/tabid/73/EntryId/818/Knockout-JS-and-Bing-Maps.aspx. 이 라이브러리는 맵 컨트롤에 액세스하기 위해 사용자 정의 ko 바인딩을 작성합니다.Durandal/Hot Towel SPA, Bing지도 및 녹아웃 맞춤 바인딩
듀란 달의 경우이 바인딩은 한 방향으로 만 작동합니다. 변경 후지도 컨트롤에서 값 (예 : 확대/축소 수준)을 가져 오는 것은 가능하지만 클릭 한 후에 확대/축소 수준을 설정하려는 경우 작동하지 않습니다.
Durandal 외부에서는 간단한 html 페이지에서 테스트했을 때 모든 것이 정상이었습니다.
어떤 아이디어가 잘못 되었나요? 어떤 도움이라도 대단히 감사하겠습니다.
내 뷰 모델 :
var mapVM = function() {
this.map = {
options: {
credentials: "bing key",
customizeOverlays: true,
showScalebar: false,
showMapTypeSelector: false,
enableClickableLogo: false,
enableSearchLogo: false,
},
mapview: {
zoom: ko.observable(4).extend({ throttle: 1 }),
},
};
this.testZoom = function() {
this.map.mapview.zoom(5);
};
};
보기 :
<input data-bind='value: map.mapview.zoom, valueUpdate: "afterkeydown"' />
<input type="button" data-bind="click: testZoom" value="test zoom" />
<div id="mapControl" data-bind="bingmaps: { map: map }" style="position: relative; width: auto; height: 400px">
나는이 "testZoom"함수 안에있는 값이 당신이 생각하는 것과 다르다고 생각한다. self라고 불리는 mapVM 내부에 변수를 생성하고이를 가리 키십시오. var self = this; this.testZoom 안에는 self.map.mapview.zoom (5)을 참조하십시오. 그게 작동하는지 알려 주시면 –
console.log를보고 오류가보고되는지 확인하십시오. –
@evan 로그가 비어 있습니다. – Damian