Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何放置两个彩色别针?一个是红色的,一个是绿色的?_Iphone_Google Maps_Mapkit_Mkmapview_Mkannotation - Fatal编程技术网

Iphone 如何放置两个彩色别针?一个是红色的,一个是绿色的?

Iphone 如何放置两个彩色别针?一个是红色的,一个是绿色的?,iphone,google-maps,mapkit,mkmapview,mkannotation,Iphone,Google Maps,Mapkit,Mkmapview,Mkannotation,我正在使用此示例应用程序制作路线 它将调用路由api并解析结果 然后在地图上方添加一个新图层,其中包含a和B之间的路线 我的问题是如何放置两个彩色别针?现在它显示了两个红色的别针。但我需要一个红色和一个绿色 我正试图与这位代表一起工作,但这对我没有帮助 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation -(MKAnnotationVi

我正在使用此示例应用程序制作路线

它将调用路由api并解析结果

然后在地图上方添加一个新图层,其中包含a和B之间的路线

我的问题是如何放置两个彩色别针?现在它显示了两个红色的别针。但我需要一个红色和一个绿色

我正试图与这位代表一起工作,但这对我没有帮助

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释
-(MKAnnotationView*)映射视图:(MKMapView*)映射视图
viewForAnnotation:(id)注释{
如果(注释==yourFirstAnnotation)
{
MKPinAnnotationView*annView=[[MKPinAnnotationView alloc]initWithAnnotation:yourFirstAnnotation重用标识符:[注释标题]];
annView.pinColor=MKPinAnnotationColorRed;
annView.animatesDrop=否;
annView.canShowCallout=是;
返回[annView autorelease];
}
其他的
如果(注释==yourSecondAnnotation)
{
MKPinAnnotationView*annView=[[MKPinAnnotationView alloc]initWithAnnotation:yourSecondAnnotation重用标识符:[注释标题]];
annView.pinColor=MKPinAnnotationColorGreen;
annView.animatesDrop=否;
annView.canShowCallout=是;
返回[annView autorelease];
}
}
我认为如果它不起作用,可以使用
isEqual:
而不是
==

- (MKAnnotationView *)mapView:(MKMapView *)mapView 
            viewForAnnotation:(id <MKAnnotation>)annotation {

    if(annotation == yourFirstAnnotation)
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:yourFirstAnnotation reuseIdentifier:[annotation title]];
            annView.pinColor = MKPinAnnotationColorRed;
            annView.animatesDrop=NO;
            annView.canShowCallout = YES;
            return [annView autorelease];
}
else
if(annotation == yourSecondAnnotation)
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:yourSecondAnnotation reuseIdentifier:[annotation title]];
            annView.pinColor = MKPinAnnotationColorGreen;
            annView.animatesDrop=NO;
            annView.canShowCallout = YES;
            return [annView autorelease];
}
}