MapKit iPhone 显示缩放控件
是否可以使用 MapKit 在 iPhone 中显示地图,就像我正在做的那样,在地图上显示缩放控件?
如果没有,我应该使用什么标志或方法来增加和减少缩放,这样我就可以创建只需按一下按钮即可执行此操作的方法。
Is it possible using MapKit to show a map in iPhone, like i´m doing, to display zoom controls on the map?
If not, what are the flags or methods i should use to increase and diminish the zoom, so i can created methods which will do this at the push of a button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它没有任何内置控件。
一些建议:
您可以更改 mapView 区域中的跨度。所以你必须:
下面是建议 2 的一些代码:
There aren't any built-in controls for it.
A couple of suggestions:
You change the span in the region of the mapView. So you have to:
Here's some code for suggestion 2:
对于 swift 4,我使用的是:
For swift 4, this is what I use:
我一时不记得(在 Windows 盒子上工作时)是否有一个开关来显示缩放控件。我假设您正在谈论显示缩放级别,因为默认情况下您可以捏合/展开视图以进行缩放。
如果没有显示控件的开关,那么您将需要创建一个自定义视图图层并将其放在 Mapkit 视图的顶部。然后您将需要调用不同的函数来更改缩放级别。
这些功能都记录在 Mapkit 文档中。只需在文档中心搜索 MapKit 即可。
编辑:
http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html#//apple_ref/doc/uid/TP40008205
根据文档中没有显示控件的开关,但启用缩放的属性允许您打开和关闭该功能。
因此,您可以订阅委托函数regionWillChange并使用mapView对象来获取缩放级别,然后相应地设置图形。
Off the top of my head I don't remember (at work on a windows box) if there is a switch to display the zoom controls. I assume you are talking about displaying the level of zoom, because by default you can pinch/spread the view for zoom.
If there isn't a switch to display the controls, then you will need to create a custom view layer and put it on top of the mapkit view. Then you will need to call the different functions to change the zoom level.
Those functions are all documented in the mapkit docs. Just do a search for MapKit in the documentation center.
Edit:
http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html#//apple_ref/doc/uid/TP40008205
According to the docs there isn't a switch to display the controls, but the zoom enabled property lets you turn the ability on and off.
So you can subscribe to the delegate function regionWillChange and use the mapView object to get the zoom level and then set your graphics accordingly.
我认为你不应该这样做,放大和缩小的预期方法是使用捏合手势。但是,如果您仍然想继续执行此操作,则应该将按钮放置在
MKMapView
上,然后使用这些按钮修改MKMapView 的
region
属性I don't think you should do that, the expected way to zoom in and out is using the pinch gestures. However if you still want to go ahead and do it, you should place yourself the buttons over the
MKMapView
, and then with those modify theregion
property of theMKMapView