How to resize the GMSMarker icon in Google Maps for iOS?

I am using the Google Maps SDK in xCode and am trying to scale the marker icon to make it bigger on mapView.

I am trying to do something like this:

marker.icon.scale = 3.0f;

But it gives me:

readonly error value assignment

Obviously, since it is read-only, I cannot write to it.

Therefore, is there an alternative for resizing or scaling a marker icon?

+4
source share
3 answers

If you want to programmatically resize your icon, which is a UIImage, you can implement your own method to resize your UIImage to the desired scale.

.

, , , ( marker.icon ):

marker.icon = [self image:marker.icon scaledToSize:CGSizeMake(3.0f, 3.0f)];
+12

NSData​​p >

NSData *imageData = [NSData dataWithContentsOfFile:imagePath];

API UIImage imageWithData: scale: :

marker.icon = [UIImage imageWithData:imageData scale:2.0];
+3

You can create

CGRect frame = CGRectMake(0, 0, 10, 10);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
imageView.image = [UIImage imageNamed:@"yourImage"];

then assign it to the marker

marker.iconView = imageView;
0
source

Source: https://habr.com/ru/post/1569003/


All Articles