1

我想绘制一个带有图像的 GMSPolygon 或裁剪 GMSGroundOverlay 的图像。

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:48.774052
                                                            longitude:-110.375980
                                                                 zoom:0];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;

GMSMutablePath *shapePath = [[GMSMutablePath alloc] init];
[shapePath addLatitude:48.774052 longitude:-110.375980];
[shapePath addLatitude:40.676195 longitude:-123.911136];
[shapePath addLatitude:33.682907 longitude:-101.762699];

/*** **/
GMSCoordinateBounds *overlayBounds = [[GMSCoordinateBounds alloc] initWithPath:shapePath];

UIImage *icon = [UIImage imageNamed:@"usaimages.jpg"];
GMSGroundOverlay *overlay =
[GMSGroundOverlay groundOverlayWithBounds:overlayBounds icon:icon];
overlay.bearing = 0;
overlay.map = mapView_;
    /*** **/

GMSPolygon *shape = [GMSPolygon polygonWithPath:shapePath];
shape.strokeWidth= 2;
shape.title=@"xx";
shape.fillColor= [UIColor redColor];
//shape.strokeColor= [UIColor brownColor];
shape.map=mapView_;

self.view = mapView_;
mapView_.delegate=self;

现在这就是我所看到的:

在此处输入图像描述

这就是我想看到的:

在此处输入图像描述

我想将标志放入 GMSPolygon 或通过裁剪 GMSGroundOverlay 的图标获得相同的结果。我不知道这是可能的,也不知道我怎么能做到。

4

1 回答 1

2

先裁剪图像然后使用。我建议使用 Gmsgroundoverlay,因为你将对图像有很多控制。比如调整角度、旋转等

于 2015-03-23T11:43:36.890 回答