私が達成しようとしているのは、userMarkerが可視範囲内にあるときに、これが自分のコードであるということです。マップ位置が地図の中にあることを確認する方法carto-mobile SDK
let screenWidth: Float = Float((map.frame.size.width))
let screenHeight: Float = Float((map.frame.size.height))
let minScreenPos: NTScreenPos = NTScreenPos(x: 0.0, y: 0.0)
let maxScreenPos: NTScreenPos = NTScreenPos(x: screenWidth, y:screenHeight)
let minPosWGS = projection.fromWgs84(map.screen(toMap: minScreenPos))!
let maxPosWGS = projection.fromWgs84(map.screen(toMap: maxScreenPos))!
let mapBounds = NTMapBounds(min: minPosWGS, max: maxPosWGS)
let markerCenter = projection.fromWgs84(userMarker.getBounds().getCenter())
let markerBounds = userMarker.getBounds()
let containPos = mapBounds!.contains(markerCenter)
let containBounds = mapBounds!.contains(markerBounds)
print(containPos)
print(containBounds)
しかし、出力は常にfalseです。間違っていると助けてください。
あなたのソリューションがあなたのためにうまくいくなら、しかし、ええ、あなたはまだそれがどのように異なる方向と回転で動作するかを調べるべきです。 'UIScreen.main.scale'を使うべきです。あなたの現在のデバイス/シミュレータのスケールは2であるかもしれませんが、それはすべてのデバイスに当てはまりません。 – Nikitah
こんにちは、私はすべての回転と向きでそれをテストし、私は、 'UIScreen.main.scale' –