* 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
});
};
initial: function()
{
+ if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
+ this.fireEvent('loadexception', this);
+ return;
+ }
+
if(!this.mapTypeId){
this.mapTypeId = google.maps.MapTypeId.ROADMAP;
}
this.gMapContext = this.GMapContext();
-// this.initOverlayView();
-//
-// this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
-//
-// var _this = this;
-//
-// google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
-// _this.setPosition(_this.gMapContext.marker.position);
-// });
-//
-// google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
-// _this.fireEvent('mapClick', this, event);
-//
-// });
-//
-// google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
-// _this.fireEvent('mapRightClick', this, event);
-//
-// });
-//
-// google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
-// _this.fireEvent('markerClick', this, event);
-//
-// });
-//
-// google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
-// _this.fireEvent('markerRightClick', this, event);
-//
-// });
-//
+ this.initOverlayView();
+
+ this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
+
+ var _this = this;
+
+ google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
+ _this.setPosition(_this.gMapContext.marker.position);
+ });
+
+ google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
+ _this.fireEvent('mapClick', this, event);
+
+ });
+
+ google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
+ _this.fireEvent('mapRightClick', this, event);
+
+ });
+
+ google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
+ _this.fireEvent('markerClick', this, event);
+
+ });
+
+ google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
+ _this.fireEvent('markerRightClick', this, event);
+
+ });
+
this.setPosition(this.gMapContext.location);
-//
-// this.fireEvent('initial', this, this.gMapContext.location);
+
+ this.fireEvent('initial', this, this.gMapContext.location);
},
initOverlayView: function()
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
});
- Roo.log(_marker);
+
return {
map: _map,
marker: _marker,
circle: null,
- location: _marker.position,
+ location: position,
radius: this.radius,
locationName: this.locationName,
addressComponents: {