Google ストリート ビューをレンダリングする次のバックボーン ビューで問題が発生しています。
問題は、processSVData 関数でthis
が のインスタンスではないことですApp.DetailStreetView
。中にconsole.log(this)
入るprocessSVData()
と、DOMWindow
オブジェクトを取得します。したがって、アクセスしようとするthis.panorama
と、undefined
App.DetailStreetView = Backbone.View.extend({
initialize: function() {
this.latLng = new google.maps.LatLng(37.869085,-122.254775);
this.panorama = new google.maps.StreetViewPanorama(this.el);
},
render: function() {
var sv = new google.maps.StreetViewService();
sv.getPanoramaByLocation(this.latLng, 50, this.processSVData);
},
processSVData: function(data, status) {
if (status == google.maps.StreetViewStatus.OK) {
// calculate correct heading for POV
//var heading = google.maps.geometry.spherical.computeHeading(data.location.latLng, this.latLng);
this.panorama.setPano(data.location.pano);
this.panorama.setPov({
heading: 270,
pitch:0,
zoom:1,
});
this.panorama.setVisible(true);
}
},
});