2013-10-22 19 views

回答

2
@IBOutlet weak var mapView: GMSMapView! 

let camera = GMSCameraPosition.cameraWithLatitude(23.0793, longitude: 
72.4957, zoom: 5) 
mapView.camera = camera 
mapView.delegate = self 
mapView.myLocationEnabled = true 

*** arry has dictionary object which has value of Latitude and Longitude. *** 
let path = GMSMutablePath() 

for i in 0..<arry.count { 

    let dict = arry[i] as! [String:AnyObject] 
    let latTemp = dict["latitude"] as! Double 
    let longTemp = dict["longitude"] as! Double 

    let marker = GMSMarker() 
    marker.position = CLLocationCoordinate2D(latitude: latTemp, longitude: longTemp) 
    marker.title = "Austrilia" 
    marker.appearAnimation = kGMSMarkerAnimationNone 
    marker.map = self.mapView 

    path.addCoordinate(CLLocationCoordinate2DMake(latTemp, longTemp)) 

} 

let bounds = GMSCoordinateBounds(path: path) 
self.mapView!.animateWithCameraUpdate(GMSCameraUpdate.fitBounds(bounds, withPadding: 50.0)) 
相關問題