如何在android中设置所需位置,并在半径范围内为用户提供10个点
final Button hereButton = (Button) findViewById(R.id.getPoints);
hereButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
String coordinates[] = {"40.000000", "-80.000000"};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);
final double radius = 480; //0.3 miles
//distance = coordinates.distance(from: userLocation)
if coordinates < radius
{
Total_Points += 10
}
}
});
答案 0 :(得分:0)
int Total_Points = 0;
CLLocation desiredlocation = CLLocation(45.000000,-80.000000);
Double radius = 480; // ~0.3 miles
Double distance = desiredlocation.distance(userLocation);
if (distance < radius){
Total_Points += 10;
pointsLabel.setText("Total Points: \(Total_Points)");
getPointsOutlet.isEnabled = false;
}
save.setValue(Total_Points, "Total Points");