The Geocode service you are using should be able to accept lat/lon fields to identify a location.In this sample, http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#RoutingDirections, notice that Locator calls AddressToLocationAsync. Instead, you need to call LocationToAddressAsync as in this other sample, http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#LocationToAddress.
if (_stops.Count < 2) _stops.Add(new Graphic(){Geometry = e.MapPoint}); if(_stops.Count == 2) _routeTask.SolveAsync(_routeParams);
_stops.Add(new Graphic(){Geometry = new MapPoint(lat, lon}); // for both start and end location.
Ah okay I see what you're doing now.In this case, you do not need LocationToAddressAsync nor AddressToLocationAsync.Using this sample http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#RoutingDirections, I commented out code for initializing locator and subscribing to its events. Instead, I subscribed to MouseClick. if (_stops.Count < 2) _stops.Add(new Graphic(){Geometry = e.MapPoint}); if(_stops.Count == 2) _routeTask.SolveAsync(_routeParams); Since you already have the lat/lon values, you do not need to get MapPoints from an event such as MouseClick, you can simply do:_stops.Add(new Graphic(){Geometry = new MapPoint(lat, lon}); // for both start and end location.That should be all you need to do.
for class MapPoint, X property means latitude, and Y property means longitude? or is it the other way around?
It's the other way : X means longitude and Y means latitude.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.