如何使用文本字段设置经度和纬度?我试过让我的文本域变成双重但它似乎崩溃了。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
mapview.showsUserLocation = YES;
MKCoordinateRegion region = { {0.0, 0.0}, {0.0,0.0}};
region.center.latitude = *(myTextField);
region.center.longitude = *(myTextField1);
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapview setRegion:region animated:YES];
MapPin *ann = [[MapPin alloc] init];
ann.title = @"Test";
ann.subtitle = @"test";
ann.coordinate = region.center;
[mapview addAnnotation:ann];
}
我如何才能做到这一点?
答案 0 :(得分:0)
MKPointAnnotation *annonation = [[MKPointAnnotation alloc]init];
CLLocationCoordinate2D mycordinate;
mycordinate.latitude = [self.latitude floatValue];
mycordinate.longitude =[self.longitude floatValue];
annonation.coordinate = mycordinate;
[self.mapview addAnnotation:annonation];
在self.latitude
存储您的纬度值和
在self.longitude
中存储您的经度值。
答案 1 :(得分:-1)
尝试以下代码:
只需从textFields获取文本并从文本中设置纬度,经度浮点值。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
mapview.showsUserLocation = YES;
MKCoordinateRegion region = { {0.0, 0.0}, {0.0,0.0}};
region.center.latitude = [self.myTextField.text floatValue];
region.center.longitude = [self.myTextField1.text floatValue];
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapview setRegion:region animated:YES];
MapPin *ann = [[MapPin alloc] init];
ann.title = @"Test";
ann.subtitle = @"test";
ann.coordinate = region.center;
[mapview addAnnotation:ann];
}
答案 2 :(得分:-1)
将public interface IRepo
{
//Return string because jqgrid need json and if i don't need json
//I would process it
string GetAll(params object[] parameters);
}
public class UserRepository : IRepo
{
public string GetAll(params object[] parameters)
{
try
{
//In the dataset there is multiple result set
//ErrorCode, Userinfo (Username,AccessCode, UserID),
//and multiple Organization
DataSet ds;
DALUser DALOsztaly = new DALUser();
ds = DALOsztaly.LoginDs();
return JsonConvert.SerializeObject(ds.Tables[0]);
}
catch (Exception e)
{
}
}
...
}
从textFields文本转换为浮点值
因为你需要浮动值。例:JsonResult j = Json(userrepo.GetAll())
var someObject = JsonConvert.DeserializeObject(loginrepo.GetAll())