1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    11
    Vote Rating
    0
    tolbahady is on a distinguished road

      0  

    Default Google map object is null!

    Google map object is null!


    console.log(myMap.map) gives null, but
    console.log(myMap) gies an object with a map attribute which is the google map....

    Code:
    Band.views.SettingsLocation = Ext.extend(Ext.Panel,{
    	dockedItems:[{
    		xtype:'toolbar',
    		title:'Location',
    		items:[{
    			text:'Cancel',
    			xtype:'button',
    			ui:'back',
    			handler:function(){
    				Ext.dispatch({
    					controller:'settings',
    					action:'index'
    				});
    			}
    		},{xtype:'spacer'},{
    			text:'Done',
    			xtype:'button',
    			ui:'confirm'
    		}]
    	}],
    	layout:'fit',
    	initComponent: function() {
    	    this.position = new google.maps.LatLng(lat,lng);
    	
    	  	var myMap = new Ext.Map({
                mapOptions : {
                    enter : this.position,  //nearby San Fran
                    zoom : 12,
                    mapTypeId : google.maps.MapTypeId.ROADMAP,
                    navigationControl: true,
    			}
            });
    
    		this.marker = new google.maps.Marker({
    				map:myMap.map,
    				title:'Currrent Location',
    			    draggable:true,
    			    animation: google.maps.Animation.DROP,
    			    position: this.position
    		});
    		
    		console.log(myMap.map);
    		console.log(myMap);
    		
    		this.items = [myMap];
    		
    	    Band.views.SettingsLocation.superclass.initComponent.apply(this, arguments);
    	},
    });
    Ext.reg('settings-location', Band.views.SettingsLocation);

  2. #2
    Sencha User Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Vote Rating
    14
    Jacky Nguyen has a spectacular aura about Jacky Nguyen has a spectacular aura about

      0  

    Default


    Ext.Map#map is not guaranteed to be readily accessible at instantiation time since the rendering operation is synchronous. You should create a listener for the 'maprender' event and put your logics in there instead (create markers, etc.), i.e:

    Code:
    var myMap = new Ext.Map({
        mapOptions : {
            ...
        },
        listeners: {
            maprender: function() {
                 // this.map is ready here
            },
            scope: this
        },
    });
    Sencha Touch Lead Architect

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    11
    Vote Rating
    0
    tolbahady is on a distinguished road

      0  

    Default


    I got it working already, Thank you very much

Thread Participants: 1