mvHelper.addMarkerGraphic(Double.parseDouble(friendData.getLatitude()), Double.parseDouble(friendData.getLongitude()), friendData.getFriendName(), friendData.getStatus(), null, icon, false, 0);
mvHelper.setOnGraphicClickListener(new OnGraphicClickListener() { @Override public void onGraphicClick(Graphic graphic) { Log.d("MVHELPER GRAPHIC LISTENER TAG",graphic.toString()); } });Solved! Go to Solution.
calculateDirection((float)((Point)graphic.getGeometry()).getX(),(float)((Point)graphic.getGeometry()).getY());
calculateDirection(float x, float y){
final Point loc = mapView.toMapPoint(x, y);
Thread t = new Thread() {
@Override
public void run() {
try {
// Start building up routing parameters
RouteParameters rp = mRouteTask
.retrieveDefaultRouteTaskParameters();
NAFeaturesAsFeature rfaf = new NAFeaturesAsFeature();
// Convert point to EGS (decimal degrees)
Point p = (Point) GeometryEngine.project(loc, wm,
egs);
// Create the stop points (start at our location, go
// to pressed location)
StopGraphic point1 = new StopGraphic(mLocation);
StopGraphic point2 = new StopGraphic(p);
rfaf.setFeatures(new Graphic[] { point1, point2 });
rfaf.setCompressedRequest(true);
rp.setStops(rfaf);
// Set the routing service output SR to our mapView
// service's SR
rp.setOutSpatialReference(wm);
// Solve the route and use the results to update UI
// when received
mResults = mRouteTask.solve(rp);
mHandler.post(mUpdateResults);
} catch (Exception e) {
mException = e;
mHandler.post(mUpdateResults);
}
}
};
// Start the operation
t.start();
}
com.esri.core.io.EsriServiceException:Unable to complete operation. Location "Location 2" in "Stops" is unlocated. Need atleast 2 valid stops. "Stops" does not contain valid input for any route.
x = -1.0401366E7 y = 5617207.0
final SpatialReference wm = SpatialReference.create(102100); final SpatialReference egs = SpatialReference.create(4326); ... ... ... Point loc = mapView.toMapPoint(x, y); Point p = (Point) GeometryEngine.project(loc, wm, egs);