I am trying to figure out a way to add custom properties/data for my marker.
What I have used
- Marker.Title (Store Title)
- Marker.Snippet (Store object Id)
- Marker.Icon (Store icon)
- Marker.userData(to store image)
Additional Information I'd like to store to display on InfoWindow
Description(String)
A number(Int)
It would be nice if there are more efficient ways of storing and retrieving custom data/properties to display on the infowindow. Any suggestions would be valuable at the moment.
Here is a snippet of what I have at the moment: Setting Marker Data:
marker.title = object["objectTitle"] as! String
marker.snippet = objecti.objectId
marker.icon = UIImage(named:"markerImage")
marker.userData = UIImage(data:imageData!)
Info Window:
func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
var infoWindow :CustomInfoWindow = NSBundle.mainBundle().loadNibNamed("eventInfo", owner: self, options: nil)[0] as! CustomInfoWindow
infoWindow.eventTitle.text = marker.title
infoWindow.Image.image = marker.userData as? UIImage
marker.userData = UIImage(data:imageData!)
marker.snippet = object.objectId
return infoWindow
}
I created a struct that has all the data i need and put it in marker.userdata since it supports Any type.
Aceess it like this: