Hello all ,
i have a simple problem i have plotted a lot of points by mouse click and gave its point an id , i need to get any of these point longitude or latitude by calling its ID , how can i do that ?
thanks in advance
Hello all ,
i have a simple problem i have plotted a lot of points by mouse click and gave its point an id , i need to get any of these point longitude or latitude by calling its ID , how can i do that ?
thanks in advance
Hi Mostafa20015,
I think this sample should be helpful.
Any question please let us know.
Regards,
Ethan
thanks ethan ,
but unfortunately it is not what i want , now i have to plot a circle its center is point_x , this point_x is a dummy point i have created on map_click event , to achieve my purpose i have to get this dummy point_x longitude and latitude by calling it’s id
EllipseShape ellipseShape = new EllipseShape(point_x , CircleRadius, GeographyUnit.DecimalDegree, DistanceUnit.Kilometer);
Hi Mostafa,
It looks you want to find the feature by its id, that’s even more simple.
We have the API named layer.QueryTools.GetFeatureById, it can works for it.
If I still misunderstand you please describe your requirement more detail.
Regards,
Ethan
hello ethan , im sorry for disturbance
here is a part of code which plot a point on mouse click event
private void winformsMap1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)
winformsMap1.FindFeatureLayer("Shape");
System.Drawing.Point screenPointEnd = e.Location;
RectangleShape extent = winformsMap1.CurrentExtent;
ScreenPointF currentPoint = new ScreenPointF(screenPointEnd.X, screenPointEnd.Y);
PointShape endPoint = ExtentHelper.ToWorldCoordinate(extent, currentPoint,winformsMap1.Width, winformsMap1.Height);
shapeLayer.InternalFeatures.Add("shape" + y, new Feature(endPoint));
winformsMap1.Refresh(winformsMap1.Overlays["PointOverlay"]);
y++;
}
}
after plotting five points for example [first point id is “shape1” , and 2nd point id is “shape2” …till “shape5”]
, i need to draw a circle it’s center is one of these point according its id (for example i will type a point id in textbox = “shape5”)
now i need this shape5 point is the center of a circle i want to plot
this part of code for plotting a circle
int q = 1; //circle id counter
private void button7_Click(object sender, EventArgs e)
{
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("Shape");
InMemoryFeatureLayer CircleLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("CircleLayer");
// circle center point
PointShape circle_center= new PointShape(30,30);
//get circle radius from Circle radius textbox
double CircleRadius = Convert.ToDouble(textBox2.Text);
EllipseShape ellipseShape = new EllipseShape(circle_center,CircleRadius, GeographyUnit.DecimalDegree, DistanceUnit.Kilometer);
CircleLayer.InternalFeatures.Add("circle" + q ,new Feature(ellipseShape));
CircleLayer.InternalFeatures.Add("circle_center" + q ,new Feature(GPSpointShape));
q++;//increasind circle id counter each time we plot a circle
winformsMap1.Refresh(winformsMap1.Overlays["PointOverlay"]);
}
BestRegards
hello all ,
that was i wanted
//get a longtude and latitue of point by its ID and use it as a center point for circle
PointShape circle_center = (PointShape)shapeLayer.InternalFeatures["shape" + PID].GetShape();
Hi Mostafa,
Yes this way can works for your scenario.
Thanks for your update.
Regards,
Ethan