This control will create a Google map with drawring tools that allows the user to define a single point or a polygon which forms a geo-fence depending on the Rock.Web.UI.Controls.GeoPicker.ManagerDrawingMode.Point. To use on a page or usercontrol: ]]> To set an initial value: gpGeoPoint.SetValue( DbGeography.FromText("POINT(-122.335197 47.646711)") ); To access the value after it's been set use the SelectedValue property: DbGeography point = gpGeoPoint.SelectedValue; If you wish to set an appropriate, initial center point you can use the CenterPoint property.
Inheritance: System.Web.UI.WebControls.CompositeControl, IRockControl
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            Controls.Clear();

            // Mode Selection Panel and Controls
            _pnlModeSelection = new Panel {
                ID = "pnlModeSelection"
            };
            _pnlModeSelection.CssClass      = "picker-mode-options";
            _pnlModeSelection.ViewStateMode = ViewStateMode.Enabled;

            _hfCurrentPickerMode    = new HiddenField();
            _hfCurrentPickerMode.ID = this.ID + "_hfCurrentPickerMode";
            this.Controls.Add(_hfCurrentPickerMode);

            _radNamed = new RockRadioButton {
                ID = "radNamed"
            };
            _radNamed.Text      = "Location";
            _radNamed.GroupName = "radiogroup-location-mode_" + this.ClientID;
            _pnlModeSelection.Controls.Add(_radNamed);

            _radAddress = new RockRadioButton {
                ID = "radAddress"
            };
            _radAddress.Text      = "Address";
            _radAddress.GroupName = "radiogroup-location-mode_" + this.ClientID;
            _pnlModeSelection.Controls.Add(_radAddress);

            _radPoint = new RockRadioButton {
                ID = "radPoint"
            };
            _radPoint.Text      = "Point";
            _radPoint.GroupName = "radiogroup-location-mode_" + this.ClientID;
            _pnlModeSelection.Controls.Add(_radPoint);

            _radPolygon = new RockRadioButton {
                ID = "radPolygon"
            };
            _radPolygon.Text      = "Geo-fence";
            _radPolygon.GroupName = "radiogroup-location-mode_" + this.ClientID;
            _pnlModeSelection.Controls.Add(_radPolygon);

            _pickersPanel = new Panel {
                ID = "pickersPanel"
            };
            _pickersPanel.ViewStateMode = ViewStateMode.Disabled;
            this.Controls.Add(_pickersPanel);

            _namedPicker    = new LocationItemPicker();
            _namedPicker.ID = this.ID + "_namedPicker";

            _addressPicker    = new LocationAddressPicker();
            _addressPicker.ID = this.ID + "_addressPicker";
            _addressPicker.SelectGeography += _addressPicker_SelectGeography;

            _pointPicker                  = new GeoPicker();
            _pointPicker.ID               = this.ID + "_pointPicker";
            _pointPicker.DrawingMode      = GeoPicker.ManagerDrawingMode.Point;
            _pointPicker.SelectGeography += _pointPicker_SelectGeography;

            _polygonPicker                  = new GeoPicker();
            _polygonPicker.ID               = this.ID + "_polygonPicker";
            _polygonPicker.DrawingMode      = GeoPicker.ManagerDrawingMode.Polygon;
            _polygonPicker.SelectGeography += _polygonPicker_SelectGeography;

            _namedPicker.ModePanel   = _pnlModeSelection;
            _pointPicker.ModePanel   = _pnlModeSelection;
            _polygonPicker.ModePanel = _pnlModeSelection;
            _addressPicker.ModePanel = _pnlModeSelection;

            _pickersPanel.Controls.Add(_namedPicker);
            _pickersPanel.Controls.Add(_addressPicker);
            _pickersPanel.Controls.Add(_pointPicker);
            _pickersPanel.Controls.Add(_polygonPicker);
        }
Exemple #2
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            Controls.Clear();

            // Mode Selection Panel and Controls
            _pnlModeSelection = new Panel { ID = "pnlModeSelection" };
            _pnlModeSelection.CssClass = "picker-mode-options";
            _pnlModeSelection.ViewStateMode = ViewStateMode.Enabled;

            _radNamed = new RadioButton { ID = "radNamed" };
            _radNamed.Text = "Location";
            _radNamed.GroupName = "radiogroup-location-mode_" + this.ClientID;
            _pnlModeSelection.Controls.Add( _radNamed );

            _radAddress = new RadioButton { ID = "radAddress" };
            _radAddress.Text = "Address";
            _radAddress.GroupName = "radiogroup-location-mode_" + this.ClientID;
            _pnlModeSelection.Controls.Add( _radAddress );
            
            _radPoint = new RadioButton { ID = "radPoint" };
            _radPoint.Text = "Point";
            _radPoint.GroupName = "radiogroup-location-mode_" + this.ClientID;
            _pnlModeSelection.Controls.Add( _radPoint );

            _radPolygon = new RadioButton { ID = "radPolygon" };
            _radPolygon.Text = "Polygon";
            _radPolygon.GroupName = "radiogroup-location-mode_" + this.ClientID;
            _pnlModeSelection.Controls.Add( _radPolygon ); 
            
            _pickersPanel = new Panel { ID = "pickersPanel" };
            _pickersPanel.ViewStateMode = ViewStateMode.Disabled;
            this.Controls.Add( _pickersPanel );

            _namedPicker = new LocationItemPicker();
            _namedPicker.ID = this.ID + "_namedPicker";

            _addressPicker = new LocationAddressPicker();
            _addressPicker.ID = this.ID + "_addressPicker";

            _pointPicker = new GeoPicker();
            _pointPicker.ID = this.ID + "_pointPicker";
            _pointPicker.DrawingMode = GeoPicker.ManagerDrawingMode.Point;
            _pointPicker.SelectGeography += _pointPicker_SelectGeography;

            _polygonPicker = new GeoPicker();
            _polygonPicker.ID = this.ID + "_polygonPicker";
            _polygonPicker.DrawingMode = GeoPicker.ManagerDrawingMode.Polygon;
            _polygonPicker.SelectGeography += _polygonPicker_SelectGeography;

            _namedPicker.ModePanel = _pnlModeSelection;
            _pointPicker.ModePanel = _pnlModeSelection;
            _polygonPicker.ModePanel = _pnlModeSelection;
            _addressPicker.ModePanel = _pnlModeSelection;

            _pickersPanel.Controls.Add( _namedPicker );
            _pickersPanel.Controls.Add( _addressPicker );
            _pickersPanel.Controls.Add( _pointPicker );
            _pickersPanel.Controls.Add( _polygonPicker );
        }