/*
 * Ext JS Library 2.2.1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://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:500,
                height:400,
                x: 140,
                y: 280,
                items: {
                    xtype: 'gmappanel',
                    region: 'center',
                    zoomLevel: 7,
                    gmapType: 'map',
                    mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
                    mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
                    setCenter: {
                        geoCodeAddr: 'jankowska 6, pakość, Polska',
                        marker: {title: 'Sanitrans Pakość, ul. Jankowska 6'}
                    },
                    markers: [{
                        lat: 53.09951288958879,
                        lng: 17.912650108337402,
                        marker: {title: 'Sanitrans Białe Błota, ul. Barycka 50'},
                        listeners: {
                            click: function(e){
                                Ext.Msg.alert('Sanitrans', 'Białe Błota, ul. Barycka 50');
                            }
                        }
                    },{
                        lat: 52.80068577135523,
                        lng: 18.08471918106079,
                        marker: {title: 'Sanitrans Pakość, ul. Jankowska 6'}
                    }]
                }
            });
            
        }
        
        mapwin.show();
        
    });
    
 });
