Google Maps iOS SDK:如何从相机的visibleRegion获取精确的纬度和经度坐标? [英] Google Maps iOS SDK: How do I get accurate latitude and longitude coordinates from a camera's visibleRegion?

查看:118
本文介绍了Google Maps iOS SDK:如何从相机的visibleRegion获取精确的纬度和经度坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:这是一个已确认的错误,其中包含。


EDIT: This is now a confirmed bug with this SDK

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.

I'm using the following code to tell me what the current projection is:

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]);

From reading the headers, it seems that it may not be updated when the camera moves. Fair enough...

/**
 * 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).
 */

But, it appears to update each time the delegate method is called, so I attempted to plot the coordinates to test them...

For the following on my phone:

The output of the NSLog from above gives me the following:

37.34209003645947,-122.0382353290915
37.34209003645947,-122.010769508779
37.30332095984257,-122.0382353290915
37.30332095984257,-122.010769508779

When plotting those coordinates using this I get a projection that seems off:

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?

解决方案

The solution is to download the latest version of the SDK (1.2 at the time of this writing) as the issue has been fixed.

From the 1.2 release notes:

Resolved Issues: - visibleRegion now reports correctly sized region on Retina devices

Download here.

这篇关于Google Maps iOS SDK:如何从相机的visibleRegion获取精确的纬度和经度坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