sencha touch 2.4无法在控制器中获取视图" MVC方式与refrence"

时间:2015-05-11 04:57:58

标签: google-maps-api-3 sencha-touch-2 sencha-architect

我正在尝试使用Google Maps API创建一个小型应用程序。 首先,我开始使用名为2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:33.296 clicks[56755:5432421] ---End Move--- 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef1 2015-05-11 00:49:33.296 clicks[56755:5432421] ---End Move--- 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef2 2015-05-11 00:49:33.296 clicks[56755:5432421] ---End Move--- 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef1 2015-05-11 00:49:27.689 clicks[56755:5432421] f1 attack ef0 2015-05-11 00:49:33.296 clicks[56755:5432421] ---End Move--- 的导航视图;这是代码:

MainView

Secand,在控制器中Ext.define('MyApp.view.MainView', { extend: 'Ext.navigation.View', alias: 'widget.mainView', requires: [ 'Ext.navigation.Bar', 'Ext.Button', 'Ext.Panel', 'Ext.Map' ], config: { itemId: 'mynavigationview', navigationBar: { ....... layout: { ..... }, items: [ ...... ] }, items: [ { xtype: 'panel', title: 'Locations', itemId: 'mapPanel', items: [ { xtype: 'map', height: '100%', itemId: 'map' } ] } ] }}); 我制作了3个参考文件和1个控件mapController,以便使用库onMapInitialize将地图置于我的位置中心。这是代码:

ext.util.Geolocation

但是当我在导航器中测试应用程序时,此图像中的错误也出现了:Error image

我认为,实例Ext.define('MyApp.controller.mapController', { extend: 'Ext.app.Controller', alias: 'controller.mapcontroller', config: { refs: { mapView: { selector: 'mainView #map', xtype: 'Ext.Map' }, mainView: { selector: 'mainView', xtype: 'Ext.navigation.View' }, mapPanel: { selector: 'mainView #mapPanel', xtype: 'Ext.Panel' } }, control: { "map#map": { initialize: 'onMapInitialize' } } }, onMapInitialize: function(component, eOpts) { var map = this.getMapView(); var geo = Ext.create('Ext.util.Geolocation', { autoUpdate: false, listeners: { locationupdate: function(geo) { var currentLat = geo.getLatitude(); var currentLng = geo.getLongitude(); console.log('marking current location...'); var currentLocation = new google.maps.LatLng(currentLat,currentLng); map.setCenter(currentLocation); var marker = new google.maps.Marker({ animation: google.maps.Animation.DROP, map: map, position: currentLocation, title: 'My Current Location' }); var infoWindow = new google.maps.InfoWindow(); google.maps.event.addListener(marker, "click", function() { infoWindow.setContent('My current position'); infoWindow.open(this.getMap(), marker); }); }, locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) { if(bTimeout) Ext.Msg.alert('Timeout occurred',"Could not get current position"); else alert('Error occurred.'); } } }); geo.updateLocation(); }}); 可能不起作用或者说错误的引用。有人可以帮忙吗?

0 个答案:

没有答案