ThinkGeo.com    |     Documentation    |     Premium Support

How to place predefined Circle shape

Hi all,


How would i have a textbox(Radius) that dictates the radius of a circle.


I then want to place that circle where the person clicks.


Or a better option would be, place a point on the map where the user clicks and then Set the radius and then on click of button draw the circle with the defined radius?



Hi Gregory,


The snipped code as below should be helpful. If you want to popup dialog client side you can try to add some the third part JS library for implement it for example jQuery.


Regards,


Don


Client side:

 


 

        <asp:ScriptManager ID="ScriptManager1" runat="server">

        </asp:ScriptManager>

        <asp:UpdatePanel runat="server">

            <ContentTemplate>

                Radius:

                <asp:TextBox ID="textRadius" runat="server" /> 

                <cc1:Map ID="Map1" runat="server" Height="480px" Width="640px" OnTrackShapeFinished="Map1_TrackShapeFinished">

                </cc1:Map>                

            </ContentTemplate>

        </asp:UpdatePanel>       、


 


Server side:


 


 protected void Page_Load(object sender, EventArgs e)

        {

            if (!Page.IsPostBack)

            {

                Map1.CurrentExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);

                Map1.MapUnit = GeographyUnit.DecimalDegree;

                Map1.EditOverlay.TrackMode = TrackMode.Point;


                WorldMapKitWmsWebOverlay worldMapKitWmsWebOverlay = new WorldMapKitWmsWebOverlay("WorldMapKitOverlay");

                Map1.CustomOverlays.Add(worldMapKitWmsWebOverlay);

            }

        }


        protected void Map1_TrackShapeFinished(object sender, EventArgs e)

        {

            Feature lastPoint = Map1.EditOverlay.Features[Map1.EditOverlay.Features.Count - 1];


            EllipseShape ellipse = new EllipseShape(lastPoint, Double.Parse(textRadius.Text));            

            Map1.EditOverlay.Features.Add(new Feature(ellipse));

        }