Coder Social home page Coder Social logo

svpulsingannotationview's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svpulsingannotationview's Issues

More explanation

Hi

Could you leave us some more explanation on how it is accomplished. From the code I see you are basically rendering 3 halo's with different radius and using Core Animation to animate the size and change the image used. That information is great to display to users of this component. Knowing the animation happens on the GPU is usefull. :)

Request: Allow non-template Images or Access to the ImageView in some way

Correct me if I'm wrong, but whenever an image is set to the SVPulsingAnnotationView, it is set to the private imageView with the UIImageRenderingModeAlwaysTemplate Rendering Mode and uses the annotationColor as the tintColor of that imageView (Lines 152 and 165 of SVPulsingAnnotationView.m as of this commit - 29th July 2015). This means if, for example, the annotation's pulse color was to be the default blue, but the image was a different color, say red, it would always render as blue.

It would be nice if the image could be set to the imageView as the actual image set to that property. Alternatively, as it's already using UIImageRenderingModeAlwaysTemplate as default, a BOOL property could be added to the class such as setImagesAsTemplate which defaults to YES and then wherever images are being added, that Boolean could be used to determine whether to set the image as Template or not. Doing this would mean any previous users wouldn't have to do anything and this issue would be fixed.

I think that #15 (image stays behind the dot) may possibly be referring to this issue but #15 is very vague. I might create a Pull Request with the above proposed changes in the next few days but for now my work around in a subclass is as follows overriding two methods:

- (void)willMoveToSuperview:(UIView *)newSuperview {

    // Set an image so that when it rebuilds the layers it will add the Image View
    self.image = [UIImage imageNamed:@"empty"]; // This is an actual image named empty

    // Call Super which rebuilds the layers and adds the image view because there's an image set to the image property
    [super willMoveToSuperview:newSuperview];

    // Set the image we want
    self.image = [UIImage imageNamed:@"imageWeWant"]; // The image we actually want to set to the imageView

}

- (void)setImage:(UIImage *)image {

    // Call super so that it sets the image
    [super setImage:image];

    // Now we want to set the image to the image view ourselves, as the superclass calls `imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate` on the image
    for (UIView *subview in self.subviews) {
        // Should only be one subview, but make sure it's the image view
        if ([subview isKindOfClass:[UIImageView class]]) {
            // Set the image
            ((UIImageView *)subview).image = image;
            break; // Just incase there are other subviews, we don't care at this point.
        }
    }

}

This sets the image called imageWeWant to the imageView in the setImage: method by scanning the subviews for an imageView and setting that image to the imageView's image property without any other rendering. The setImage: method would get called for the empty image also, though at that point there doesn't seem to be an imageView in the subviews, and instead just allows for the imageView to be added when rebuildLayers is called within the super (SVPulsingAnnotationView) implementation of willMoveToSuperview:.

TL;DR:
The Above Block of code is a workaround for this issue. Will attempt the proposed changes in the second paragraph (not the above block of code) and create a Pull Request soon to hopefully fix the issue.

Hopefully I haven't missed something which is already implemented to help this issue. Let me know :).

Enhancement request - Variable annotation radius

Hey there. First of all thanks a lot for a great library.

This is not a issue per say but a feature request ... I found no way of specifying.

