Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / ux / GMapPanel.js
index 18c1237..8a732a9 100644 (file)
@@ -1,15 +1,15 @@
-/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
 /**
  * @class Ext.ux.GMapPanel
  * @extends Ext.Panel
  * @author Shea Frederick
  */
-Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
+Ext.define('Ext.ux.GMapPanel', {
+    extend: 'Ext.Panel',
+    
+    alias: 'widget.gmappanel',
+    
+    requires: ['Ext.window.MessageBox'],
+    
     initComponent : function(){
         
         var defConfig = {
@@ -24,15 +24,17 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
         
         Ext.applyIf(this,defConfig);
         
-        Ext.ux.GMapPanel.superclass.initComponent.call(this);        
-
+        this.callParent();        
     },
+    
     afterRender : function(){
         
-        var wh = this.ownerCt.getSize();
+        var wh = this.ownerCt.getSize(),
+            point;
+            
         Ext.applyIf(this, wh);
         
-        Ext.ux.GMapPanel.superclass.afterRender.call(this);    
+        this.callParent();     
         
         if (this.gmapType === 'map'){
             this.gmap = new GMap2(this.body.dom);
@@ -51,7 +53,7 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
                 this.geoCodeLookup(this.setCenter.geoCodeAddr);
             }else{
                 if (this.gmapType === 'map'){
-                    var point = new GLatLng(this.setCenter.lat,this.setCenter.lng);
+                    point = new GLatLng(this.setCenter.lat,this.setCenter.lng);
                     this.gmap.setCenter(point, this.zoomLevel);    
                 }
                 if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
@@ -73,13 +75,13 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
         this.addMapControls();
         this.addOptions();  
     },
-    onResize : function(w, h){
+    afterComponentLayout : function(w, h){
 
         if (typeof this.getMap() == 'object') {
             this.gmap.checkResize();
         }
         
-        Ext.ux.GMapPanel.superclass.onResize.call(this, w, h);
+        this.callParent(arguments);
 
     },
     setSize : function(width, height, animate){
@@ -88,7 +90,7 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
             this.gmap.checkResize();
         }
         
-        Ext.ux.GMapPanel.superclass.setSize.call(this, width, height, animate);
+        this.callParent(arguments);
         
     },
     getMap : function(){
@@ -118,7 +120,7 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
         
     },
     addMarker : function(point, marker, clear, center, listeners){
-        
+        var evt;
         Ext.applyIf(marker,G_DEFAULT_ICON);
 
         if (clear === true){
@@ -131,6 +133,9 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
         var mark = new GMarker(point,marker);
         if (typeof listeners === 'object'){
             for (evt in listeners) {
+                if (!listeners.hasOwnProperty(evt)) {
+                    continue;
+                }
                 GEvent.bind(mark, evt, this, listeners[evt]);
             }
         }
@@ -141,7 +146,7 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
         
         if (this.gmapType === 'map') {
             if (Ext.isArray(this.mapControls)) {
-                for(i=0;i<this.mapControls.length;i++){
+                for(var i=0;i<this.mapControls.length;i++){
                     this.addMapControl(this.mapControls[i]);
                 }
             }else if(typeof this.mapControls === 'string'){
@@ -163,8 +168,7 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
     addOptions : function(){
         
         if (Ext.isArray(this.mapConfOpts)) {
-            var mc;
-            for(i=0;i<this.mapConfOpts.length;i++){
+            for(var i=0;i<this.mapConfOpts.length;i++){
                 this.addOption(this.mapConfOpts[i]);
             }
         }else if(typeof this.mapConfOpts === 'string'){
@@ -183,11 +187,11 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
     geoCodeLookup : function(addr) {
         
         this.geocoder = new GClientGeocoder();
-        this.geocoder.getLocations(addr, this.addAddressToMap.createDelegate(this));
+        this.geocoder.getLocations(addr, Ext.Function.bind(this.addAddressToMap, this));
         
     },
     addAddressToMap : function(response) {
-        
+        var place, addressinfo, accuracy, point;
         if (!response || response.Status.code != 200) {
             Ext.MessageBox.alert('Error', 'Code '+response.Status.code+' Error Returned');
         }else{
@@ -211,5 +215,3 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
     }
  
 });
-
-Ext.reg('gmappanel', Ext.ux.GMapPanel); 
\ No newline at end of file