带有UIImage的GMSPolygon或GMSGroundOverlay

时间:2015-03-06 16:59:01

标签: ios google-maps-sdk-ios gmsgroundoverlay

我想在其中绘制带有图像的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;

现在这就是我所看到的:

enter image description here

这就是我想看到的:

enter image description here

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

1 个答案:

答案 0 :(得分:2)

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