Question

So i've got a google map in a small view on one of my main views, i'm trying to get a badge to show a location, like google show in their example.. But after ages of trying to get the map to show inside a resizable view (so i can display it within another view), the way i've done it doesn't appear to have a way of adding a badge.

This is my code so far:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:6];
// Create marker
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(-33.86, 151.20);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = @"Hello World";


self.map.camera = camera;

self.map being (in the .h file):

@property (weak, nonatomic) IBOutlet GMSMapView *map;

This is google's example:

// Google map
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;

But i seem unable to combine the two

Was it helpful?

Solution

For any one struggling with a similar problem: This is how i solved using a custom view with a google map + badge

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6];
// set camera location to Novi Sad, Serbia :-)

[self.mymap setCamera:camera];     // set the camera to map


// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mymap;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top