我有多目标应用程序,他们必须使用谷歌地图我决定创建可可触摸框架并添加所有谷歌地图依赖项并创建一个笔尖来显示谷歌地图。这项工作成功,我可以重用该项目中的nib文件嵌入我的框架,我可以在地图上显示用户当前位置,但我需要实现GMSMapViewDelegate来检测地图移动时,但当实现GMSMapViewDelegate我得到以下错误:
ld:框架未找到架构arm64的GoogleMaps clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
这是我的nib文件类
import UIKit
import GoogleMaps
class GoogleMapView: UIView,MyLocationManagerDelegate,GMSMapViewDelegate {
let marker = GMSMarker()
@IBOutlet weak var geoCodeAddressTxtfield: UITextField!
@IBOutlet var mapView: GMSMapView!
public var geoAddresshandler :((_ lat :CLLocationDegrees, _ long :CLLocationDegrees) -> Void)?
private let nibName :String = "GoogleMapXib"
let locationManager = MyLocationManager()
public override init(frame : CGRect){
super.init(frame: frame)
setup()
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
locationManager.delegate = self
setup()
}
func getLocationCordination(long: CLLocationDegrees, lat: CLLocationDegrees) {
let camera = GMSCameraPosition.camera(withLatitude: lat, longitude: long, zoom: 17)
mapView.camera = camera
mapView.animate(to: camera)
mapView.isMyLocationEnabled = true
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: lat, longitude: long)
marker.map = mapView
}
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
print("You tapped at \(coordinate.latitude), \(coordinate.longitude)")
}
private func setup(){
self.mapView = UINib(nibName: nibName, bundle: Bundle(for: type(of: self))).instantiate(withOwner: self, options: nil)[0] as! GMSMapView
self.mapView.frame = bounds
self.mapView.autoresizingMask = [.flexibleWidth , .flexibleHeight]
self.addSubview(self.mapView)
self.geoCodeAddressTxtfield.becomeFirstResponder()
mapView.bringSubview(toFront: self.geoCodeAddressTxtfield)
}
func mapView(mapView: GMSMapView!, didTapAtCoordinate coordinate: CLLocationCoordinate2D) {
}
func mapView(_ mapView: GMSMapView, willMove gesture: Bool){
mapView.hideKeyboardWhenTappedAround()
}
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition){}
}