Custom myLocationButton Google maps iOS SKD - ios

Is there one way to customize myLocationButton GoogleMaps ? I want to add my own button with a background image which make the same function as the original Google button

First your Application needs to get current location using CLLocation Manager. If you don't know how, refer to my answer here : For google maps iOS sdk, current location occasionally gets plotted at 0,0
Now for button press action, do this
- (void)locationButtonPressed
{
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:self.mapView.myLocation.coordinate.latitude
longitude:self.mapView.myLocation.coordinate.longitude
zoom:self.mapView.camera.zoom];
[self.gMapView animateToCameraPosition:camera];
}
Hope that helps.

Related

"My location button" in google map disappeared

I'am trying to add a view to google map which both have been created using the storyboard. In order to do this, I've changed this part of the code:
mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
to this:
mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
self.mapView.myLocationEnabled = YES;
[self.view insertSubview:mapView atIndex:0];
it works, but the default "My location button" disappeared after this. Is there a way to get back the default button? I would greatly appreciate any help.
I tried this solution My location button not appearing in view (Google maps SDK, ios)
but it didn't work or maybe I didn't get it correctly, if this is the only solution could you please explain it in details?
I got around this problem by creating a button from the storyboard and connect it to this action.
- (IBAction)MyLocation:(id)sender {
CLLocation *location = mapView.myLocation;
if (location) {
[mapView animateToLocation:location.coordinate];
} }
In my case, if I place the created button on the lower right/left corner still can't get it but everywhere else is just fine. (I don't know why I think because of inserting the map at index 0 or something like that).
Are you requesting access to location services correctly? It's done a bit different in iOS 8. Try adding the following to you Info.plist file and let me know if it works:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your message to request location usage permission goes here</string>

How does WatchKit handle multiple map annotations on the same map?

In WatchKit, the documentation for WKInterfaceMap specify that:
"Tapping the map launches the Maps app on the user’s Apple Watch and
displays the corresponding location.
However: I want to show multiple map annotations on the map - is there a way to specify which map annotation will be displayed in Maps.app when the map is tapped?
There is currently no visibility as to exactly what happens when Apple Watch transitions from a WKInterfaceMap to Apple's native Maps application.
Try the WatchKit Developer Forums, exactly the right place for this question!
Currently in WatchOS 2 (at least), tapping on a WKInterfaceMap will open up the Watch's Maps app with the option the get directions to the location that was at the centre point of your WKInterfaceMap. When viewing these directions to this location it will be marked with a Red Pin annotation.
None of your custom annotations will be displayed in the Watch's Maps app.
You can use following methods to add multiple annotations. As per Apple documentation, currently only 5 annotations can be displayed on watch app's map
addAnnotation:withPinColor
addAnnotation:withImageNamed:centerOffset:
addAnnotation:withPinColor:
Here is a sample code, which displays 2 annotations:
CLLocationCoordinate2D mapLocation1 = CLLocationCoordinate2DMake(37.787730, -122.403370);
CLLocationCoordinate2D mapLocation2 = CLLocationCoordinate2DMake(37.794873, -122.397892);
//
MKCoordinateSpan coordinateSpan = MKCoordinateSpanMake(0.1, 0.1);
// Other colors include red and green pins
[self.map addAnnotation:mapLocation1 withPinColor: WKInterfaceMapPinColorPurple];
[self.map addAnnotation:mapLocation2 withPinColor: WKInterfaceMapPinColorRed];
[self.map setRegion:(MKCoordinateRegionMake(mapLocation, coordinateSpan))];

blue arrow in gmsmapview won't update whichever way i am facing

I am using google map SDK 1.9.1. And i have to display blue arrow at direction which ever direction i am facing. but In new SDK i am not find any property to enable it. In old SDK it display that arrow but in new SDK it don't display that arrow
#pragma mark
#pragma mark - setup the google map
-(void) setupMap
{
GMSMapView *mapView = [[GMSMapView alloc] init];
mapView.delegate = self;
[mapView setMyLocationEnabled:YES];
[mapView.settings setCompassButton:YES];
[mapView.settings setMyLocationButton:YES];
[[self getGoogleMapView] addSubview:mapView];
}
Edited
hi after some research i found that direction is not display in ipod only but if you used google map in iphone it display direction arrow.
The reason being that was a part of sensor parameter in the Direction API which is now Deprecated in all Google Maps Display.
Read the official Google Documentation. Scroll Down to the bottom of page and you will see that.

How to display a MKMapView without street names?

I need to display a map without street names. is it possible using MKMapView ? if not, is there a different map API for iOs that supports this?
thanks,
Nimrod
What you need to do, is to set the maptype to Satellite.
Here's how to do this:
[mapView setMapType:MKMapTypeSatellite];
EDIT:
Not sure if it's satellite, but try one of these:
[mapView setMapType:MKMapTypeStandard];
[mapView setMapType:MKMapTypeHybrid];
[mapView setMapType:MKMapTypeSatellite];
Nimrod, you can't show the map view hiding the street name, only showing the Satellite view. However, check the Google Maps SDK - they just launched it and they provide a lot of thinks that the default MKMapView don't provide.
The MapBox iOS SDK will allow you to customize your map completely, including removing street names, but with MapKit-like functionality.
If you prefer, you can use the Google Maps SDK and make a custom map in this link:
http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html?utm_medium=twitter
And then use the atributes generated in this to custom your map in the app.

How to apply animations to GMSMarker

I’m changing my app by migrating iOS maps to google maps using Google Maps SDK for iOS V1.1.0 and I’m trying to animate the markers while adding/removing but I didn’t find any suggestions in the documentation related to this, Please suggest me how to perform the animations on GMSMarkers
In the GMSMarker Class Reference, it says, for the appearAnimation property:
Controls the animation used when this marker is placed on a GMSMapView (default kGMSMarkerAnimationNone, no animation).
Using the Google Maps SDK for iOS, a marker can be made like this:
GMSMarker *startMarker = [GMSMarker markerWithPosition:#"NYC"];
startMarker.appearAnimation = kGMSMarkerAnimationPop;
startMarker.title = #"Start";
startMarker.snippet = #"My address";
startMarker.map = mapView;

Resources