我无法找到以高分辨率在地图上获取自定义图片图像的方法。 (我说的是MapBox iOS SDK)。
通常,当UIImage大小等于* .png大小时,这可能发生在Xcode中。我已经尝试准备3x scaled * .png文件并调整我的UIImage对象的大小,但仍然在屏幕上获得低分辨率图像。有什么想法吗?
Mapbox SDK for iOS版本4.0.2
当我以前使用标准库MapKit时,相同的图像工作正常(以高分辨率显示)。
解!!!
我能够在以下问题后解决问题:
MapBox iOS ImageFor注释方法的完整示例代码是:
func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? {
var reuseIdentifier = annotation.title!
// For better performance, always try to reuse existing annotations.
var annotationImage = mapView.dequeueReusableAnnotationImage(withIdentifier: reuseIdentifier! )
let img = UIImage(named:"pinCustom.png") {
let scaledUpImage = UIImage(cgImage: img.cgImage!, scale: 3.0, orientation: .up)
annotationImage = MGLAnnotationImage(image: scaledUpImage, reuseIdentifier: reuseIdentifier! )
return annotationImage
}