I would appreciate some help for my problem, I am creating a view called mapView and have changed its class to GMSMapView. But when I assign the map to this mapView, the layout is perfectly fine but the camera is set to Europe by default, which does not change.
Following is the code:
@IBOutlet weak var mapView: GMSMapView!
var latitudes = [19.199782,19.19855,19.199179]
var longitudes = [72.8734634,72.872935, 72.874535]
var titles = ["Riviera","Alica","Senate"]
var subTitle = ["1","2","3"]
override func viewDidLoad() {
super.viewDidLoad()
let camera = GMSCameraPosition.camera(withLatitude: 19.20060, longitude: 72.8734462, zoom: 15.0)
let mapView1 = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
let path = GMSMutablePath()
for i in 0...2
{
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: latitudes[i], longitude: longitudes[i])
marker.title = titles[i]
marker.snippet = subTitle[i]
marker.map = mapView1
path.add(CLLocationCoordinate2D(latitude: latitudes[i], longitude: longitudes[i]))
}
let polyLine = GMSPolyline(path: path)
polyLine.map = mapView1
mapView = mapView1
mapView.camera = camera
}
The output for the code is: Output
When I add the map to view I get the desired map
modification to above code: instead of mapView = mapView1 put view = mapView1
Desired output:Desired Output
So please help me getting the desired output in the mapView view of my screen. Thank You!