首页 > 解决方案 > 谷歌地图显示肤色屏幕

问题描述

它获取当前位置但未在屏幕上显示,而是显示此

  1. 查看didload方法

    override func viewDidLoad() {
        super.viewDidLoad()
      selectedAdressType = "pickup"
    
        mapV.delegate = self
       styleOfMap()
       mapV.settings.myLocationButton = true
        mapV.isMyLocationEnabled = true
     //   self.pickupAddressTxtF.setLeftPaddingPoints(7)
        //self.destinationAddressTxtF.setLeftPaddingPoints(7)
        googleLocationTableV.rowHeight = UITableViewAutomaticDimension
        googleLocationTableV.estimatedRowHeight = 50
        googleLocationTableV.tableFooterView = UIView(frame: .zero)
        savedLocationTableV.keyboardDismissMode = .interactive
        googleLocationTableV.keyboardDismissMode = .interactive
    
        // Add footer for set pinn location
        googleLocationTableV.tableFooterView = AddFooterView()
        savedLocationTableV.tableFooterView = AddFooterView()
        redirectMap(to: Double("\(latitude)") ?? 0.0, lng: Double("\(longitude)") ?? 0.0)
    
        let userDefaults = UserDefaults.standard
        if userDefaults.object(forKey: "LocationInitialData") != nil {
    
            let retriveArrayData = UserDefaults.standard.object(forKey:  "LocationInitialData") as? NSData
    
            let dataDic = (NSKeyedUnarchiver.unarchiveObject(with: retriveArrayData! as Data) as? NSDictionary)
            print(" saved response = \(dataDic!)")
    
            self.recentSerchList = dataDic?.value(forKey: "recent_search")as! NSArray
            self.savedLocationList = dataDic?.value(forKey: "save_address")as! NSArray
    
            self.savedLocationTableV.reloadData()
        }
        savedLocationTableV.keyboardDismissMode = .onDrag
        googleLocationTableV.keyboardDismissMode = .onDrag
      //  addressSerachApiCall()
        if Language.isRTL {
            pickupAddressTxtF.textAlignment = .right
        }
    
    }
    
  2. 重定向方法

    func redirectMap(to lat: Double, lng: Double) {
        // [_mapView clear];
        let position: CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat, lng)
        let camera = GMSCameraPosition(target: position, zoom: 16, bearing: 0, viewingAngle: 0)
        mapV.animate(to: camera)
    }
    
  3. 地图样式显示“无法找到 style.json”

       func styleOfMap()  {
            do {
                if let styleURL = Bundle.main.url(forResource: "style", withExtension: "json") {
                    mapV.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
                } else {
                    NSLog("Unable to find style.json")
                }
            } catch {
                NSLog("One or more of the map styles failed to load. \(error)")
            }
        }
    

标签: iosswiftgoogle-maps-sdk-ios

解决方案


推荐阅读