iOS MapKit:如何在标记拖动期间平移地图? [英] iOS MapKit: How Do I Get the Map to Pan During A Marker Drag?

查看:63
本文介绍了iOS MapKit:如何在标记拖动期间平移地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找答案.

在Google Maps JavaScript API中,当您拖动标记并靠近边缘时,地图将平移以为标记留出空间,并使更多地图可见.这对于从位置A开始然后拖动到位置B非常有用.即使B目前不在地图上.

显然,这在MapKit中是不可能的.似乎没有任何内置功能.<​​/p>

足够公平.我会写我自己的.我将沿边缘设置矩形,如果拖动进入矩形,则地图将开始平移.我会根据与边缘的接近程度来加快平移速度.

除了:在拖动过程中似乎也无法获得标记的位置.您只能在之前和之后获得它.这是我的好主意.

我通过编写一个NSTimer进行了测试,该NSTimer在拖动开始时就开始了,在结束时就失效了.它反复调用一个函数,以读取注释对象的位置.

在拖动过程中位置永远不会改变.

问题:关于如何使此自动平移"工作有任何想法吗?

解决方案

不是.看来您无法从这里到达那里.

我这样做了,当您移动地图时,地图似乎进入了某种锁定状态.当下面的地图坐标系移动时,似乎无法处理标记.

我怀疑我现在知道为什么不支持拖动平移.

我希望它会在更高版本的MapKit中得到支持.

I've looked in vain for answers on this.

In the Google Maps JavaScript API, when you drag a marker, and get close to the edge, the map pans to make room for the marker, and bring more of the map into view. This is very useful for starting at location A, then dragging to location B; even though B is currently off the map.

Apparently, this is not possible in MapKit. There does not seem to be any built-in functionality for this.

Fair enough. I'll write my own. I'll set up rects along the edges, and if the drag enters them, the map starts to pan. I'd accelerate the pan, based on the proximity to the edge.

Except: There also seems to be no way to get the marker location during a drag. You can only get it before and after. That kind of pooches my great idea.

I tested this by writing an NSTimer that is kicked off at the start of a drag, and invalidated at the end. It repeatedly calls a function that reads the annotation object for its location.

The location never changes during the drag.

Question: Any ideas on how I can get this "auto-pan" to work?

解决方案

Nope. Looks like you can't get there from here.

I did that, and the map seems to go into some kind of lock when you shift it. Looks like it can't deal with handling the marker when the coordinate system of the map underneath shifts.

I suspect that I now know why drag-panning is not supported.

I can hope that it will be supported in a later version of the MapKit.

这篇关于iOS MapKit:如何在标记拖动期间平移地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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