iOS - 用GPS坐标检测一个地方 [英] iOS - Detect a place with GPS coordinates
问题描述
44 35'25 n 104 42'55w
或
44.5903 -104.7153
然后一个警报弹出并显示一条消息!
谢谢。
您可以使用以下方式测量硬编码位置与当前用户位置之间的距离:
CLLocation * hardcoded_location = [[CLLocation alloc] initWithLatitude:latitude1 longitude:longitude1];
CLLocation * new_location = newLocation;
CLLocationDistance distance = [hardcoded_location distanceFromLocation:new_location];
然后你可以这样做:
if(distance {
[[[UIAlertView alloc] initWithTitle:@Titlemessage:@Messagedelegate:nil cancelButtonTitle:@OK otherButtonTitles:nil,nil] show];
更新:
$ b
typedef double CLLocationDistance
:
距离现有位置的距离测量值(以米为单位)。
is there any way to detect a place with GPS coordinates ? (as much as possible without map ) for example check if longitude and latitude is equal or near to these :
44 35′25″n 104 42′55″w
or
44.5903 -104.7153
then an alert pops up and display a message ! Thanks .
You can measure the distance between your "hardcoded" location and current users location with following:
CLLocation *hardcoded_location = [[CLLocation alloc] initWithLatitude:latitude1 longitude:longitude1];
CLLocation *new_location = newLocation;
CLLocationDistance distance = [hardcoded_location distanceFromLocation:new_location];
Then you could do:
if (distance < some_value)
{
[[[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
}
See https://developer.apple.com/library/mac/documentation/CoreLocation/Reference/CoreLocationDataTypesRef/Reference/reference.html for more info.
UPDATE:
typedef double CLLocationDistance
:
A distance measurement (in meters) from an existing location.
这篇关于iOS - 用GPS坐标检测一个地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!