新的和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
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。