/*!
 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */

Ext.onReady(function(){

    var mapwin;
    var button = Ext.get('show-btn');

    button.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!mapwin){

            mapwin = new Ext.Window({
                layout: 'fit',
                title: 'GMap Window',
                closeAction: 'hide',
                width:400,
                height:400,
                x: 450,
                y: 180,
                items: {
                    xtype: 'gmappanel',
                    region: 'center',
                    zoomLevel: 14,
                    gmapType: 'map',
                    mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
                    mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
                    setCenter: {
                        geoCodeAddr: '2375 lewis avenue, Rockville, MD, 20851, USA',
                        marker: {title: 'Sly Horse Studio.\n 2375 lewis avenue, Rockville, MD, 20851'},
                        listeners: {
                            click: function(e){
                                Ext.Msg.alert('','Sly Horse Studio:  2375 lewis avenue, Rockville, MD, 20851');
                            }
                        }

                    },
                    markers: [{
                        lat: 39.062391,
                        lng: -77.120791,
                        marker: {title: 'Twinbrook Metro Station'},
                        listeners: {
                            click: function(e){
                                Ext.Msg.alert('','Twinbrook Metro Station');
                            }
                        }
                    },{
                        lat: 42.339419,
                        lng: -71.09077,
                        marker: {title: 'Northeastern University'}
                    }]
                }
            });
            
        }
        
        mapwin.show();
        
    });
    
 });