Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I saw your issue <a href="https://code.google.com/p/gmaps-api-issues/issues/detail?id=5107&amp;q=visibleRegion&amp;colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Stars%20ApiType%20Internal" rel="noreferrer">here</a>. Hope that they fix this issue in next update.</p> <p>But now we can take the real visible region like this:</p> <pre><code> CGPoint topLeftPoint = CGPointMake(0, 0); CLLocationCoordinate2D topLeftLocation = [_mapView.projection coordinateForPoint: topLeftPoint]; CGPoint bottomRightPoint = CGPointMake(_mapView.frame.size.width, _mapView.frame.size.height); CLLocationCoordinate2D bottomRightLocation = [_mapView.projection coordinateForPoint: bottomRightPoint]; CGPoint topRightPoint = CGPointMake(_mapView.frame.size.width, 0); CLLocationCoordinate2D topRightLocation = [_mapView.projection coordinateForPoint: topRightPoint]; CGPoint bottomLeftPoint = CGPointMake(0, _mapView.frame.size.height); CLLocationCoordinate2D bottomLeftLocation = [_mapView.projection coordinateForPoint: bottomLeftPoint]; GMSVisibleRegion realVisibleRegion; realVisibleRegion.farLeft = topLeftLocation; realVisibleRegion.farRight = topRightLocation; realVisibleRegion.nearLeft = bottomLeftLocation; realVisibleRegion.nearRight = bottomRightLocation; [self drawPolylineWithGMSVisibleRegion:realVisibleRegion color:[UIColor redColor] width:10.0f forMap:mapView]; </code></pre> <p>Drawing polyline method:</p> <pre><code>- (void)drawPolylineWithGMSVisibleRegion:(GMSVisibleRegion)visibleRegion color:(UIColor*)color width:(double)width forMap:(GMSMapView*)mapView{ GMSPolylineOptions *rectangle = [GMSPolylineOptions options]; rectangle.color = color; rectangle.width = width; GMSMutablePath *path = [GMSMutablePath path]; [path addCoordinate:visibleRegion.nearRight]; [path addCoordinate:visibleRegion.nearLeft]; [path addCoordinate:visibleRegion.farLeft]; [path addCoordinate:visibleRegion.farRight]; [path addCoordinate:visibleRegion.nearRight]; rectangle.path = path; [mapView addPolylineWithOptions:rectangle]; } </code></pre> <p>It works even for map with non-default bearing and angle.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload