hussain hussain - 1 year ago 111
Swift Question

Change the Size of Marker in GoogleMap using Swift

I have placed a marker in

which contains
. but the size of image is much bigger. so how can i decrease the size of an marker. i have tried this :

marker.icon = self.image(marker.icon, scaledToSize: CGSize(width: 3.0, height: 3.0))

Answer Source

To resize the image refer to :The simplest way to resize an UIImage?

Now the set the resized image as marker icon ,i.e,

marker.icon = self.imageWithImage(image: UIImage(named: "imageName")!, scaledToSize: CGSize(width: 3.0, height: 3.0))


func imageWithImage(image:UIImage, scaledToSize newSize:CGSize) -> UIImage{
    UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0);
    image.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height))
    let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()
    return newImage
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download