我使用的是Google Maps API,但有几个问题。我想这样做是为了让我现在的用户在每个方向只能看到离他们家乡10英里的距离。
我已经显示了用户家庭地址。我只需要知道如何制作它,以便它只显示地图中10英里的有限区域。
这是我显示用户家庭住址的方式:
func getCurrentUsersHomeAddress() {
let userID = currentUser?.uid
ref.child("users").child(userID!).observeSingleEventOfType(.Value, withBlock: { (snapshot) in
// Get user value
let username = snapshot.value!["fullName"] as! String
let homeAddress = snapshot.value!["homeAddress"] as! [Double]
let email = snapshot.value!["email"] as! String
let lat = homeAddress[0] as Double
let long = homeAddress[1] as Double
let coords = CLLocationCoordinate2D(latitude: lat as CLLocationDegrees, longitude: long as CLLocationDegrees)
self.mapView.camera = GMSCameraPosition(target: coords, zoom: 15, bearing: 0, viewingAngle: 0)
let marker = GMSMarker(position: coords)
请记住,我只想显示10英里的地图。任何帮助将不胜感激。