Custom Map Annotation is blurry

627 Views Asked by At

Hi I have created a custom annotation in Sketch 3 and when I scale it down to fit into the map view it becomes blurry. How do I fix this?

2

There are 2 best solutions below

3
On BEST ANSWER

You could try to set the filtering Mode of your Node texture to .Nearest

 let nodeTexture = SKTexture(imageNamed: "node")
 nodeTexture.filteringMode = .Nearest
 node = SKSpriteNode(texture: nodeTexture)
1
On

I was having trouble with this too. Maybe this might help other people though, as you seem to have found a suitable solution.

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
    let reuseId = "id"
    var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
    if anView == nil {
        anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
        anView!.canShowCallout = true
    }
    else {
        anView!.annotation = annotation
    }

    anView!.image = yourFullSizeImage
    anView!.frame.size = CGSize(width: 50, height: 50) //Resize frame AFTER setting image, for me resizing frame first did not work

    return anView
}