Objective c 如何知道谷歌地图上选定标记的坐标

Objective c 如何知道谷歌地图上选定标记的坐标,objective-c,google-maps-markers,google-polyline,Objective C,Google Maps Markers,Google Polyline,我想在谷歌地图上为选定的标记绘制一条多段线。我在谷歌地图上钉了大约20个标记。这些标记是根据GooglePlacesAPI返回的数据绘制的。我将所有坐标存储在一个数组中,然后使用反向地理编码来获取特定坐标的地址 然后,为了使用marker,我调用了delegate方法didTapMarker,在其中我使用了googledirectionsapi 但我的问题是:-用户可以选择任何标记,而不考虑存储坐标的数组的indexPath值。因此,如何在谷歌地图上为随机选择的标记绘制多边形线。您可以获得点击的

我想在谷歌地图上为选定的标记绘制一条多段线。我在谷歌地图上钉了大约20个标记。这些标记是根据GooglePlacesAPI返回的数据绘制的。我将所有坐标存储在一个数组中,然后使用反向地理编码来获取特定坐标的地址

然后,为了使用marker,我调用了delegate方法didTapMarker,在其中我使用了googledirectionsapi


但我的问题是:-用户可以选择任何标记,而不考虑存储坐标的数组的indexPath值。因此,如何在谷歌地图上为随机选择的标记绘制多边形线。

您可以获得点击的标记。 使用以下属性获取其在地图上的位置

marker.position
不知怎么的,我做到了

我只需要使用GMSMarker的userData属性。 我在“for loop”中为每个标记分配了一个markerID,如下所示:

marker.userData = @{@"marker_id":[NSString stringWithFormat:@"%d",i]};
然后在GMSMapView的didTapMarker委托下,我像这样调用了googledirectionsapi

   NSDictionary *tempDic=[[NSDictionary alloc]init];
   tempDic=marker.userData;
   int value= [tempDic[@"marker_id"]intValue];

  NSString *strUrl = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/directions/json?&alternatives=true&origin=%@&destination=%@&key=%@&sensor=false",addressAt,[tempArray objectAtIndex:value],googleAPI_Key];
  //addressAt is the current location of user i.e source and for destination I called the array in which my converted address is stored

没有太多的帮助,它一无所获。