开发者社区> 问答> 正文

Google-Maps-iOS-Utils中的GMUGeometryRenender忽略kml样式

新的和iOS(Android开发者.)。我试图使用iOSAPI将KML层覆盖到GoogleMap上。我使用了最新版本的谷歌地图和谷歌地图-iOS-Utils。KML特性呈现得很好,但是样式却被忽略了。我正在使用GitHub的Utils代码提供的KML_Sample.kml文件(这包含Googleplex上的彩色多边形-我检查了示例kml文件是否在网上正确呈现)。任何帮助都将不胜感激,因为我不知道问题出在哪里。下面是一个代码片段:

导入UIKit导入GoogleMaps

类MapViewController:UIViewController{

var mapView:GMSMapView = GMSMapView()

override func loadView() {

    let camera = GMSCameraPosition.camera(withLatitude: 37.42, longitude: -122.084, zoom: 13.0)
    mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)

    view = mapView
}

override func viewDidLoad() {
    super.viewDidLoad()

    let path = Bundle.main.path(forResource: "KML_Sample", ofType: "kml")
    let url = URL(fileURLWithPath: path!)
    let kmlParser = GMUKMLParser(url: url)
    kmlParser.parse()

    let renderer = GMUGeometryRenderer(map: mapView,geometries: kmlParser.placemarks,styles: kmlParser.styles)

    //the following line produces the same kml rendering on the google map - so styles are being ignored above :(
    //let renderer = GMUGeometryRenderer(map: mapView,geometries: kmlParser.placemarks)

    renderer.render()

    //add marker
    let position = CLLocationCoordinate2D(latitude: 37.42, longitude: -122.084)
    let marker = GMSMarker(position: position)
    marker.title = "Hello World"
    marker.map = mapView        
}

所显示的图像如下(多边形应该是彩色的,而不是默认的):

https://i.stack.imgur.com/vVyVD.png

展开
收起
游客5akardh5cojhg 2019-12-16 21:26:44 661 0
0 条回答
写回答
取消 提交回答
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载