Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / examples / ux / GMapPanel.js
index 788fd9e..04b5e71 100644 (file)
@@ -1,15 +1,29 @@
-/*!
- * Ext JS Library 3.3.0
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 /**
  * @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 +38,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 +67,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 +89,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 +104,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 +134,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 +147,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 +160,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 +182,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 +201,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{
@@ -212,4 +230,3 @@ Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
  
 });
 
-Ext.reg('gmappanel', Ext.ux.GMapPanel); 
\ No newline at end of file