Articles: 843 | Categories: 148   
   
   
Home Articles Contact Us
 
 
 
 
Adding a Google Map to a Tab or Window (0 Comments)
Admin: Posted Date: April 4, 2010

 The window and Tab need to be rendered before you can gain access to the body.dom element, for this I just tag a show() in the end when they are being created.

Adding a Google Map to a Tab or Window

Getting Started

The window and Tab need to be rendered before you can gain access to the body.dom element, for this I just tag a show() in the end when they are being created.

 

Tabs

  1. var tabs = new Ext.TabPanel({  
  2.     renderTo: 'tabs',  
  3.     width:450,  
  4.     height: 300,  
  5.     frame:true  
  6. });  
  7. var tab1 = tabs.add({id: 'gmap',title: 'Map Tab',html: 'map',tbar: [  
  8.     'Address',  
  9.     addr_field = new Ext.form.TextField({  
  10.         width:200,  
  11.         qtip:'Example: 123 Fake Street, Baltimore, MD, 21211, US'  
  12.     })  
  13. ]}).show();  
  14. var tab2 = tabs.add({title: 'Some Other Tab'});  
  15. map = new GMap2(tab1.body.dom);  
var tabs = new Ext.TabPanel({ renderTo: 'tabs', width:450, height: 300, frame:true }); var tab1 = tabs.add({id: 'gmap',title: 'Map Tab',html: 'map',tbar: [ 'Address', addr_field = new Ext.form.TextField({ width:200, qtip:'Example: 123 Fake Street, Baltimore, MD, 21211, US' }) ]}).show(); var tab2 = tabs.add({title: 'Some Other Tab'}); map = new GMap2(tab1.body.dom);

Windows

  1. dialog = new Ext.Window({  
  2.     title: 'Google Map in a Window',  
  3.     width:535,  
  4.     height:500,  
  5.     shadow:true,  
  6.     closeAction: 'hide',  
  7.     buttons: [  
  8.         {  
  9.             text:'Map Address',  
  10.             handler: function(){ Map.addressPrompt(); }  
  11.         },  
  12.         {  
  13.             text:'Close',  
  14.             handler: function(){ dialog.hide(); }  
  15.         }  
  16.     ]  
  17. }).show();  
  18. map = new GMap2(dialog.body.dom);  
dialog = new Ext.Window({ title: 'Google Map in a Window', width:535, height:500, shadow:true, closeAction: 'hide', buttons: [ { text:'Map Address', handler: function(){ Map.addressPrompt(); } }, { text:'Close', handler: function(){ dialog.hide(); } } ] }).show(); map = new GMap2(dialog.body.dom);

The last line of each of these sniplets is the important part, it gives the Google Maps API access to the proper DOM element. Its just that simple, and when I figured it out, I was kicking myself.

 

 
 
Add a Comment:
 
(You must be signed in to comment on an article. Not a member? Click here to register)
   
Title:

Comments: