Select to view content in your preferred language

How to Get point long and lat from Geometry

1924
2
Jump to solution
07-02-2012 06:19 PM
JulieBiju
Deactivated User
Hello...Advance thanks...Please help me to solve the issue specified below

    I drw a point on my map using the function below.Now i want to save these points long and lat to DB for future reference.How can i retrive point geometry?Help me for this Please

rivate Sub MyDrawObject_DrawComplete(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.DrawEventArgs)                        Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayer"), GraphicsLayer)         Dim graphic As New ESRI.ArcGIS.Client.Graphic() With           {             .Geometry = args.Geometry,             .Symbol = _activeSymbol           }         graphicsLayer.Graphics.Add(graphic)       End Sub
0 Kudos
1 Solution

Accepted Solutions
JoeHershman
MVP Alum
You just need top cast your geometry to a MapPoint which has the X, Y coordinates.  Make sure you are in WGS 84 projection, if you are using Bing or AGS Online you will be in WebMercator.  Look in the projection namespace for the classes that will project from one to the other.  Also X is Longitude and Y is Latitude.  In this part of the world X of mid 50's, Y of mid 20's is what you should expect.

Apologizes if the VB is not correct, it has been a long time and this is done in a text editor, but I believe something like this

   Private Sub MyDrawObject_DrawComplete(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.DrawEventArgs)           Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayer"), GraphicsLayer)         Dim graphic As New ESRI.ArcGIS.Client.Graphic() With           {             .Geometry = args.Geometry,             .Symbol = _activeSymbol           }         graphicsLayer.Graphics.Add(graphic)    Dim mapPoint As MapPoint = TryCast(args.Geometry, MapPoint)  If mapPoint Is Not Nothing Then        ''Write out the points, make sure to convert to WGS 84 if in Web Mercator  End If       End Sub 
Thanks,
-Joe

View solution in original post

0 Kudos
2 Replies
JulieBiju
Deactivated User
Can anybdy help me for this...It is very Urgent....Please
0 Kudos
JoeHershman
MVP Alum
You just need top cast your geometry to a MapPoint which has the X, Y coordinates.  Make sure you are in WGS 84 projection, if you are using Bing or AGS Online you will be in WebMercator.  Look in the projection namespace for the classes that will project from one to the other.  Also X is Longitude and Y is Latitude.  In this part of the world X of mid 50's, Y of mid 20's is what you should expect.

Apologizes if the VB is not correct, it has been a long time and this is done in a text editor, but I believe something like this

   Private Sub MyDrawObject_DrawComplete(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.DrawEventArgs)           Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayer"), GraphicsLayer)         Dim graphic As New ESRI.ArcGIS.Client.Graphic() With           {             .Geometry = args.Geometry,             .Symbol = _activeSymbol           }         graphicsLayer.Graphics.Add(graphic)    Dim mapPoint As MapPoint = TryCast(args.Geometry, MapPoint)  If mapPoint Is Not Nothing Then        ''Write out the points, make sure to convert to WGS 84 if in Web Mercator  End If       End Sub 
Thanks,
-Joe
0 Kudos