C# Class Rock.Web.UI.Controls.GeoPicker

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
Show file Open project: SparkDevNetwork/Rock Class Usage Examples

Private Properties

Property Type Description
ConvertPointFromWellKnownText string
ConvertPointToWellKnownText string
ConvertPolyFromWellKnownText string

Public Methods

Method Description
ConvertPolyToWellKnownText ( string latCommaLongPipe ) : string

Convert string from "lat1,long1|lat2,long2|..." to Well Known Text (WKT) http://en.wikipedia.org/wiki/Well-known_text format "POLYGON(( long1 lat1, long2 lat2, ...))". It is expected that the input is a single polygon (not a polygon with an inner polygon). It will also correct the orientation (clockwise-ness) of the points because DbGeography needs them to be in counter-clockwise order.

GeoPicker ( ) : System

Initializes a new instance of the GeoPicker class.

IsClockwisePolygon ( PointF polygon ) : bool

Attempt to determine if the polygon is clockwise or counter-clockwise. Thank you dominoc! http://dominoc925.blogspot.com/2012/03/c-code-to-determine-if-polygon-vertices.html

RenderBaseControl ( System.Web.UI.HtmlTextWriter writer ) : void

Renders the base control.

RenderControl ( System.Web.UI.HtmlTextWriter writer ) : void

Outputs server control content to a provided T:System.Web.UI.HtmlTextWriter object and stores tracing information about the control if tracing is enabled.

SetValue ( System.Data.Entity.Spatial.DbGeography dbGeography ) : void

Sets the value. Necessary to preload the geo fence or geo point.

Protected Methods

Method Description
CreateChildControls ( ) : void

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.

OnInit ( EventArgs e ) : void

Raises the E:System.Web.UI.Control.Init event.

RegisterJavaScript ( ) : void

Registers the java script.

btnSelect_Click ( object sender, EventArgs e ) : void

Handles the Click event of the btnSelect control.

Private Methods

Method Description
ConvertPointFromWellKnownText ( string wkt ) : string

Convert from WKT format: "POINT (long1 lat1)" to "lat1,long1"

ConvertPointToWellKnownText ( string latCommaLong ) : string

Converts single coordinate set (lat,long) into the Well Known Text (WKT) POINT format. http://en.wikipedia.org/wiki/Well-known_text

ConvertPolyFromWellKnownText ( string wkt ) : string

Convert from WKT format: "POLYGON ((long1 lat1, long2 lat2, ...))" to "lat1,long1|lat2,long2|..."

Method Details

ConvertPolyToWellKnownText() public static method

Convert string from "lat1,long1|lat2,long2|..." to Well Known Text (WKT) http://en.wikipedia.org/wiki/Well-known_text format "POLYGON(( long1 lat1, long2 lat2, ...))". It is expected that the input is a single polygon (not a polygon with an inner polygon). It will also correct the orientation (clockwise-ness) of the points because DbGeography needs them to be in counter-clockwise order.
public static ConvertPolyToWellKnownText ( string latCommaLongPipe ) : string
latCommaLongPipe string string of "lat1,long1|lat2,long2|..."
return string

CreateChildControls() protected method

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.
protected CreateChildControls ( ) : void
return void

GeoPicker() public method

Initializes a new instance of the GeoPicker class.
public GeoPicker ( ) : System
return System

IsClockwisePolygon() public static method

Attempt to determine if the polygon is clockwise or counter-clockwise. Thank you dominoc! http://dominoc925.blogspot.com/2012/03/c-code-to-determine-if-polygon-vertices.html
public static IsClockwisePolygon ( PointF polygon ) : bool
polygon System.Drawing.PointF
return bool

OnInit() protected method

Raises the E:System.Web.UI.Control.Init event.
protected OnInit ( EventArgs e ) : void
e System.EventArgs An object that contains the event data.
return void

RegisterJavaScript() protected method

Registers the java script.
protected RegisterJavaScript ( ) : void
return void

RenderBaseControl() public method

Renders the base control.
public RenderBaseControl ( System.Web.UI.HtmlTextWriter writer ) : void
writer System.Web.UI.HtmlTextWriter The writer.
return void

RenderControl() public method

Outputs server control content to a provided T:System.Web.UI.HtmlTextWriter object and stores tracing information about the control if tracing is enabled.
public RenderControl ( System.Web.UI.HtmlTextWriter writer ) : void
writer System.Web.UI.HtmlTextWriter The object that receives the control content.
return void

SetValue() public method

Sets the value. Necessary to preload the geo fence or geo point.
public SetValue ( System.Data.Entity.Spatial.DbGeography dbGeography ) : void
dbGeography System.Data.Entity.Spatial.DbGeography The db geography.
return void

btnSelect_Click() protected method

Handles the Click event of the btnSelect control.
protected btnSelect_Click ( object sender, EventArgs e ) : void
sender object The source of the event.
e System.EventArgs The instance containing the event data.
return void