You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Replace MGLAnnotation image on didSelectAnnotation: #2210
@hshah2811 That (#1688) is of a class of bug/enhancement we are trying to get into this week's release, but it may not quite make it. Stay tuned — on a short timeline.
@RomainQuidet Could you give me an example how to change an image(MGLAnnotationImage) for selected annotation in didSelectAnnotation? I can't figure out ...
Thank you in advance.
@RomainQuidet Thank you very much!
Just one question: How do you define annotationImages ?
I do like this : var annotationImages = [String:MGLAnnotationImage]() also tried var annotationImages = [String:AnuObject]() but I can't call objectForKey
I tried like that : annotationImages["\(annotation.title!!)"]?.image = UIImage(named: "selectedPin")! in didSelectAnnotation but in this case all annotations change images...
@minikin MGLAnnotationImages are objects in the mapBox SDK with a designated initializer + (instancetype)annotationImageWithImage:(UIImage *)image reuseIdentifier:(NSString *)reuseIdentifier;
(in ObjC)
@RomainQuidet Thank you.
If I understand you correctly I need to do like this:
let annotationImage = self.mapView.dequeueReusableAnnotationImageWithIdentifier("nonSelectedImage")
let annoImage = annotationImage?.valueForKey(annotation.title!!) as! MGLAnnotationImage
annoImage.image = UIImage(named: "selectedPin")!
I have an error :
[< UIImage 0x7f91060f0cd0 > valueForUndefinedKey:]: this class is not key value coding-compliant for the key Antalia.
objc[54908]: pthread_rwlock_rdlock failed (11)
I am still facing an issue trying to change an annotation image on the fly (without removing and adding all annotations).
I create a dictionary of annotation titles to annotations - [String : MGLAnnotationImage] var annotationsTitlesAndImages: [String:MGLAnnotationImage] = [:]
I populate this dictionary with all my MGLAnnotationImages within the imageForAnnotation function
replacing the image property of annotationImage should do the job. But I've seen yesterday an error saying {Map}[Sprite]: Can't change sprite dimensions for 'com.mapbox.sprites.4'
@alexagat@Ramshandilya, if setting the MGLAnnotationImage’s image property doesn’t work following #3146, it definitely should work following #3835 (which no longer causes the annotation to be removed and readded). Please try it out in the v3.3.0 alphas and let us know if it isn’t working as expected. Thanks!
Activity
incanus commentedon Sep 1, 2015
This will rely on #1688.
incanus commentedon Sep 1, 2015
Refs #1980
hshah2811 commentedon Sep 8, 2015
May i know when can we expect this fix?
incanus commentedon Sep 8, 2015
@hshah2811 That (#1688) is of a class of bug/enhancement we are trying to get into this week's release, but it may not quite make it. Stay tuned — on a short timeline.
minikin commentedon Oct 29, 2015
I also looking forward to fix this bug/enhancement. Thank you.
RomainQuidet commentedon Nov 26, 2015
FYI I'm working on it. Will send a pull request soon
RomainQuidet commentedon Nov 30, 2015
Code is working, cleaning up and pull request coming soon
RomainQuidet commentedon Nov 30, 2015
Pull request sent : (#3146)
Just get your annotationImage and update the image property
friedbunny commentedon Jan 14, 2016
Fixed by #3146.
minikin commentedon Feb 22, 2016
@RomainQuidet Could you give me an example how to change an image(MGLAnnotationImage) for selected annotation in didSelectAnnotation? I can't figure out ...
Thank you in advance.
RomainQuidet commentedon Feb 23, 2016
@minikin : I'm doing this on my sample
minikin commentedon Feb 23, 2016
@RomainQuidet Thank you very much!
Just one question: How do you define annotationImages ?
I do like this :
var annotationImages = [String:MGLAnnotationImage]()also triedvar annotationImages = [String:AnuObject]()but I can't callobjectForKeyI tried like that :
annotationImages["\(annotation.title!!)"]?.image = UIImage(named: "selectedPin")!indidSelectAnnotationbut in this case all annotations change images...I would appreciate any advice. Thanks.
RomainQuidet commentedon Feb 23, 2016
@minikin MGLAnnotationImages are objects in the mapBox SDK with a designated initializer
+ (instancetype)annotationImageWithImage:(UIImage *)image reuseIdentifier:(NSString *)reuseIdentifier;(in ObjC)
minikin commentedon Feb 23, 2016
@RomainQuidet Thank you.
If I understand you correctly I need to do like this:
I have an error :
ps:
annotation.title!!- looks weirdminikin commentedon Feb 23, 2016
@1ec5 maybe you can help me? Thanks!
1ec5 commentedon Feb 23, 2016
@minikin, please contact our Support staff, and we’d be happy to assist you further.
alexagat commentedon Mar 31, 2016
I am still facing an issue trying to change an annotation image on the fly (without removing and adding all annotations).
I create a dictionary of annotation titles to annotations -
[String : MGLAnnotationImage]var annotationsTitlesAndImages: [String:MGLAnnotationImage] = [:]I populate this dictionary with all my MGLAnnotationImages within the
imageForAnnotationfunctionI try and update the annotation's image in the
didSelectAnnotationfunctionWith a breakpoint set on the
annotationsTitlesAndImages[annotation.title!!]!.imageline above, I see this code in the framework being run:...but the image doesn't update.
Any insight?
RomainQuidet commentedon Mar 31, 2016
replacing the image property of annotationImage should do the job. But I've seen yesterday an error saying
{Map}[Sprite]: Can't change sprite dimensions for 'com.mapbox.sprites.4'I'll check that.
Ramshandilya commentedon May 25, 2016
@alexagat Were you able to find a way to change image of an annotation? (without removing & adding)
1ec5 commentedon May 25, 2016
@alexagat @Ramshandilya, if setting the MGLAnnotationImage’s
imageproperty doesn’t work following #3146, it definitely should work following #3835 (which no longer causes the annotation to be removed and readded). Please try it out in the v3.3.0 alphas and let us know if it isn’t working as expected. Thanks!