I want to incorporate Google Places API in my projects and I want to edit the markers that the Google Places API provides for you. Here is a link displaying how the API works: https://developers.google.com/places/ios/placepicker. However, I want to be able to edit the red markers and change them to other types of images as opposed to having them as the built-in markers that Google has provided. The reason I see this is possible is because I looked at https://developers.google.com/maps/showcase/#ios and found that the project Foodspotter has changed the markers into those of different images. Would there be a way to edit the Places API to do this or would I have to do something like https://developers.google.com/maps/documentation/ios/marker to change the appearance of the markers? Thanks!
Edit: My Attempt:
@IBAction func pickPlace(sender: UIButton) {
let center = CLLocationCoordinate2DMake(locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude)
let northEast = CLLocationCoordinate2DMake(center.latitude + 0.001, center.longitude + 0.001)
let southWest = CLLocationCoordinate2DMake(center.latitude - 0.001, center.longitude - 0.001)
let viewport = GMSCoordinateBounds(coordinate: northEast, coordinate: southWest)
let config = GMSPlacePickerConfig(viewport: viewport)
var camera = GMSCameraPosition.cameraWithLatitude(locationManager.location.coordinate.latitude,
longitude: locationManager.location.coordinate.longitude, zoom: 6)
var mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
mapView.myLocationEnabled = true
self.view = mapView
println("Going into place picker")
placePicker?.pickPlaceWithCallback({ (place: GMSPlace?, error: NSError?) -> Void in
println("Inside Callback")
if let error = error {
println("Pick Place error: \(error.localizedDescription)")
return
}
if let place = place {
self.nameLabel.text = place.name
self.addressLabel.text = "\n".join(place.formattedAddress.componentsSeparatedByString(", "))
var marker: GMSMarker = GMSMarker(position: self.locationManager.location.coordinate)
marker.position = place.coordinate
marker.title = place.name
marker.snippet = place.formattedAddress
marker.map = mapView;
marker.icon = UIImage(contentsOfFile: "test")
//marker.icon = [UIImage imageNamed:@"marker"];
var cameraView = GMSCameraPosition.cameraWithLatitude(marker.position.latitude, longitude: marker.position.longitude, zoom: 6)
mapView.animateToCameraPosition(cameraView)
} else {
self.nameLabel.text = "No place selected"
self.addressLabel.text = ""
}
})
}