I came across a situation in which i have to resize the circle in regard to gps accuracy... I think there should be a way to be able to update the radius (it shouldn't be hardcoded).

My problem is that i'm using this with a MKCircle and I can't make the two radiouses to coincide. How would you recommend i do this?

I'm using the following to get the current zoom level:

define MERCATOR_RADIUS 85445659.44705395

define MAX_GOOGLE_LEVELS 20

  • (double)getZoomLevel
    {
    CLLocationDegrees longitudeDelta = mapView.region.span.longitudeDelta;
    CGFloat mapWidthInPixels = mapView.frame.size.width;
    double zoomScale = longitudeDelta * MERCATOR_RADIUS * M_PI / (180.0 * mapWidthInPixels);
    double zoomer = zoomScale;
    if ( zoomer < 0 ) zoomer = 0;
    return zoomer;
    }

Possible to add a pulse method?

First of all, this is really awesome and I was not expecting to find something like this, which I actually really wanted! So cheers!

But my main use for this pulsing feature will be to indicate a "pulse" when my app actually updates the location for an annotation. In other words, simply setting it to a repeating animation is of little use as the pulses would be meaningless.

Rather, I am looking to implement a simple [pulse] method that will perform a single pulse animation on command. I am hoping this is possible and that you just didn't think of it, as opposed to there being some intrinsic limitation preventing it.

Any kind of headstart would be appreciated.

Setting Image Using setImage removed the pulse

Hello,

I want to use your animation effect with my custom Image as current location Image.

If I am giving your setImage: call then the pulsing is not seen around my image, Can you advice. I am also using ur Pods as instructed.

Request to add Google Maps iOS SDK support

This great code should be used with Google Maps SDK. You probably don't have time to this. I add this issue so someone (maybe me) could do this some time.
So the one who will implement this should probably use UIView and add it as a subview to the ViewControllers view. This example does it with the SMCalloutView using mapView:didChangeCameraPosition delegate method.
It is possible that GMSMarker can handle CAAnimation though. It has a CALayer but I don't know how to use it yet.

Can't Change Pulse Color On First Try

iOS 9 issue maybe? Some random time after having already set the pulse to green.

[pulse setPulseColor:[UIColor redColor]];
NSLog(@"%@", string);

Never works but I get the NSLog after it every time.

I have no trouble changing just the annotation colors back and forth.

When I try to change both of the colors at the same time I'll only get the annotation change.

In order to get the pulse change I have to change the color an extra time, so my current work around looks like this:

[pulse setAnnotationColor:[UIColor redColor]];
[pulse setPulseColor:[UIColor redColor]];
[pulse setAnnotationColor:[UIColor redColor]];

It's as if the pulse change gets put on the stack, but doesn't get popped off until I change the color.

image stays behind the dot

If I add an image to the SVPulsingAnnotationView is stays behind the dot and as "pulseColor" is no available I cannot set the dot to clearColor

Random Crash while creating pulseAnimationGroup

And a while ago, we notice this bug while opening a map from our app. The app crashes on some random line of code in the following function for creating a animation group.

- (CAAnimationGroup*)pulseAnimationGroup {
    if(!_pulseAnimationGroup) {
        _pulseAnimationGroup = [CAAnimationGroup animation];
        _pulseAnimationGroup.duration = self.outerPulseAnimationDuration + self.delayBetweenPulseCycles;
        _pulseAnimationGroup.repeatCount = INFINITY;
        ... and a lot more settings
    }
}

The problem is probably because this function is used in a secondary thread. Whatever code within if(!_pulseAnimationGroup){ ... } could be executed in different threads concurrently and it may result in some random crashes.

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
    if(self.delayBetweenPulseCycles != INFINITY) {
        CAAnimationGroup *animationGroup = self.pulseAnimationGroup;      
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            [_colorHaloLayer addAnimation:animationGroup forKey:@"pulse"];
        });
    }
});

I am not 100% sure about the comments above. But please fix it if it is the case. But no matter what, it must bug somewhere else if not here.

Changing color as location updates without removing annotation from map?

I love this annotation, but I have a question!

I'm using it in a map based app I'm working on in Swift (I just started developing in Xcode a couple months ago, so I'm unfamiliar with Objective-C), but I want the color of the annotation on the map to change according to speed of a user as the location changes without removing the annotation from the map. The UserLocation pulsing annotation does this if you change the TintColor of the map.

In my code, I'm updating the annotation color as follows. I have a class I created called vehicle where I can access updates to location, etc. of vehicles (these vehicles are not necessarily the user, their info is stored in a database we're accessing). I also created a custom annotation called MGAnnotation that has a property called color that I can change dynamically and vehicle.icon is an instance of it. Finally, I have a function updateColor() which calculates a color using the speed.

vehicle.icon.subtitle = "Speed: \(speed) m/s"
vehicle.icon.color = updateColor(speed)
vehicle.icon.coordinate = last_location
mapView.addAnnotation(vehicle.icon)

In the rendering function I have:

if let annotation = annotation as? MGAnnotation {
let annotationView = SVPulsingAnnotationView(annotation: annotation, reuseIdentifier: "pulse")
annotationView.annotationColor = annotation.color
annotationView.canShowCallout = true
return annotationView
}

In the first block of code, when vehicle.icon.coordinate changes, the annotation changes location on the map accordingly, but the color doesn't update. Is there any easy fix to this that I could make in the SVPulsingAnnotation code?

Thanks!

animation does not restart once the view disappears and then reappers

Great work! I'm going to use it in the next version of my Terremoto app.
One issue I found is haloLayer losing its animations when view disappears and then reappears (not an issue with the library itself, just the way core animation works).
You can expose the private rebuildLayers method so that the view controller using mapkit can call it again from viewDidAppear and on UIApplicationDidBecomeActiveNotification notifications (if view is active)
Regards,
Nico.

Animation got stucking in GoogleMap IconView

` self.userCreatedMarker.groundAnchor = CGPoint(x: 1.0, y: 1.0)

let vwAnno = SVPulsingAnnotationView(annotation: MKMapView().userLocation, reuseIdentifier: "str")
vwAnno.center = view_pin.center
view_pin.addSubview(vwAnno)`

Here is my code.

  • Pulsing effect like ring look like little bit stuck.
    Please help to solve these issue.
    Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.