2017-11-24 3 views
1

내가 달성하려고하는 것은 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) 

항상 출력은 거짓이며, 나는 무엇을 잘못하고 있는지, 어떤 도움을 주는지. 때 당신이 당신의 screenToMap 계산을하고있는 첫째

,

답변

관련 문제