是否有用于平移或缩放地图的Google Map事件侦听器? [英] Is there a Google Map event listener for panning or zooming map?

查看:154
本文介绍了是否有用于平移或缩放地图的Google Map事件侦听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够检测用户是否缩小或移动了地图中心。我已经看过有关事件监听器的帖子,但是在Javascript中,我试图查看Google Maps iOS SDK中是否有类似的东西。我看到iPad Yelp应用程序具有类似的功能,如果您放大/缩小或移动地图,工具栏将从底部显示,并让用户知道他们是否想要重新搜索区域。我想要做类似的事情,并用其他/更多的标记重新加载地图。



我看过Google Map的参考指南,但遗憾的是还没有找到任何东西。如果任何人有类似的东西或有任何指导如何可以完成,任何信息将是伟大的。



链接到Google Map文档我已经看过:

https://developers.google.com/maps/documentation/ios/reference/protocol_g_m_s_map_view_delegate-p



https://developers.google.com/maps/ documentation / ios / reference / interface_g_m_s_coordinate_bounds

解决方案

我使用这个代理来检测相机的变化,位置:

   - (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position; 

编辑

<使用这段代码你可以得到visibile区域的边角:

  NSLog(@%f,%f, _mapView.projection.visibleRegion.farLeft.latitude,_mapView.projection.visibleRegion.farLeft.longitude); // north west 
NSLog(@%f,%f,_ mapView.projection.visibleRegion.farRight.latitude, _mapView.projection.visibleRegion.farRight.longitude); // north east
NSLog(@%f,%f,_ mapView.projection.visibleRegion.nearLeft.latitude,_mapView.projection.visibleRegion.nearLeft.longitude) ; // south west
NSLog(@%f,%f,_ mapView.projection.visibleRegion.nearRight.latitude,_mapView.projection.visibleRegion.nearRight.longitude); // south east


I want to be able to detect if the user has zoomed out or moved the map center. I have seen post about an event listener but in Javascript and I am trying to see if there is anything in the Google Maps iOS SDK similar to that. I see that iPad Yelp app has something like that, where if you zoom in/out or move the map a Tool Bar appears from the bottom and lets the user know if they want to "Redo Search In Area". I want to do something similar like that and reload the map with other/more markers.

I have looked at Google Map's Reference guide but have not found anything, unfortunately. If anyone has had something similar to this or has any guidance on how this can be accomplished, any information would be great. Thanks in advance!

Link to Google Map Documentation I have looked at:

https://developers.google.com/maps/documentation/ios/reference/protocol_g_m_s_map_view_delegate-p

https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_coordinate_bounds

解决方案

I use this delegate to detect the camera change, which includes zoom and position:

- (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position;

EDIT

with this code you can get the corners of the visibile area:

NSLog(@"%f,%f",_mapView.projection.visibleRegion.farLeft.latitude,_mapView.projection.visibleRegion.farLeft.longitude);//north west
NSLog(@"%f,%f",_mapView.projection.visibleRegion.farRight.latitude,_mapView.projection.visibleRegion.farRight.longitude);//north east
NSLog(@"%f,%f",_mapView.projection.visibleRegion.nearLeft.latitude,_mapView.projection.visibleRegion.nearLeft.longitude);//south west
NSLog(@"%f,%f",_mapView.projection.visibleRegion.nearRight.latitude,_mapView.projection.visibleRegion.nearRight.longitude);//south east

这篇关于是否有用于平移或缩放地图的Google Map事件侦听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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