2

I have an ArcGIS Engine application that contains a PAGELAYOUT CONTROL In the code progressing I have acquired the centroid's of some selected polygons in real world coordinates (ie x = 2484242.45 and Y = 276913.75) I have verified the coordinates are correct in arc map for the selected polygons. I am trying to use the centroid x, y location to be the anchor point for some balloon callouts. thus converting the real world coordinates to page units (ie x = 1.1 in & y = 4.3in) Here I run into problems. Here is function I found on esri site but Obviously I am missing something and I know it is probably something simple. Can anyone help I am definitely not getting page units to anchor the text balloon callouts like I expected. I am thinking I might have to populates some constants prior to running the conversion. Here is the function as I have used it

Function GetScreenCoordinatesFromMapCoorindates(ByVal mapPoint As ESRI.ArcGIS.Geometry.IPoint, ByVal activeView As ESRI.ArcGIS.Carto.IActiveView, ByVal mapenvelope As IEnvelope) As ESRI.ArcGIS.Geometry.IPoint

    If mapPoint Is Nothing OrElse mapPoint.IsEmpty OrElse activeView Is Nothing Then
         Return Nothing
    End If        
    Dim screenDisplay As ESRI.ArcGIS.Display.IScreenDisplay = activeView.ScreenDisplay
    Dim displayTransformation As ESRI.ArcGIS.Display.IDisplayTransformation = screenDisplay.DisplayTransformation
    Dim x As System.Int32
    Dim y As System.Int32
    displayTransformation.FromMapPoint(mapPoint, x, y)
    Dim returnPoint As ESRI.ArcGIS.Geometry.IPoint = New ESRI.ArcGIS.Geometry.PointClass
    returnPoint.PutCoords(x, y)
    Return returnPoint
End Function

'Variables for attributes used in the function after processing
'MapPoint.x = 2484228.50293302
'Mappoint.y = 276930.5335755446
'returnPoint.x = 190643159
'returnPoint.Y = -21251274

  • This will give you coordinates relative to that data frame, not the page. Can you show a screen dump of the incorrect coordinates please. – Michael Stimson Jan 6 '15 at 0:14
  • I hope this helps. I know it must be something stupid that I am doing I am definitely not an expert. Any help would be appreciated. – Bob Folsom Jan 6 '15 at 16:51
  • What is the spatial reference of the map/mapPoint? Is it set? It looks like either the map or the point is missing spatial reference or conflicting projected/geographic; can you provide information on activeView.FocusMap.SpatialReference and mapPoint.SpatialReference, the .FactoryCode should be enough if you're using SRID spatial references. – Michael Stimson Jan 6 '15 at 23:16
  • Well I have the spatial reference set in the map document via the arcmap document that is being opened. I will add some code to verify what the spatial reference is going in and post. – Bob Folsom Jan 7 '15 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.