GMSMapStyle unresolved identifier

≯℡__Kan透↙ 提交于 2020-04-13 04:39:43

问题


I want to change my google map style in ios. For that I am trying to implement this code. GMSMapStyle

I am importing import GoogleMaps. But I am getting this error Use of unresolved identifier GMSMapStyle. Can anybody help me to which module I have to import to avoid this error. Thanks in advance


回答1:


While updating an app, I was getting a similar error but with mapType:

'Use of unresolved identifier 'kGMSTypeTerrain' with the following code:

  @IBOutlet weak var googleMapView: GMSMapView!
  googleMapView.mapType = kGMSTypeTerrain

Took me a couple of days to resolve this item. I thought I had an issue with my GoogleMaps IOS api so did a cocoa pod install (when I should of done a pod update) but it did not fix the issue. I finally came across the issue noted above with mapStyle. As it turns out, with Swift 3,

googleMapView.mapType = kGMSTypeTerrain  

should be changed to

googleMapView.mapType = .terrain 

Likewise for the other map types.




回答2:


The problem is that I was trying to implement this code in GoogleMapSDK version 2.0.1. But it is available from 2.1.0.




回答3:


Use this that:

example:

let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.mapType = GMSMapViewType.terrain



回答4:


In older version also you can add map style by the following method

let mapView = GMSMapView.map(withFrame: .zero, camera: camera)
    // Available map types: kGMSTypeNormal, kGMSTypeSatellite,kGMSTypeHybrid,
    // kGMSTypeTerrain, kGMSTypeNone
    // Set the mapType to Satellite
    mapView.mapType = kGMSTypeSatellite
    view = mapView


来源:https://stackoverflow.com/questions/39855951/gmsmapstyle-unresolved-identifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!