我在kml文件中绘制地图上的叠加层,我存储在我的文档目录中。我一次查看大约30到40 kml文件,线条颜色存储在kml中。问题是其中一些不显示。
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
return [kmlParser viewForOverlay:overlay];
}
上面的代码来自参考KMLViewer,可以从here
下载当我编写下面的代码时,它完全正常,但所有生成的kml文件都使用黑色绘制
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKOverlayPathView *overlayPathView;
if ([overlay isKindOfClass:[MKPolygon class]])
{
overlayPathView = [[MKPolygonView alloc] initWithPolygon:(MKPolygon*)overlay];
overlayPathView.fillColor = [[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0] colorWithAlphaComponent:0.2];
overlayPathView.strokeColor = [[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0] colorWithAlphaComponent:0.7];
overlayPathView.lineWidth = 3;
return overlayPathView;
}
}
任何帮助都会非常值得注意!
感谢。
答案 0 :(得分:1)
boundingMapRect可能是罪魁祸首请检查地图的缩放级别及其boundingmaprect属性