I am trying to create many pins from a database of locations, each with custom images. The images are passed from the server in base64 format, I am able to create a UIImage
from the base64 data, but I cannot upload the image as the icon instead of the pin for each annotation.
Any ideas how I can do this?
I tried to follow these SO posts to help, but they can only create a preset one, I can't figure out how edit all of them so they each have a unique icon:
Any ideas?
here is my code to create the pins/annotations incase anyone is interested:
func mapTheseCoordinates(lat: Double, lng: Double, username: NSString, fullname: NSString) {
let location = CLLocationCoordinate2D(
latitude: lat,
longitude: lng
)
// 2
let span = MKCoordinateSpanMake(0.15, 0.15)
let region = MKCoordinateRegion(center: location, span: span)
mapView.setRegion(region, animated: true)
//3
let annotation = MKPointAnnotation()
annotation.setCoordinate(location)
annotation.title = username
annotation.subtitle = fullname
mapView.addAnnotation(annotation)
}