Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps iOS SDK: How do I get accurate latitude and longitude coordinates from a camera's visibleRegion?
    text
    copied!<p>EDIT: This is now a confirmed bug with <a href="https://code.google.com/p/gmaps-api-issues/issues/detail?id=5107" rel="nofollow noreferrer">this</a> SDK</p> <p>I'm using version 1.1.1.2311 of the Google Maps for iOS SDK, and I'm looking to find the bounding latitude and longitude coordinates for the visible map on screen.</p> <p>I'm using the following code to tell me what the current projection is:</p> <pre><code>NSLog(@"\n%@,%@\n%@,%@\n%@,%@\n%@,%@\n", [NSNumber numberWithDouble:mapView.projection.visibleRegion.farLeft.latitude], [NSNumber numberWithDouble:mapView.projection.visibleRegion.farLeft.longitude], [NSNumber numberWithDouble:mapView.projection.visibleRegion.farRight.latitude], [NSNumber numberWithDouble:mapView.projection.visibleRegion.farRight.longitude], [NSNumber numberWithDouble:mapView.projection.visibleRegion.nearLeft.latitude], [NSNumber numberWithDouble:mapView.projection.visibleRegion.nearLeft.longitude], [NSNumber numberWithDouble:mapView.projection.visibleRegion.nearRight.latitude], [NSNumber numberWithDouble:mapView.projection.visibleRegion.nearRight.longitude]); </code></pre> <p>From reading the headers, it seems that it may not be updated when the camera moves. Fair enough...</p> <pre><code>/** * The GMSProjection currently used by this GMSMapView. This is a snapshot of * the current projection, and will not automatically update when the camera * moves. The projection may be nil while the render is not running (if the map * is not yet part of your UI, or is part of a hidden UIViewController, or you * have called stopRendering). */ </code></pre> <p>But, it appears to update each time the delegate method is called, so I attempted to plot the coordinates to test them...</p> <p>For the following on my phone:</p> <p><img src="https://i.stack.imgur.com/sxoFI.png" alt="my app&#39;s current projection"></p> <p>The output of the NSLog from above gives me the following:</p> <pre><code>37.34209003645947,-122.0382353290915 37.34209003645947,-122.010769508779 37.30332095984257,-122.0382353290915 37.30332095984257,-122.010769508779 </code></pre> <p>When plotting those coordinates using <a href="http://www.darrinward.com/lat-long/" rel="nofollow noreferrer">this</a> I get a projection that seems off:</p> <p><img src="https://i.stack.imgur.com/R5rMX.png" alt="actual projection"></p> <p>These coordinates are consistent across app launches which leads me to believe that I'm either consistently doing something wrong, I'm misunderstanding what visibleRegion is, or I've discovered a bug. Anyone care to help me figure out which one it is?</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