iphone 蓝点和 pin 同时 -
请帮忙,这个问题之前已经被问过很多次了,但是人们的建议对我的结果没有影响,我想要的只是在地图上显示图钉和蓝色圆圈(准确性),这是我的实现。 - 哦,我正在使用 iPhone 设备 - 我不在模拟器中
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
NSLog(@"View for Annotation is called");
if (NSClassFromString(@"MKUserLocation")==[annotation class]) {
return nil;
}
if (annotation == mapView.userLocation) {
return nil;
}
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
UIButton * btn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.rightCalloutAccessoryView = btn;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
pinDropped = TRUE;
return annView;
}
提前欢呼......该死的事情
please help, this question has been asked so many times before, but peoples suggestions have no effect on my outcome, all i want, is the pin and blue circle (Accuracy) to be shown on the map, here is my implementation. - oh, im using an iPhone device - im not in the simulator
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
NSLog(@"View for Annotation is called");
if (NSClassFromString(@"MKUserLocation")==[annotation class]) {
return nil;
}
if (annotation == mapView.userLocation) {
return nil;
}
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
UIButton * btn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.rightCalloutAccessoryView = btn;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
pinDropped = TRUE;
return annView;
}
cheers in advance.... bloody thing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用模拟器,那么您可能会在 CoreLocation 和 MapKit 计算当前位置的方式上遇到不为人知的差异。
在模拟器中,
CoreLocation 将始终使用位于美国加利福尼亚州库比蒂诺的 Apple 总部作为您的当前位置。这是蓝点始终出现在地图上的位置。
MapKit 将始终使用 Apple 的 IP 地址和 WiFi 热点信息数据库来近似您当前的实际位置。如果您告诉地图使用您当前的位置,这就是地图的中心位置。
因此,地图将以您当前的位置为中心,但蓝点将位于库比蒂诺。
在 iOS 设备上,
CoreLocation 将蓝点放在近似您当前实际位置的位置上。
MapKit 将地图以接近您当前实际位置的位置为中心。
因此,当使用实际的 iOS 设备时,您会在地图中心看到蓝点。
这些知识可以减轻很多压力。 :)
If you're using the Simulator then you're likely encountering the not-well-known difference in the way that CoreLocation and MapKit figure your current position.
In the Simulator
CoreLocation will always use Apple's headquarters in Cupertino, California, USA as your current location. This is where the blue dot will always appear on the map.
MapKit will always use something approximating your actual current location using Apple's database of IP address and WiFi hotspot information. This is where the map will center if you tell it to use your current location.
As a result, the map will center on your current location but the blue dot will be over in Cupertino.
On an iOS Device
CoreLocation puts the blue dot on something approximating your actual current location.
MapKit centers the map on something approximating your actual current location.
As a result you'll see the blue dot in the center of the map when using an actual iOS device.
This bit of knowledge can save a lot of stress. :)
以防万一有人想知道,这也有效:
just in case someone was wondering, this also works:
这在我的代码中有效
尝试一下并让我们知道
This works in my code
Try that and let us know
确保已实现 [mapview addAnnotation:annotation];
谢谢安娜的提醒。
make sure implemented [mapview addAnnotation:annotation];
thanks Anna for the reminder.