gpt4 book ai didi

ios - 在平移/缩放上移动的 Mapbox 标注。

转载 作者:行者123 更新时间:2023-11-28 06:18:30 30 4
gpt4 key购买 nike

我已遵循指南here创建自定义标注 View 。我在自定义类中添加了两行:

var dismissesAutomatically: Bool = false
var isAnchoredToAnnotation: Bool = true

在平移和缩放时保持标注 View 显示并保持其锚定到注释时,这些似乎可以完成工作。但是,当用户平移或缩放时,标注似乎下降了大约 20 像素。

点击注释时的初始 View ,但在平移/缩放之前:

Before Pan/Zoom

平移/缩放后立即查看:

View immediately after panning/zooming

最佳答案

来自 isAnchoredToAnnotation 的 Mapbox API 文档:

A Boolean value indicating whether the callout view should be anchored to the corresponding annotation. You can adjust the callout view’s precise location by overriding -[UIView setCenter:]. The callout view will not be anchored to the annotation if this optional property is unimplemented.

在 Swift 中会是:myView.center =
希望这会有所帮助。

编辑:-看看this example在描述如何实现可拖动注释的 Mapbox 网站上。有趣的部分是在测试拖动状态(MGLAnnotationViewDragState)的 setDragState 方法中。我建议在 .dragging 案例中以类似于他们实现 startDragging()endDragging() 的方式实现标注中心坐标更新 功能。

关于ios - 在平移/缩放上移动的 Mapbox 标注。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44379788/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com