GMSMarker does not appear in 1.3

I updated my application to use the Google Maps iOS SDK 1.3. Everything seems to work, except for GMSMarkers. They either do not appear, or appear with the wrong image. They still respond to touch and can be moved, but are otherwise invisible or damaged.

Here is the code to add GMSMarkers:

playerAnnotation = [[CustomPlayerAnnotation markerWithPosition:coord] retain]; [playerAnnotation setType:ANNOTATION_PLAYER]; [playerAnnotation setIcon:[UIImage imageNamed:@"Icon-72.png"]]; [playerAnnotation setGroundAnchor:ccp(.5f, .5f)]; [playerAnnotation setAnimated:NO]; [playerAnnotation setTappable:YES]; [playerAnnotation setTitle:@"Player"]; [playerAnnotation setMap:gameMapView]; GMSMarker* test = [[GMSMarker markerWithPosition:gameMapView.myLocation.coordinate] retain]; [test setIcon:[UIImage imageNamed:@"Icon-72.png"]]; [test setGroundAnchor:ccp(.5f, .5f)]; [test setAnimated:NO]; [test setTappable:YES]; [test setTitle:@"Player"]; [test setMap:gameMapView]; 

And CustomPlayerAnnotation is just a GMSMarker with some additional variables:

 @interface CustomPlayerAnnotation : GMSMarker { AnnotationType type; int tag; struct CoordinatePair coordinatePair; } 

Map with CustomPlayerAnnotation and GMSMarker test:

Map with markers

I have a large number of ground overlays, and the removal of overlays made by the marker reappears, but some still have odd images that do not display properly. It works fine in 1.2.2, but not 1.3.

Does anyone have a way around markers? Does anyone else see this behavior in GMSMarkers?

Other information: the application uses cocos2d 2.0, the director stops before loading the map, and GMSMapView is added as follows:

 UIWindow* window = [(ProjectFusionAppDelegate*)[[UIApplication sharedApplication] delegate] window]; [[[window subviews] objectAtIndex:0] addSubview:gameMapView]; 
+4
source share
3 answers

There seems to be a bug on the Google side. I just stopped using my CustomPlayerAnnotation or GMSMarker and instead used GMSGroundOverlay. It appeared on the map. Then, instead of using the type, tag, and pair coordinates built into CustomPlayerAnnotation, I simply relied on the header.

 playerAnnotation = [[GMSGroundOverlay groundOverlayWithPosition:coord icon:[UIImage imageNamed:@"Down1.png"]] retain]; [playerAnnotation setZoomLevel:zoomLevel]; [playerAnnotation setAnchor:ccp(.5f, 1)]; [playerAnnotation setTitle:@"Player"]; [playerAnnotation setMap:gameMapView]; 

Note: please note that I had to install Anchor: ccp (.5f, 1). When it was set to (.5f, .5f), the playerโ€™s overlay override will overlap the bottom of the overlay while overlapping other GMSGroundOverlays. An anchor change fixed pattern z. It seems that 1.4, which has just been released, may have a fixed order of z, but 1.4 has broken something else on mine, so I will stick with version 1.3.1.

0
source

Make sure you first create the map object in the view with the camera position, then add GMSMarker (s). I created my markers and added them to the map. Nothing appeared, turned the logic around, and everything shows as expected. My project uses ARC FYI.

 - (void)loadView { // Create a GMSCameraPosition that tells the map to display the // coordinates at zoom level 12. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:43.071482 longitude:-70.749856 zoom:12]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; self.view = mapView_; // Creates a marker in the center of the map, make sure the mapView_ is created, and // has the camera position set. GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake(43.071482, -70.749856); marker.title = @"Portsmouth"; marker.snippet = @"New Hampshire"; marker.map = mapView_; 

}

0
source

Set edges for an image before setting it to mapview

 var icon : UIImage = UIImage(named: "userLocation")! icon = icon.imageWithAlignmentRectInsets(UIEdgeInsetsMake(-(icon.size.height/2), -(icon.size.width/2), 0, 0)) marker.icon = icon marker.map = GoogleMapView 
0
source

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


All Articles