Select to view content in your preferred language

Change map coordinate to screen point(x-y)

3898
4
03-04-2019 11:51 PM
MohamadFathin
Emerging Contributor

Hi

I try search many tutorial on how can convert the map coordinate(Lat/Long) to screen coordinate but it seem i can't find any of it. I want to perform a traverse method for the map to plot a marker. Any suggestion and idea are much appreciate.

0 Kudos
4 Replies
Nicholas-Furness
Esri Regular Contributor

Hi Mohamad Fathin,

Does this help? MapView.LocationToScreen Method 

Pass in any MapPoint and you get a screen position relative ‌to the top-left corner of the MapView control.

Nick.

0 Kudos
MohamadFathin
Emerging Contributor

Hi Nicholas Furness

I try the reference you share.

double longitude = 100.458802; //reference starting point
double latitude = 5.997545;

public Point LocationToScreen(MapPoint location)
{
location = new MapPoint(longitude,latitude, SpatialReferences.Wgs84);
return location;
}

But it get me this error : 

Cannot implicitly convert type 'Esri.ArcGISRuntime.Geometry.MapPoint' to 'System.Windows.Point' 

Fathin

0 Kudos
Nicholas-Furness
Esri Regular Contributor

I meant that you should call mapView.LocationToScreen, not write your own function.

Something like…

double longitude = 100.458802; //reference starting point
double latitude = 5.997545;
location = new MapPoint(longitude,latitude, SpatialReferences.Wgs84);
screenPoint = mapView.LocationToScreen(location);

Perhaps I misunderstood your question.

0 Kudos
MohamadFathin
Emerging Contributor

Hi Nicholas Furness

It work. Thank for your help.