Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Does anyone know how to do the following.

Say I have a map and I draw a rectangle over the state of Texas. ArcMapControl.TrackRectangle returns the lat,lon of this. However, what I'd like is to actually get the X,Y coords of the screen. For instance if the map was 500 px wide and 450 tall I'd expect something like

top = 257 bottom = 242 left = 146 right = 167

Anyone know if there is an easy way to convert this?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted
activeView = mapControl.Map as IActiveView;
ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;
int x, y; 
displayTransformation.FromMapPoint(yourIPoint, out x, out y);

should pop out your x,y

share|improve this answer
add comment

Take a look at IDisplayTransformation.FromMapPoint method, there is also a snippet that does this the other way around here that you can take a look at: Convert Display Pixel to Map Units Snippet

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.