fix docs
[roojs1] / Roo / bootstrap / LocationPicker.js
index 4537a00..0de0d63 100644 (file)
@@ -125,7 +125,13 @@ Roo.bootstrap.LocationPicker = function(config){
          * Fires when OverlayView Draw
          * @param {Roo.bootstrap.LocationPicker} this
          */
-        OverlayViewHide : true
+        OverlayViewHide : true,
+        /**
+         * @event loadexception
+         * Fires when load google lib failed.
+         * @param {Roo.bootstrap.LocationPicker} this
+         */
+        loadexception : true
     });
         
 };
@@ -173,6 +179,11 @@ Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component,  {
     
     initial: function()
     {
+        if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
+            this.fireEvent('loadexception', this);
+            return;
+        }
+        
         if(!this.mapTypeId){
             this.mapTypeId = google.maps.MapTypeId.ROADMAP;
         }
@@ -190,25 +201,21 @@ Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component,  {
         });
         
         google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
-            Roo.log('mapClick');
             _this.fireEvent('mapClick', this, event);
             
         });
 
         google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
-            Roo.log('mapRightClick');
             _this.fireEvent('mapRightClick', this, event);
             
         });
         
         google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
-            Roo.log('markerClick');
             _this.fireEvent('markerClick', this, event);
             
         });
 
         google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
-            Roo.log('markerRightClick');
             _this.fireEvent('markerRightClick', this, event);
             
         });
@@ -226,31 +233,26 @@ Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component,  {
             
             draw: function()
             {
-                Roo.log('OverlayView draw');
                 _this.fireEvent('OverlayViewDraw', _this);
             },
             
             onAdd: function()
             {
-                Roo.log('OverlayView onAdd');
                 _this.fireEvent('OverlayViewOnAdd', _this);
             },
             
             onRemove: function()
             {
-                Roo.log('OverlayView onRemove');
                 _this.fireEvent('OverlayViewOnRemove', _this);
             },
             
             show: function(cpx)
             {
-                Roo.log('OverlayView show');
                 _this.fireEvent('OverlayViewShow', _this, cpx);
             },
             
             hide: function()
             {
-                Roo.log('OverlayView hide');
                 _this.fireEvent('OverlayViewHide', _this);
             }
             
@@ -269,14 +271,29 @@ Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component,  {
     
     getGmapContext: function() 
     {
-        return this.gMapContext
+        return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
     },
     
     GMapContext: function() 
     {
-        var _map = new google.maps.Map(this.el.dom, this);
+        var position = new google.maps.LatLng(this.latitude, this.longitude);
+        
+        var _map = new google.maps.Map(this.el.dom, {
+            center: position,
+            zoom: this.zoom,
+            mapTypeId: this.mapTypeId,
+            mapTypeControl: this.mapTypeControl,
+            disableDoubleClickZoom: this.disableDoubleClickZoom,
+            scrollwheel: this.scrollwheel,
+            streetViewControl: this.streetViewControl,
+            locationName: this.locationName,
+            draggable: this.draggable,
+            enableAutocomplete: this.enableAutocomplete,
+            enableReverseGeocode: this.enableReverseGeocode
+        });
+        
         var _marker = new google.maps.Marker({
-            position: new google.maps.LatLng(this.latitude, this.longitude),
+            position: position,
             map: _map,
             title: this.markerTitle,
             draggable: this.draggable
@@ -286,7 +303,7 @@ Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component,  {
             map: _map,
             marker: _marker,
             circle: null,
-            location: _marker.position,
+            location: position,
             radius: this.radius,
             locationName: this.locationName,
             addressComponents: {