我想向地图添加一个点。经度纬度点的奇怪位置
我得到这样的搭配:
- (void)plotCrimePositions:(NSData *)responseData {
for (id<MKAnnotation> annotation in _mapView.annotations) {
[_mapView removeAnnotation:annotation];
}
NSDictionary *root = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];
NSArray *data = [root objectForKey:@"features"];
NSLog(@"features: %@", data);
for (NSDictionary *dic in data) {
NSDictionary *geometry = [dic objectForKey:@"geometry"];
// Do what you want..
NSNumber *latitude = [geometry objectForKey:@"x"];
NSNumber *longitude = [geometry objectForKey:@"y"];
NSString *crimeDescription = @"test";
NSString *address = @"banaan";
NSLog(@"latitude: %@", latitude);
NSLog(@"longitude: %@", longitude);
NSLog(@"error: %@", crimeDescription);
NSLog(@"error: %@", address);
CLLocationCoordinate2D coordinate;
coordinate.latitude = latitude.doubleValue;
coordinate.longitude = longitude.doubleValue;
NSLog(@"latitude2: %f", coordinate.latitude);
NSLog(@"longitude2: %f", coordinate.longitude);
MyLocation *annotation = [[MyLocation alloc] initWithName:crimeDescription address:address coordinate:coordinate] ;
[_mapView addAnnotation:annotation];
}
}
我得到这个作为的NSLog:
2012-11-14 10:57:02.404 ArrestPlotter[9254:907] Response: {"displayFieldName":"Gecontroleerd","fieldAliases":{"Gecontroleerd":"Gecontroleerd"},"geometryType":"esriGeometryPoint","spatialReference":{"wkid":4326},"fields":[{"name":"Gecontroleerd","type":"esriFieldTypeString","alias":"Gecontroleerd","length":255}],"features":[{"attributes":{"Gecontroleerd":"Ja"},"geometry":{"x":5.9680979652859065,"y":52.507071127790766}}]}
2012-11-14 10:57:02.421 ArrestPlotter[9254:907] features: (
{
attributes = {
Gecontroleerd = Ja;
};
geometry = {
x = "5.968097965285907";
y = "52.50707112779077";
};
}
)
2012-11-14 10:57:02.423 ArrestPlotter[9254:907] latitude: 5.968097965285907
2012-11-14 10:57:02.424 ArrestPlotter[9254:907] longitude: 52.50707112779077
2012-11-14 10:57:02.425 ArrestPlotter[9254:907] error: test
2012-11-14 10:57:02.426 ArrestPlotter[9254:907] error: banaan
2012-11-14 10:57:02.427 ArrestPlotter[9254:907] latitude2: 5.968098
2012-11-14 10:57:02.437 ArrestPlotter[9254:907] longitude2: 52.507071
但它应该是在这里:
但地图在这里显示它:
上面说的是位置 2012年11月14日10:57:02.427 ArrestPlotter [9254:907] latitude2:5.968098 2012年11月14日10:57:02.437 ArrestPlotter [9254:907] longitude2:52.507071
应该在荷兰。
有谁知道我做错了什么或有同样的问题? 在此先感谢
编辑
难道是因为我用来自美国的教程中,我用这个值
#define METERS_PER_MILE 1609.344
我觉得自己像一个滞后 –
不要!我们都犯了类似的错误......令人惊讶的是另一双眼睛能够如何帮助 –