我正在从服务器加载数据并将其传递给数组。该数据包括坐标,文本,图像等。它还包含名为“ id”的变量(我曾考虑过对特定ID进行数组排序,但不确定这是否是一个好的解决方案)。此数据用于在地图上显示标记。 我的任务是在单独的视图上显示此标记的详细信息。如何告诉此详细信息屏幕选择了哪个标记,或者如何根据所选标记从数组中获取特定元素?
这是我创建标记的地方:
for element in spots {
let image = UIImage(named: element.type)
let position = CLLocationCoordinate2D(latitude: element.coordinates.latitude,longitude:
element.coordinates.longitude)
marker = GMSMarker(position: position)
marker.icon = image
marker.map = mapView
}