Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blinking Custom Markers In Google maps iOS

I have placed 6 custom markers with the same coordinates in google maps iOS SDK. Those markers are continuously blinking/Toggling. I don't want blinking animation at all. Please help me.

Here is my Source Code.

-(void)loadPlacesInMapWithIndex:(int)index{

    for (int i = 0; i < [[[SearchManager sharedInstance]searchedStallArray] count]; i++) {
        Stall *stall = [[[SearchManager sharedInstance]searchedStallArray] objectAtIndex:i];

        // Creates a marker in the center of the map.
        GMSMarker *marker = [[GMSMarker alloc] init];
        marker.position = CLLocationCoordinate2DMake([stall.stallLatitude doubleValue],[stall.stallLongitude doubleValue]);
        marker.infoWindowAnchor = CGPointMake(0.44f, -0.07f);
        marker.userData = stall;
        marker.tappable = YES;
        self.infoView = [[[NSBundle mainBundle]loadNibNamed:@"StallInfoWindow" owner:self options:nil] objectAtIndex:0];

        marker.iconView = self.infoView;
        if (index == i) {
            [self.infoView.stallPinImageView setImage:[UIImage imageNamed:@"RateLabel.png"]];
            [self.infoView.stallPriceLabel setTextColor:[UIColor whiteColor]];

            CGFloat currentZoom = self.stallsMapView.camera.zoom;
            [CATransaction begin];
            [CATransaction setValue:[NSNumber numberWithFloat: 0.5f] forKey:kCATransactionAnimationDuration];
            [self.stallsMapView animateToCameraPosition:[GMSCameraPosition
                                                          cameraWithLatitude:[stall.stallLatitude doubleValue]
                                                          longitude:[stall.stallLongitude doubleValue]
                                                          zoom:currentZoom]];
            [CATransaction setCompletionBlock:^{
            }];
            [CATransaction commit];

        }else{
            [self.infoView.stallPinImageView setImage:[UIImage imageNamed:@"horse.png"]];
            [self.infoView.stallPriceLabel setTextColor:[UIColor redColor]];
        }

        self.infoView.stallPriceLabel.text = [NSString stringWithFormat:@"$%@",stall.stallPrice];

        marker.map = self.stallsMapView;
    }
}
like image 943
Raghu Bujji Avatar asked Sep 16 '16 08:09

Raghu Bujji


People also ask

Can you change markers on Google Maps?

Click on the option labeled Tools and then click on Change map. Once there, click on the button labeled Change feature styles. There are plenty of options for changing the different styles of your markers, which includes changing their color.

How do I make a custom marker map?

Create Custom Maps using Google MapsClick on the “Your Places” option in the menu. Click on the “Maps” Tab in the top right. Click on the “CREATE MAP” link at the bottom of the menu. Once you are on the map creation page, click the marker icon to add a marker to the page.


1 Answers

You have to provide them diffrent zIndex property. This property defines which marker is on the top of stack. The highest numbers are on top.

For your code, insert under:

 marker.tappable = YES;

this line of code:

 marker.zIndex = (UInt32)i
like image 108
B2D Avatar answered Sep 21 '22 03:09

B2D