I am trying to place a custom image into a Marker using the following code.
Marker(
coordinate: CLLocationCoordinate2D(
latitude: obj.loc.coordinate.latitude,
longitude: obj.loc.coordinate.longitude),
label: {
Label {
Text(obj.name)
} icon: {
Image(uiImage:imageFor(obj.imgSet, idx: obj.img ))
}
}
)
The image is created from images that are 16 pixels high and have various images that are 16 pixels wide. Thus we compute and offset and then extract an image 16x16 at that offset. The Marker appears, but has a square that is white with in color, and the Label text does not appear on the Marker.
var s_imgs : [UIImage] = [
UIImage(named: "Symbols")!,
UIImage(named: "Symbols2")!
]
func imageFor(_ symSet: Int, idx : Int ) -> UIImage {
let w : Double = 16
let cgimg = s_imgs[symSet]
.cgImage!
.cropping(to: CGRect(
x: w*Double(idx),
y: 0,
width: w,
height: w))!
return UIImage(cgImage: cgimg)
}
What do I need to do in order to have custom images within the Marker? It would be awesome to just have a View there and have the Marker change diameter to accommodate whatever View I needed to construct. Ideally, I just need the image to work, but that image will have a wide range of colors across all the images and thus I need some flexibility to manage background coloring dynamically as well. .tint could mostly work, but I'd like to but a border on the image with some white space inside the boarder before the image starts.