指向Google Maps iOS的坐标

时间:2013-11-19 11:25:46

标签: ios google-maps google-maps-sdk-ios

GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(48.f, 35.f);
marker.map = mapView;
CGPoint point = [mapView.projection pointForCoordinate:marker.position];

为什么点有NaN值?

打印点描述: (CGPoint)point =(x = NaN,y = NaN)

1 个答案:

答案 0 :(得分:0)

由于CLLocationCoordinate2DMake等待float值,而您发送integer值。

您可以执行以下操作:

float pointA = (float) (arc4random() % 10);
float pointB = (float) (arc4random() % 10);

marker.position = CLLocationCoordinate2DMake(pointA, pointB);