我想要实现的是,当 userMarker 在可见边界内完成一些操作时,这是我的代码。
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)
但总是输出是错误的,我做错了什么,请帮忙。