google maps iOS SDK: custom icons to be used as markers

Here is what I have done let marker = GMSMarker() // I have taken a pin image which is a custom image let markerImage = UIImage(named: “mapMarker”)!.withRenderingMode(.alwaysTemplate) //creating a marker view let markerView = UIImageView(image: markerImage) //changing the tint color of the image markerView.tintColor = UIColor.red marker.position = CLLocationCoordinate2D(latitude: 28.7041, longitude: 77.1025) marker.iconView = markerView … Read more

How to get animated polyline route in GMSMapView, so that it move along with map when map is moved?

SWIFT Declartion var polyline = GMSPolyline() var animationPolyline = GMSPolyline() var path = GMSPath() var animationPath = GMSMutablePath() var i: UInt = 0 var timer: Timer! To Darw Route func drawRoute(routeDict: Dictionary<String, Any>) { let routesArray = routeDict [“routes”] as! NSArray if (routesArray.count > 0) { let routeDict = routesArray[0] as! Dictionary<String, Any> let routeOverviewPolyline … Read more

GoogleMaps without CocoaPods

Sure there is: Immediate answer: https://www.gstatic.com/cpdc/0646cf0bd434ed77-GoogleMaps-1.10.1.tar.gz (Download and unzip it) How did I do it (Useful for any library you need) Go to the pod you need, in this case: https://cocoapods.org/pods/GoogleMaps Click on “See Podspec” link below Library on the bottom right corner You are gonna be taken to the podspec.json At the end of … Read more

Google Maps iOS SDK, Getting Directions between 2 locations

NSString *urlString = [NSString stringWithFormat: @”%@?origin=%f,%f&destination=%f,%f&sensor=true&key=%@”, @”https://maps.googleapis.com/maps/api/directions/json”, mapView.myLocation.coordinate.latitude, mapView.myLocation.coordinate.longitude, destLatitude, destLongitude, @”Your Google Api Key String”]; NSURL *directionsURL = [NSURL URLWithString:urlString]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:directionsURL]; [request startSynchronous]; NSError *error = [request error]; if (!error) { NSString *response = [request responseString]; NSLog(@”%@”,response); NSDictionary *json =[NSJSONSerialization JSONObjectWithData:[request responseData] options:NSJSONReadingMutableContainers error:&error]; GMSPath *path =[GMSPath pathFromEncodedPath:json[@”routes”][0][@”overview_polyline”][@”points”]]; GMSPolyline *singleLine … Read more

Custom annotation view in Google Maps SDK

I don’t know about y’all, but I find Google’s rendered UIView info windows to be a bit restricting. Using SMCalloutView and Ryan Maxwell’s example project, it’s possible to present more interactive views. This works on Google Maps SDK v1.8.1, as of 2014-June-10. First, do some set up: #import <SMCalloutView/SMCalloutView.h> static const CGFloat CalloutYOffset = 10.0f; … Read more