PlayMapView
Description
지도데이터를 화면에 표시하는 메인 클래스입니다.
Constructors
PlayMapView(frame:CGRect)
Example
var mapView = PlayMapView(frame: frame);
self.view.addSubview(mapView);
mapView.setAppKey(“[발급받은 appKey]”);
Methods
protocol mapViewDidFinishLoadingMap()
Descript
지도 초기화 후 호출되는 인터페이스 함수 추가
Parameters
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func mapViewDidFinishLoadingMap () {
// 코드 처리
}
func authorizationSuccess()
Descript
인증이 성공하면 전달합니다.
Parameters
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func authorizationSuccess () {
// 코드 처리
}
func authorizationFail()
Descript
인증이 실패하면 전달합니다.
Parameters
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func authorizationFail () {
// 코드 처리
}
func mapView(_ mapView: PlayMapView, shouldChangeFrom oldPosition: CLLocationCoordinate2D, to newPosition: CLLocationCoordinate2D)->Bool
Descript
지도의 영역이 이동되기 전 호출 되며 이동 전의 중심 좌표와 이동할 좌표가 파라미터로 전달되는 프로토콜을 정의합니다.
Parameters
Name {Type} | Description |
---|---|
mapView{PlayMapView} | 해당되는 맵뷰 인스턴스 |
oldPosition{CLLocationCoordinate2D} | 이동하기 직전 지점의 좌표 |
newPosition{CLLocationCoordinate2D} | 이동후 지점의 좌표 |
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func mapView(_ mapView:PlayMapView, shouldChangeFrom oldPosition:CLLocation Coordinate2D, to newPosition:CLLocationCoordinate2D)->Bool {
// 코드 처리
}
func mapView(_ mapView: PlayMapView, mapMoved position: CLLocationCoordinate2D, zoom: Int)
Descript
지도 위치 및 줌 변경 시 호출되는 프로토콜
Parameters
Name {Type} | Description |
---|---|
mapView{PlayMapView} | 해당되는 맵뷰 인스턴스 |
position{CLLocationCoordinate2D} | 이동된 지점의 좌표 |
zoom{Int} | 이동된 지점의 줌레벨 |
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func mapView(_ mapView:PlayMapView, mapMoved position:CLLocationCoordinate2D, zoom:Int) {
// 코드 처리
}
func mapView(_ mapView: PlayMapView, tapOnMap position: CLLocationCoordinate2D)
Descript
지도상에 탭 이벤트 발생시 전달합니다.
Parameters
Name {Type} | Description |
---|---|
mapView{PlayMapView} | 해당되는 맵뷰 인스턴스 |
position{CLLocationCoordinate2D} | 탭 이벤트가 발생한 지도상의 좌표 |
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func mapView (_ mapView:PlayMapView, tapOnMap position:CLLocationCoordinate2D) {
// 코드 처리
}
func mapView(_ mapView: PlayMapView, longTapOnMap position: CLLocationCoordinate2D)
Descript
지도상에 롱탭 이벤트 발생시 전달합니다.
Parameters
Name {Type} | Description |
---|---|
mapView{PlayMapView} | 해당되는 맵뷰 인스턴스 |
position{CLLocationCoordinate2D} | 탭 이벤트가 발생한 지도상의 좌표 |
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func mapView (_ mapView:PlayMapView, longTapOnMap position:CLLocationCoordinate2D) {
// 코드 처리
}
func mapView(_ mapView: PlayMapView, doubleTapOnMap position: CLLocationCoordinate2D)
Descript
지도상에 롱탭 이벤트 발생시 전달합니다.
Parameters
Name {Type} | Description |
---|---|
mapView{PlayMapView} | 해당되는 맵뷰 인스턴스 |
position{CLLocationCoordinate2D} | 더블탭 이벤트가 발생한 지도상의 좌표 |
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func mapView (_ mapView:PlayMapView, doubleTapOnMap position:CLLocationCoordinate2D) {
// 코드 처리
}
func mapView(_ mapView: PlayMapView, doubleTapOnMap position: CLLocationCoordinate2D)
Descript
지도상에 롱탭 이벤트 발생시 전달합니다.
Parameters
Name {Type} | Description |
---|---|
mapView{PlayMapView} | 해당되는 맵뷰 인스턴스 |
position{CLLocationCoordinate2D} | 더블탭 이벤트가 발생한 지도상의 좌표 |
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func mapView (_ mapView:PlayMapView, doubleTapOnMap position:CLLocationCoordinate2D) {
// 코드 처리
}
func mapView(_ mapView: PlayMapView, tapOnMarker marker: PlayMapMarker)
Descript
마커에 탭 이벤트가 발생한 경우 전달합니다.
Parameters
Name {Type} | Description |
---|---|
mapView{PlayMapView} | 해당되는 맵뷰 인스턴스 |
position{CLLocationCoordinate2D} | 더블탭 이벤트가 발생한 지도상의 좌표 |
Example
// 클래스 선언부에 delegate 설정
class ViewController: UIViewController, PlayMapViewDelegate {
// delegate 함수 추가
func mapView(_ mapView: PlayMapView, tapOnMarker marker: PlayMapMarker) {
// 코드 처리
}
heading: CLLocationDirection
Descript
현재 지도의 방향을 가져오거나 설정합니다. (360도 기준)
Parameters
Example
mapView.heading = 0 // 정북 방향
mapView.heading = 180 // 정남 방향
var angle = mapView.heading // 현재 지도의 방향
mapRotation: Bool
Descript
지도 회전 기능을 on/off 하거나 현재 상태를 가져옵니다.
Parameters
Example
mapView.mapRotation = true // 회전 가능
mapView.mapRotation = false // 회전 불가
var status = mapView.mapRotation // 회전 가능 상태 여부
mapScroll: Bool
Descript
지도 스크롤(패닝) 기능을 on/off 하거나 현재 상태를 가져옵니다.
Parameters
Example
mapView.mapScroll = true // 지도 드래그 가능
mapView.mapScroll = false // 지도 드래그 불가
var status = mapView.mapScroll // 드래그 가능 상태 여부
mapZoom: Bool
Descript
지도 확대/축소 기능을 on/off 하거나 현재 상태를 가져옵니다.
Parameters
Example
mapView.mapZoom = true // 확대/축소 가능
mapView.mapZoom = false // 확대/축소 불가
var status = mapView.mapZoom // 확대/축소 가능 상태 여부
compassMode: Bool
Descript
지도 나침반 기능을 on/off 하거나 현재 상태를 가져옵니다.
Parameters
Example
mapView.compassMode = true // 나침반 기능 활성화
mapView.compassMode = false // 나침반 기능 비활성화
var status = mapView.compassMode // 나침반 기능 활성화 여부
trackingMode: Bool
Descript
지도 트래킹모드를 on/off 하거나 현재 상태를 가져옵니다.
Parameters
Example
mapView.trackingMode = true // 트래킹 모드 활성화
mapView.trackingMode = false // 트래킹 모드 비활성화
var status = mapView.trackingMode // 트래킹 모드 활성화 여부
trafficMode: Bool
Descript
교통정보 기능을 on/off 하거나 현재 상태를 가져옵니다.
Parameters
Example
mapView.trafficMode = true // 교통정보 활성화
mapView.trafficMode = false // 교통정보 비활성화
var status = mapView.trafficMode // 교통정보 활성화 여부
func setAppKey(_ appKey:String)
Descript
지도를 사용하기 위해 인증키를 세팅합니다.
Parameters
Name {Type} | Description |
---|---|
appKey{String} | 부여받은 인증키 |
Example
mapView.setAppKey(“[발급받은 appKey]”);
func clear()
Descript
지도상의 모든 오브젝트(마커, 라인, 폴리곤 등)를 제거합니다.
Parameters
Example
mapView.clear()
func set(minZoom:CGFloat, maxZoom:CGFloat)
Descript
표출할 지도의 최대/최소 줌레벨을 설정합니다.
Parameters
Name {Type} | Description |
---|---|
minZoom{CGFloat} | 표출할 최소레벨 |
maxZoom{CGFloat} | 표출할 최대레벨 |
Example
mapView.set(minZoom: 10, maxZoom:15) // 10~15레벨까지 표출
func addAnimation(animation:PlayMapAnimation )
Descript
애니메이션을 추가합니다.
Parameters
Name {Type} | Description |
---|---|
animation{PlayMapAnimation} | PlayMapAnimation 객체 |
Example
let animation = PlayMapAnimation(position:position, animationView:animationView)
mapView.addAnimation(animation)
func removeAnimation(animation:PlayMapAnimation)
Descript
애니메이션을 삭제합니다.
Parameters
Name {Type} | Description |
---|---|
animation{PlayMapAnimation} | PlayMapAnimation 객체 |
Example
let animation = PlayMapAnimation(position:position, animationView:animationView)
mapView.removeAnimation(animation)
func removeAllAnimation( )
Descript
모든 애니메이션을 삭제합니다.
Example
mapView.removeAllAnimation( )
func animateTo(location:CLLocationCoordinate2D, zoom:Int)
Descript
애니메이션 효과와 함께 해당 지점과 줌레벨로 지도을 이동합니다.
Parameters
Name {Type} | Description |
---|---|
location{CLLocationCoordinate2D} | 이동시킬 지도상의 좌표 |
zoom{Int} | 줌레벨 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let zoom = 10
mapView.animateTo(location:coord, zoom: zoom) // coord와 zoom으로 지도 애니메이션
func animateTo(zoom:Int)
Descript
애니메이션 효과와 함께 해당 줌레벨로 이동합니다.
Parameters
Name {Type} | Description |
---|---|
zoom{Int} | 줌레벨 |
Example
mapView.animateTo(zoom: 10) // 현재 위치에서 10레벨로 지도 애니메이션
func animateTo(location:CLLocationCoordinate2D, zoom:Int, isAnimated:Bool)
Descript
애니메이션 효과 적용 여부를 선택하여 해당 지점과 줌레벨로 지도를 이동합니다.
Parameters
Name {Type} | Description |
---|---|
location{CLLocationCoordinate2D} | 이동시킬 지도 상의 좌표 |
zoom{Int} | 줌 레벨 |
isAnimated{Bool} | 애니메이션 효과 적용 여부 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let zoom = 10
mapView.animateTo(location: coord, zoom: zoom, isAnimated: true) // 애니메이션 효과 On
mapView.animateTo(location: coord, zoom: zoom, isAnimated: true) // 애니메이션 효과 Off
func animateTo(location:CLLocationCoordinate2D)
Descript
애니메이션 효과와 함께 지정한 위치로 화면을 이동합니다.
Parameters
Name {Type} | Description |
---|---|
location{CLLocationCoordinate2D} | 이동시킬 지도 상의 좌표 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
mapView.animateTo(location: coord)
func getCenter()->CLLocationCoordinate2D?
Descript
현재 지도의 중심 좌표를 가져옵니다.
Parameters
Example
let center = mapView.getCenter()
func setCenter(_ location:CLLocationCoordinate2D, zoom:Int)
Descript
현재 지도의 중심 좌표와 줌레벨을 설정합니다.
Parameters
Name {Type} | Description |
---|---|
location{CLLocationCoordinate2D} | 설정할 지도의 좌표 |
zoom{CLLocationCoordinate2D} | 설정할 줌레벨 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let zoom = 10
mapView.setCenter(location:coord, zoom: zoom) // coord와 zoom으로 지도 이동
func setCenter(_ location:CLLocationCoordinate2D)
Descript
현재 지도의 중심 좌표를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
location{CLLocationCoordinate2D} | 설정할 지도의 좌표 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
mapView.animateTo(coord) // coord 로 지도 애니메이션
func fitCenter(_ location:CLLocationCoordinate2D, radius:Int)
Descript
현재 지도의 중심 좌표를 해당 반경이 보이도록 설정합니다.
Parameters
Name {Type} | Description |
---|---|
location{CLLocationCoordinate2D} | 설정할 지도의 좌표 |
radius{Int} | 표출될 지도의 반경 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let radius = 500 // 반경 500미터
mapView.fitCenter(location:coord, radius: radius) // coord와 반경으로 지도 이동
func setMapBounds(_ locationList:Array<CLLocationCoordinate2D>, padding:UIEdgeInsets, animated:Bool)
Descript
현재 지도의 영역과 상하좌우 여백, 애니메이션 적용 여부를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
locationList{Array<CLLocationCoordinate2D>} | 한 화면에 전부 표시할 좌표 리스트 |
padding{UIEdgeInsets} | 상하좌우 여백 |
animated{Bool} | 애니메이션 효과 적용 여부 |
Example
let locationArray = Array.init(arrayLiteral:
CLLocationCoordinate2D(latitude: 37.426070, longitude: 126.623825),
CLLocationCoordinate2D(latitude: 37.342867, longitude: 126.661272),
CLLocationCoordinate2D(latitude: 37.350237, longitude: 126.583630),
CLLocationCoordinate2D(latitude: 37.379979, longitude: 126.697002),
CLLocationCoordinate2D(latitude: 37.517759, longitude: 126.624744))
mapView.setMapBounds(locationArray, padding:padding, animated:true)
// 해당 영역으로 이동 (애니메이션 효과 On)
func fitBounds(_ bounds:MapBounds)
Descript
현재 지도의 영역을 설정합니다.
Parameters
Name {Type} | Description |
---|---|
bounds{MapBounds} | 설정할 지도의 영역 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let bounds = MapBounds(sw: sw, ne: ne) // 영역 객체 생성
mapView.fitBounds(bounds) // 해당 영역으로 이동
func fitBounds(_ bounds:MapBounds, padding:CGFloat)
Descript
현재 지도의 영역과 상하좌우 여백을 설정합니다.
Parameters
Name {Type} | Description |
---|---|
bounds{MapBounds} | 설정할 지도의 영역 |
padding{CGFloat} | 상하좌우 여백 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let bounds = MapBounds(sw: sw, ne: ne) // 영역 객체 생성
let padding = 20 // 20픽셀만큼 패딩
mapView.fitBounds(bounds, padding:padding) // 해당 영역으로 이동
func fitBounds(_ bounds:MapBounds, padding: UIEdgeInsets)
Descript
현재 지도의 영역과 상하좌우 여백을 설정합니다.
Parameters
Name {Type} | Description |
---|---|
bounds{MapBounds} | 설정할 지도의 영역 |
padding{UIEdgeInsets} | 상하좌우 여백 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let bounds = MapBounds(sw: sw, ne: ne) // 영역 객체 생성
let padding = UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 15) // 상하좌우 padding 각각 설정
mapView.fitBounds(bounds, padding:padding) // 해당 영역으로 이동
func fitBounds(bounds:MapBounds, padding:CGFloat, isAnimated:Bool)
Descript
현재 지도의 영역과 상하좌우 여백, 애니메이션 적용 여부를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
bounds{MapBounds} | 설정할 지도의 영역 |
padding{CGFloat} | 상하좌우 여백 |
isAnimated{Bool} | 애니메이션 효과 적용 여부 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let bounds = MapBounds(sw: sw, ne: ne) // 영역 객체 생성
let padding = 20
mapView.fitBounds(bounds, padding:padding, isAnimated:true) // 해당 영역으로 이동 (애니메이션 효과 On)
func getZoom()->Int?
Descript
현재 지도의 줌레벨을 가져옵니다.
Parameters
Example
let zoom = mapView.getZoom()
func setZoom(_ zoom:Int)
Descript
현재 지도의 줌레벨을 설정합니다.
Parameters
Name {Type} | Description |
---|---|
zoom{Int} | 설정할 줌레벨 |
Example
mapView.setZoom(10) // 10레벨로 이동
func setZoomButtonActive(margin:CGPoint, position:MapControlPosition )
Descript
확대/축소 버튼의 위치를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
margin{CGPoint} | 상하좌우 여백 |
position{MapControlPosition} | Compass 의 위치 (MapControlPosition 생략 가능) |
Example
let padding = 80
mapView.setZoomButtonActive(margin:padding, position: .LeftBottom )
func convertPixelToMeter(_ pixel:Double)->Double
Descript
스크린 픽셀 거리를 실제 거리(미터)로 변환합니다.
Parameters
Name {Type} | Description |
---|---|
pixel{Double} | 픽셀 거리 |
Example
var meter = mapView.convertPixelToMeter(100) // 100픽셀에 대한 실제거리(미터)
func convertMeterToPixel(_ meter:Double)->Double
Descript
실제 거리(미터)를 스크린 픽셀 거리로 변환합니다.
Parameters
Name {Type} | Description |
---|---|
meter{Double} | 실제 거리(미터) |
Example
var pixel = mapView.convertMeterToPixel(100) // 100미터에 대한 픽셀거리
func setCompassPosition(margin:CGPoint, position:MapControlPosition)
Descript
나침반의 위치를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
margin{CGPoint} | 상하좌우 여백 |
position{MapControlPosition} | Compass 의 위치 (MapControlPosition 생략 가능) |
- MapControlPosition.None
- MapControlPosition.LeftTop
- MapControlPosition.RightTop
- MapControlPosition.LeftBottom
- MapControlPosition.RightBottom
Example
let padding = 20
mapView.setCompassPosition(margin:padding, position: .LeftTop )
func setLocationBtnPosition(margin:CGPoint, position:MapControlPosition)
Descript
현재 위치 버튼의 위치를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
margin{CGPoint} | 상하좌우 여백 |
position{MapControlPosition} | Compass 의 위치 (MapControlPosition 생략 가능) |
Example
let padding = 20
mapView.setLocationBtnPosition(margin:padding, position: .LeftBottom )
func setLogoPosition(margin:CGPoint, position:MapControlPosition)
Descript
로고이미지의 위치를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
margin{CGPoint} | 상하좌우 여백 |
position{MapControlPosition} | Compass 의 위치 (MapControlPosition 생략 가능) |
- MapControlPosition.None
- MapControlPosition.LeftTop
- MapControlPosition.RightTop
- MapControlPosition.LeftBottom
- MapControlPosition.RightBottom
Example
let padding = 20
mapView.setLogoPosition(margin:padding, position: .RightBottom )
func setScaleBarPosition(margin:CGPoint, position:MapControlPosition)
Descript
축척바의 위치를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
margin{CGPoint} | 상하좌우 여백 |
position{MapControlPosition} | Compass 의 위치 (MapControlPosition 생략 가능) |
- MapControlPosition.None
- MapControlPosition.LeftTop
- MapControlPosition.RightTop
- MapControlPosition.LeftBottom
- MapControlPosition.RightBottom
Example
let padding = 20
mapView.setScaleBarPosition(margin:padding, position: .LeftBottom )
func addText(_ text:PlayMapText)
Descript
지도상에 텍스트 객체를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
text{PlayMapText} | PlayMapText 객체 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let text = PlayMapText(position: coord, text: "Hello!") // 텍스트 객체 생성
text.fontSize = 18 // 폰트사이즈
text.fontColor = .red // 폰트 색상
text.backgroundColor = .clear // 배경 색상
text.borderWidth = 0 // 외곽선 두께
text.borderColor = .brown // 외곽선 색상
mapView.addText(text) // 지도에 추가
func removeText(_ text:PlayMapText)
Descript
지도상에서 텍스트 객체를 제거합니다.
Parameters
Name {Type} | Description |
---|---|
text{PlayMapText} | 제거할 PlayMapText 객체 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let text = PlayMapText(position: coord, text: "Hello!") // 텍스트 객체 생성
mapView.addText(text) // 지도에 추가
mapView.removeText(text) // 지도에서 제거
func removeAllTexts()
Descript
지도상의 모든 텍스트 객체를 제거합니다.
Parameters
Example
mapView.removeAllTexts() // 모든 텍스트 객체를 제거
func addMarker(_ marker:PlayMapMarker)
Descript
지도상에 마커 객체를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
marker{PlayMapMarker} | 추가할 PlayMapMarker 객체 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker = PlayMapMarker(position: coord)
marker.title = "제목없음" // 마커 제목
marker.subTitle = "내용없음" // 마커 부제목
marker.draggable = true // 마커 드래그 가능 여부
mapView.addMarker(marker) // 지도에 추가
func addMarkers(_ markers:Array<PlayMapMarker>)
Descript
한번에 여러 개의 마커 객체를 추가할 때 사용합니다.
Parameters
Name {Type} | Description |
---|---|
marker{Array<PlayMapMarker>} | 추가할 PlayMapMarker객체의 배열 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
let marker2 = PlayMapMarker(position: coord) // 2번 마커
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
func selectMarker(_ marker:PlayMapMarker)
Descript
해당 마커를 선택합니다. 마커의 어노테이션 뷰가 보여지게 됩니다.
Parameters
Name {Type} | Description |
---|---|
marker{PlayMapMarker} | 선택할 마커의 객체 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
let marker2 = PlayMapMarker(position: coord) // 2번 마커
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
mapView.selectMarker(marker1) // 1번 마커 선택
func deselectMarker(_ marker:PlayMapMarker)
Descript
해당 마커의 선택을 해제합니다. 마커의 어노테이션 뷰가 사라지게 됩니다.
Parameters
Name {Type} | Description |
---|---|
marker{PlayMapMarker} | 선택 해제할 마커의 객체 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
let marker2 = PlayMapMarker(position: coord) // 2번 마커
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
mapView.selectMarker(marker1) // 1번 마커 선택
mapView.deselectMarker(marker1) // 1번 마커 선택 해제
func findMarkerByTag(_ tag:Int)->Array<PlayMapMarker>
Descript
해당 태그를 설정한 마커 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
tag{Int} | 마커 객체 생성시에 설정한 tag 값 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
marker1.tag = 1
let marker2 = PlayMapMarker(position: coord) // 2번 마커
marker2.tag = 2
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
let result = mapView.findMarkerByTag(1) // tag가 1인 마커 반환
func findMarkerByName(_ name:String)->Array<PlayMapMarker>
Descript
해당 name을 설정한 마커 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
name{String} | 마커 객체 생성시에 설정한 name값 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
marker1.name = “m1”
let marker2 = PlayMapMarker(position: coord) // 2번 마커
marker2.name = “m2”
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
let result = mapView.findMarkerByName(“m1”) // name이 “m1”인 마커 반환
func removeMarker(_ marker:PlayMapMarker)
Descript
해당 마커 객체를 지도상에서 제거합니다.
Parameters
Name {Type} | Description |
---|---|
marker{PlayMapMarker} | 제거할 마커의 객체 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker = PlayMapMarker(position: coord) // 마커
mapView.addMarker(marker) // 지도에 추가
mapView.removeMarker(marker) // 지도에서 제거
func removeMarkers(_ markers:Array<PlayMapMarker>)
Descript
한번에 여러 개의 마커를 제거할 때 사용합니다.
Parameters
Name {Type} | Description |
---|---|
marker{Array<PlayMapMarker>} | 제거할 마커 객체의 배열 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
let marker2 = PlayMapMarker(position: coord) // 2번 마커
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
mapView.removeMarkers(markerArray) // 마커 제거
func removeMarkers(_ markers:Array<PlayMapMarker>)
Descript
한번에 여러 개의 마커를 제거할 때 사용합니다.
Parameters
Name {Type} | Description |
---|---|
marker{Array<PlayMapMarker>} | 제거할 마커 객체의 배열 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
let marker2 = PlayMapMarker(position: coord) // 2번 마커
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
mapView.removeMarkers(markerArray) // 마커 제거
func removeAllMarkers()
Descript
모든 마커 객체를 제거합니다.
Parameters
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
let marker2 = PlayMapMarker(position: coord) // 2번 마커
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
mapView.removeAllMarkers()
func fitMapBoundsToShowAllMarkers()
Descript
지도에 추가한 모든 마커가 보이도록 지도 영역을 변경합니다.
Parameters
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let marker1 = PlayMapMarker(position: coord) // 1번 마커
let marker2 = PlayMapMarker(position: coord) // 2번 마커
let markerArray = [marker1, marker2] // 배열에 담기
mapView.addMarker(markerArray) // 지도에 추가
mapView.fitMapBoundsToShowAllMarkers()
func addCircle(_ circle:PlayMapCircle)
Descript
지도상에 원 객체를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
circle{PlayMapCircle} | 추가할 원 객체 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let circle = PlayMapCircle(position: coord, radius: 100) // 반경 100미터 원 객체 생성
circle.fillColor = .cyan // 채움 색상
circle.strokeColor = .red // 선 색상
circle.opacity = 0.5 // 투명도 50%
mapView.addCircle(circle) // 지도에 추가
func findCircleByTag(_ tag:Int)->Array<PlayMapCircle>
Descript
해당 태그를 설정한 원 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
tag{Int} | 원 객체 생성시에 설정한 태그 값 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let circle1 = PlayMapCircle(position: coord, radius: 100) // 반경 100미터 원 객체 생성
circle1.tag = 1 // 태그 등록
let circle2 = PlayMapCircle(position: coord, radius: 200) // 반경 200미터 원 객체 생성
circle2.tag = 2 // 태그 등록
mapView.addCircle(circle1) // 지도에 추가
mapView.addCircle(circle2) // 지도에 추가
let result = mapView.findCircleByTag(1) // 태그가 1인 원 객체 반환
func findCircleByName(_ name:String)->Array<PlayMapCircle>
Descript
해당 name을 설정한 원 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
name{String} | 원 객체 생성시에 설정한 name 값 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let circle1 = PlayMapCircle(position: coord, radius: 100) // 반경 100미터 원 객체 생성
circle1.name = “c1” // name 등록
let circle2 = PlayMapCircle(position: coord, radius: 200) // 반경 200미터 원 객체 생성
circle2.name = “c2” // name 등록
mapView.addCircle(circle1) // 지도에 추가
mapView.addCircle(circle2) // 지도에 추가
let result = mapView.findCircleByName(“c1”) // name이 “c1”인 원 객체 반환
func removeCircle(_ circle:PlayMapCircle)
Descript
원 객체를 지도상에서 제거합니다.
Parameters
Name {Type} | Description |
---|---|
circle{PlayMapCircle} | 제거할 원 객체 |
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let circle = PlayMapCircle(position: coord, radius: 100) // 반경 100미터 원 객체 생성
mapView.addCircle(circle) // 지도에 추가
mapView.removeCircle(circle) // 지도에서 제거
func removeAllCircles()
Descript
지도상의 모든 원 객체를 제거합니다.
Parameters
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let circle1 = PlayMapCircle(position: coord, radius: 100) // 반경 100미터 원 객체 생성
let circle2 = PlayMapCircle(position: coord, radius: 200) // 반경 200미터 원 객체 생성
mapView.addCircle(circle1) // 지도에 추가
mapView.addCircle(circle2) // 지도에 추가
mapView.removeAllCircles() // 모든 원 객체 제거
func fitMapBoundsToShowAllCircles()
Descript
지도상의 모든 원 객체가 보이도록 지도 영역을 변경합니다.
Parameters
Example
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let circle1 = PlayMapCircle(position: coord, radius: 100) // 반경 100미터 원 객체 생성
let circle2 = PlayMapCircle(position: coord, radius: 200) // 반경 200미터 원 객체 생성
mapView.addCircle(circle1) // 지도에 추가
mapView.addCircle(circle2) // 지도에 추가
mapView.fitMapBoundsToShowAllCircles()
func addRectangle(_ rectangle:PlayMapRectangle)
Descript
지도상에 사각형 객체를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
rectangle{PlayMapRectangle} | 추가할 사각형 객체 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let rectangle = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne)) // 사각형 객체 생성
rectangle.fillColor = .cyan // 채움 색상
rectangle.strokeColor = .red // 선 색상
rectangle.opacity = 0.5 // 투명도
mapView.addRectangle(rectangle) // 지도에 추가
func findRectangleByTag(_ tag:Int)->Array<PlayMapRectangle>
Descript
해당 태그를 설정한 사각형 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
tag{Int} | 사각형 객체 생성시에 설정한 태그 값 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let rectangle1 = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
rectangle1.tag = 1 // 태그 등록
let rectangle2 = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
rectangle2.tag = 2 // 태그 등록
mapView.addRectangle(rectangle1)
mapView.addRectangle(rectangle2)
let result = mapView.findRectangleByTag(1) // 태그가 1인 사각형 객체 반환
func findRectangleByName(_ name:String)->Array<PlayMapRectangle>
Descript
해당 name을 설정한 사각형 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
name{String} | 사각형 객체 생성시에 설정한 name 값 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let rectangle1 = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
rectangle1.name = “r1” // name 등록
let rectangle2 = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
rectangle2.name = “r2” // name 등록
mapView.addRectangle(rectangle1)
mapView.addRectangle(rectangle2)
let result = mapView.findRectangleByName(“r1”) // name이 “r1”인 사각형 객체 반환
func removeRectangle(_ rectangle:PlayMapRectangle)
Descript
사각형 객체를 지도상에서 제거합니다.
Parameters
Name {Type} | Description |
---|---|
rectangle{PlayMapRectangle} | 제거할 사각형 객체 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let rectangle = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
mapView.addRectangle(rectangle)
mapView.removeRectangle(rectangle) // 사각형 객체 제거
func removeAllRectangles()
Descript
지도상의 모든 사각형 객체를 제거합니다.
Parameters
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let rectangle1 = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
let rectangle2 = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
mapView.addRectangle(rectangle1)
mapView.addRectangle(rectangle2)
mapView.removeAllRectangles() // 모든 사각형 객체 제거
func fitMapBoundsToShowAllRectangles()
Descript
지도상의 모든 사각형 객체가 보이도록 지도 영역을 변경합니다.
Parameters
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let rectangle1 = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
let rectangle2 = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne))
mapView.addRectangle(rectangle1)
mapView.addRectangle(rectangle2)
mapView.fitMapBoundsToShowAllRectangles() // 모든 사각형 객체가 보이도록 지도 이동
func addPolyline(_ polyline:PlayMapPolyline)
Descript
지도상에 폴리라인 객체를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
polyline{PlayMapPolyline} | 추가할 폴리라인 객체 |
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
polyline.strokeWidth = 4 // 선 두께
polyline.strokeColor = .red // 선 색상
mapView.addPolyline(polyline) // 지도에 추가
func findPolylineByTag(_ tag:Int)->Array<PlayMapPolyline>
Descript
해당 태그를 설정한 폴리라인 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
tag{Int} | 폴리라인 객체 생성시에 설정한 태그 값 |
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline1 = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
polyline1.tag = 1 // 태그 등록
let polyline2 = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
polyline2.tag = 2 // 태그 등록
mapView.addPolyline(polyline1)
mapView.addPolyline(polyline2)
let result = mapView.findPolylineByTag(1) // 태그가 1인 라인 객체 반환
func findPolylineByName(_ name:String)->Array<PlayMapPolyline>
Descript
해당 name을 설정한 폴리라인 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
name{String} | 폴리라인 객체 생성시에 설정한 name 값 |
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline1 = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
polyline1.name = “p1” // name 등록
let polyline2 = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
polyline2.name = “p2” // name 등록
mapView.addPolyline(polyline1)
mapView.addPolyline(polyline2)
let result = mapView.findPolylineByName(“p1”) // name이 “p1”인 라인 객체 반환
func removePolyline(_ polyline:PlayMapPolyline)
Descript
폴리라인 객체를 지도상에서 제거합니다.
Parameters
Name {Type} | Description |
---|---|
polyline{PlayMapPolyline} | 제거할 폴리라인 객체 |
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
mapView.addPolyline(polyline) // 지도에 등록
mapView.removePolyline(polyline) // 지도에서 제거
func removeAllPolylines()
Descript
지도상의 모든 폴리라인 객체를 제거합니다.
Parameters
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline1 = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
let polyline2 = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
mapView.addPolyline(polyline1)
mapView.addPolyline(polyline2)
mapView.removeAllPolylines() // 모든 폴리라인 객체 제거
func fitMapBoundsToShowAllPolylines()
Descript
지도상의 모든 폴리라인 객체가 보이도록 지도 영역을 변경합니다.
Parameters
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline1 = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
let polyline2 = PlayMapPolyline(coordinates: path) // 폴리라인 객체 생성
mapView.addPolyline(polyline1)
mapView.addPolyline(polyline2)
mapView. fitMapBoundsToShowAllPolylines()
func addPolygon(_ polygon:PlayMapPolygon)
Descript
지도상에 폴리곤 객체를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
polygon{PlayMapPolygon} | 추가할 폴리곤 객체 |
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
polygon.opacity = 0.8 // 투명도
polygon.fillColor = .brown // 채움 색상
polygon.strokeColor = .red // 라인 색상
mapView.addPolygon(polygon) // 지도에 등록
func findPolygonByTag(_ tag:Int)->Array<PlayMapPolygon>
Descript
해당 태그를 설정한 폴리곤 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
tag{Int} | 폴리곤 객체 생성시에 설정한 태그 값 |
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon1 = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
polygon1.tag = 1 // 태그 등록
let polygon2 = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
polygon2.tag = 2 // 태그 등록
mapView.addPolygon(polygon1) // 지도에 등록
mapView.addPolygon(polygon2) // 지도에 등록
let result = mapView.findPolygonByTag(1) // 태그가 1인 폴리곤 객체 반환
func findPolygonByName(_ name:String)->Array<PlayMapPolygon>
Descript
해당 name을 설정한 폴리곤 객체의 배열을 가져옵니다.
Parameters
Name {Type} | Description |
---|---|
name{String} | 폴리곤 객체 생성시에 설정한 name 값 |
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon1 = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
polygon1.name = “p1” // name 등록
let polygon2 = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
polygon2.name = “p2” // name 등록
mapView.addPolygon(polygon1) // 지도에 등록
mapView.addPolygon(polygon2) // 지도에 등록
let result = mapView.findPolygonByName(“p1”) // name이 “p1”인 폴리곤 객체 반환
func removePolygon(_ polygon:PlayMapPolygon)
Descript
폴리곤 객체를 지도상에서 제거합니다.
Parameters
Name {Type} | Description |
---|---|
polygon{PlayMapPolygon} | 제거할 폴리곤 객체 |
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
mapView.addPolygon(polygon) // 지도에 등록
mapView.removePolygon(polygon) // 지도에서 제거
func removeAllPolygons()
Descript
지도상의 모든 폴리곤 객체를 제거합니다.
Parameters
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon1 = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
let polygon2 = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
mapView.addPolygon(polygon1) // 지도에 등록
mapView.addPolygon(polygon2) // 지도에 등록
mapView.removeAllPolygons() // 모든 객체 제거
func fitMapBoundsToShowAllPolygons()
Descript
지도상의 모든 폴리곤 객체가 보이도록 지도 영역을 변경합니다.
Parameters
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>() // 패스 생성
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon1 = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
let polygon2 = PlayMapPolygon(coordinates: path) // 폴리곤 객체 생성
mapView.addPolygon(polygon1) // 지도에 등록
mapView.addPolygon(polygon2) // 지도에 등록
mapView. fitMapBoundsToShowAllPolygons()
func addGroundImage(_ groundImage:PlayMapGroundImage)
Descript
지도상의 특정 영역에 고정되어 있는 그라운드 이미지 객체를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
groundImage{PlayMapGroundImage} | 그라운드 이미지 객체 |
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let bounds = MapBounds(sw: sw, ne: ne) // 이미지가 표시될 지도상의 영역 객체
let cityhallImage = UIImage(named: "cityhall") // 이미지
let groundImage = PlayMapGroundImage(bounds: bounds, image: cityhallImage!) // 그라운드 이미지 객체 생성
mapView.addGroundImage(groundImage) // 지도에 등록
func removeGroundImage(_ groundImage:PlayMapGroundImage)
Descript
해당 그라운드 이미지 객체를 지도상에서 제거합니다.
Parameters
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let bounds = MapBounds(sw: sw, ne: ne) // 이미지가 표시될 지도상의 영역 객체
let cityhallImage = UIImage(named: "cityhall") // 이미지
let groundImage = PlayMapGroundImage(bounds: bounds, image: cityhallImage!) // 그라운드 이미지 객체 생성
mapView.addGroundImage(groundImage) // 지도에 등록
mapView.removeGroundImage(groundImage) // 지도에서 제거
func removeAllGroundImages()
Descript
지도상의 모든 그라운드 이미지 객체를 제거합니다.
Parameters
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845) // 남서쪽 좌표
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851) // 북동쪽 좌표
let bounds = MapBounds(sw: sw, ne: ne) // 이미지가 표시될 지도상의 영역 객체
let cityhallImage = UIImage(named: "cityhall") // 이미지
let groundImage1 = PlayMapGroundImage(bounds: bounds, image: cityhallImage!) // 그라운드 이미지 객체 생성
let groundImage2 = PlayMapGroundImage(bounds: bounds, image: cityhallImage!) // 그라운드 이미지 객체 생성
mapView.addGroundImage(groundImage1) // 지도에 등록
mapView.addGroundImage(groundImage2) // 지도에 등록
mapView.removeAllGroundImages() // 모든 그라운드 이미지 제거
func setMarkerCluster(_ markerCluster:MarkerCluster)
Descript
마커 클러스터 객체를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
markerCluster{MarkerCluster} | 추가할 마커클러스터 객체 |
Example
var markerArray:Array<PlayMapMarker> = []
// 마커 200개 생성
for i in 0 ..< 10 {
for j in 0 ..< 20 {
let lat = 37.570841 + (Double(i) * 0.0005)
let lng = 126.985302 + (Double(j) * 0.0005)
let marker = PlayMapMarker(position: CLLocationCoordinate2D(latitude: lat, longitude: lng))
self.mapView?.addMarker(marker)
markerArray.append(marker)
}
}
let markerCluster = MarkerCluster(markerArray) // 마커 클러스터 객체 생성
markerCluster.setStep([50, 100, 150, 200]) // 마커 표시할 단계 설정
markerCluster.setStepColor([.yellow, .systemPink, .orange, .red]) // 단계별 색상 설정
mapView.setMarkerCluster(markerCluster) // 지도에 등록
func removeMarkerCluster()
Descript
마커 클러스터 객체를 해제합니다.
Parameters
Example
mapView.removeMarkerCluster()
func measureDistance()
Descript
거리측정 기능을 시작합니다.
Parameters
Example
mapView.measureDistance()
// 위 코드 수행 후 지도상에서 원하는 지점 터치
func exitMeasureDistance()
Descript
거리측정 기능을 종료합니다.
Parameters
Example
mapView.exitMeasureDistance()
func measureArea()
Descript
면적측정 기능을 시작합니다.
Parameters
Example
mapView.measureArea()
// 위 코드 수행 후 지도상에서 원하는 지점 터치
func exitMeasureArea()
Descript
거리측정 기능을 종료합니다.
Parameters
Example
mapView.exitMeasureArea()
func distanceBetweenMarker(from:PlayMapMarker, to:PlayMapMarker)->Int
Descript
두 마커 객체 사이의 거리를 반환합니다(미터).
Parameters
Name {Type} | Description |
---|---|
from{PlayMapMarker} | 시작 지점의 마커 객체 |
to{PlayMapMarker} | 끝 지점의 마커 객체 |
Example
let coord1 = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let coord2 = CLLocationCoordinate2D(latitude: 37.56650, longitude: 126.97751)
let marker1 = PlayMapMarker(position: coord1)
let marker2 = PlayMapMarker(position: coord2)
let result = mapView.distanceBetweenMarker(from:marker1, to:marker2) // 거리 반환
func distanceBetweenCoordinates(from:CLLocationCoordinate2D, to:CLLocationCoordinate2D)->Int
Descript
두 좌표 사이의 거리를 반환합니다(미터).
Parameters
Name {Type} | Description |
---|---|
from{CLLocationCoordinate2D} | 시작 지점의 좌표 |
to{CLLocationCoordinate2D} | 끝 지점의 좌표 |
Example
let coord1 = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let coord2 = CLLocationCoordinate2D(latitude: 37.56650, longitude: 126.97751)
let result = mapView.distanceBetweenCoordinates(from:coord1, to:coord2) // 거리 반환
func addCustom(_ custom: PlayMapCustom)
Descript
지도 상에 사용자 정의 View 를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
custom{PlayMapCustom} | 사용자 정의 View 를 포함하는 객체 |
Example
let customView = UIVIew(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let playMapCustom = PlayMapCustom(position: position: customView: CustomView)
mapView.addCustom(playMapCustom)
func removeCustom(_ custom: PlayMapCustom)
Descript
사용자 정의 view 객체를 지도 상에 제거합니다.
Parameters
Name {Type} | Description |
---|---|
custom{PlayMapCustom} | 제거할 사용자 정의 View 를 포함하는 객체 |
Example
let customView = UIVIew(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let playMapCustom = PlayMapCustom(position: position: customView: CustomView)
mapView.addCustom(playMapCustom)
mapView.removeCustom(playMapCustom)
blackTheme : Bool
Descript
현재 테마가 블랙 테마인지 여부를 가져옵니다.
Example
mapView.blackTheme = true
mapView.blackTheme = false
PlayMapText
Properties
offset:CGSize?
Description
텍스트 객체를 표시하기 위한 오프셋.
Example
let text = PlayMapText(position: position, text: "Hello!")
text.offset = CGSize(width:10, height: 10)
fontSize:CGFloat
Description
텍스트의 폰트 사이즈.
Example
let text = PlayMapText(position: position, text: "Hello!")
text.fontSize = 17
fontColor:UIColor
Description
폰트 색상.
Example
let text = PlayMapText(position: position, text: "Hello!")
text.fontColor = UIColor(red: 1, green: 0, blue:0, alpha: 1)
fontWeight:Int
Description
폰트 두께.
Example
let text = PlayMapText(position: position, text: "Hello!")
text.fontWeight = 5
backgroundColor:UIColor
Description
배경 색상.
Example
let text = PlayMapText(position: position, text: "Hello!")
text.backgroundColor = UIColor(red: 1, green: 1, blue:1, alpha: 1)
borderWidth:CGFloat
Description
테두리 두께.
Example
let text = PlayMapText(position: position, text: "Hello!")
text.borderWidth = 2
borderColor:UIColor
Description
테두리 색상.
Example
let text = PlayMapText(position: position, text: "Hello!")
text.borderColor = UIColor(red: 0, green: 0, blue:0, alpha: 1)
alignment:TextAlignment
Description
텍스트 정렬.
Example
let text = PlayMapText(position: position, text: "Hello!")
text.alignment = .Center
text.alignment = .LeftMiddle
text.alignment = .RightMiddle
PlayMapMarker
Properties
position:CLLocationCoordinate2D?
Description
마커가 표시될 지도상의 좌표.
Example
let marker = PlayMapMarker(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851))
let position = marker.position
icon:UIImage?
Description
마커의 이미지 객체.
Example
let marker = PlayMapMarker(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851))
marker.icon = UIImage(named: “image”)
title:String?
Description
어노테이션 뷰에 표시될 제목.
Example
let marker = PlayMapMarker(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851))
marker.title = “제목”
subTitle:String?
Description
어노테이션 뷰에 표시될 부제목.
Example
let marker = PlayMapMarker(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851))
marker.subTitle = “부제목”
offset:CGSize?
Description
마커를 표시하기 위한 오프셋.
Example
let marker = PlayMapMarker(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851))
marker.offset = CGSize(width: 20, height: 20)
draggable:Bool?
Description
마커의 드래그 가능 여부.
Example
let marker = PlayMapMarker(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851))
marker.draggable = true
PlayMapCircle
Properties
position:CLLocationCoordinate2D?
Description
원이 표시될 지도상의 좌표.
Example
let circle = PlayMapCircle(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851), radius: 100)
let position = circle.position
radius:Int
Description
원의 반경.
Example
let circle = PlayMapCircle(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851), radius: 100)
let radius = circle.radius
strokeColor:UIColor?
Description
외곽선 색상.
Example
let circle = PlayMapCircle(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851), radius: 100)
ciecle.strokeColor = UIColor(red: 0, green: 0, blue:0, alpha: 1)
strokeWidth:CGFloat?
Description
외곽선 두께.
Example
let circle = PlayMapCircle(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851), radius: 100)
circle.strokeWidth = 2
fillColor:UIColor?
Description
채움 색상.
Example
let circle = PlayMapCircle(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851), radius: 100)
ciecle.fillColor = UIColor(red: 1, green: 1, blue:1, alpha: 1)
opacity:CGFloat?
Description
투명도.
Example
let circle = PlayMapCircle(position: CLLocationCoordinate2D.init(latitude: 37.56640, longitude: 126.97851), radius: 100)
circle.opacity = 0.5
PlayMapRectangle
Properties
bounds:MapBounds?
Description
사각형이 표시될 지도의 영역.
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845)
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851)
let rectangle = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne)) /
let bounds = rectangle.bounds
strokeColor:UIColor?
Description
외곽선 색상.
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845)
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851)
let rectangle = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne)) /
rectangle.strokeColor = UIColor(red: 0, green: 0, blue:0, alpha: 1)
strokeWidth:CGFloat?
Description
외곽선 두께.
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845)
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851)
let rectangle = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne)) /
rectangle.strokeWidth = 2
fillColor:UIColor?
Description
채움 색상.
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845)
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851)
let rectangle = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne)) /
rectangle.fillColor = UIColor(red: 1, green: 1, blue:1, alpha: 1)
opacity:CGFloat?
Description
투명도.
Example
let sw = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97845)
let ne = CLLocationCoordinate2D(latitude: 37.56645, longitude: 126.97851)
let rectangle = PlayMapRectangle(rectangle: MapBounds(sw: sw, ne: ne)) /
rectangle.opacity = 0.8
PlayMapPolyline
Properties
path:Array<CLLocationCoordinate2D>?
Description
폴리라인을 구성하는 지도 좌표의 배열.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline = PlayMapPolyline(coordinates: path)
let polylinePath = polyline.path
strokeColor:UIColor?
Description
외곽선 색상.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline = PlayMapPolyline(coordinates: path)
polyline.strokeColor = UIColor(red: 0, green: 0, blue:0, alpha: 1)
strokeWidth:CGFloat?
Description
외곽선 두께.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline = PlayMapPolyline(coordinates: path)
polyline.strokeWidth = 2
opacity:CGFloat?
Description
투명도.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline = PlayMapPolyline(coordinates: path)
polyline.opacity = 0.8
lineStyle:LineStyle
Description
라인 스타일.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polyline = PlayMapPolyline(coordinates: path)
polyline.lineStyle = .dash // 점선
polyline.lineStyle = .dot // 점선
polyline.lineStyle = .solid // 실선
PlayMapPolygon
Properties
path:Array<CLLocationCoordinate2D>?
Description
폴리곤을 구성하는 지도 좌표의 배열.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon = PlayMapPolygon(coordinates: path)
let polygonPath = polygon.path
strokeColor:UIColor?
Description
외곽선 색상.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon = PlayMapPolygon(coordinates: path)
polygon.strokeColor = UIColor(red: 0, green: 0, blue:0, alpha: 1)
strokeWidth:CGFloat?
Description
외곽선 두께.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon = PlayMapPolygon(coordinates: path)
polygon.strokeWidth = 2
opacity:CGFloat?
Description
투명도.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon = PlayMapPolygon(coordinates: path)
polygon.opacity = 0.8
fillColor:UIColor?
Description
채움 색상.
Example
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
var path = Array<CLLocationCoordinate2D>()
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude - 0.001))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude - 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude, longitude: position.longitude))
path.append(CLLocationCoordinate2D(latitude: position.latitude + 0.001, longitude: position.longitude + 0.0005))
path.append(CLLocationCoordinate2D(latitude: position.latitude - 0.001, longitude: position.longitude + 0.001))
let polygon = PlayMapPolygon(coordinates: path)
polygon.fillColor = UIColor(red: 1, green: 1, blue:1, alpha: 1)
PlayMapGroundImage
Description
지도상의 특정 영역에 고정되어 있는 이미지 객체입니다.
Constructors
PlayMapGroundImage(bounds:MapBounds, image:UIImage)
Parameters
Name {Type} | Description |
---|---|
bounds{MapBounds} | 표시될 지도상의 영역 |
image{UIImage} | 표시될 이미지 |
Example
let bounds = MapBounds(sw: CLLocationCoordinate2D(latitude: 37.566115, longitude: 126.977378), ne: CLLocationCoordinate2D(latitude: 37.566997, longitude: 126.979071))
let cityhallImage = UIImage(named: "cityhall")
let groundImage = PlayMapGroundImage(bounds: bounds, image: cityhallImage!)
MarkerCluster
Description
대량의 마커가 겹쳐지는 경우 겹쳐진 숫자로 표시하기 위한 클래스입니다.
Constructors
MarkerCluster(_ markers:Array<PlayMapMarker>)
Parameters
Name {Type} | Description |
---|---|
markers{Array<PlayMapMarker>} | 표시될 마커의 배열 |
Example
var markerArray:Array<PlayMapMarker> = []
for i in 0 ..< 10 {
for j in 0 ..< 20 {
let lat = 37.570841 + (Double(i) * 0.0005)
let lng = 126.985302 + (Double(j) * 0.0005)
let marker = PlayMapMarker(position: CLLocationCoordinate2D(latitude: lat, longitude: lng))
self.mapView?.addMarker(marker)
markerArray.append(marker)
}
}
let markerCluster = MarkerCluster(markerArray)
Methods
func add(_ marker:PlayMapMarker)
Descript
마커 클러스터 객체에 마커를 추가합니다.
Parameters
Name {Type} | Description |
---|---|
marker{PlayMapMarker} | 추가할 마커 객체 |
Example
let markerCluster = MarkerCluster([])
let marker = PlayMapMarker(position: CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851))
markerCluster.add(marker)
func setStep(_ step:Array<Int>)
Descript
클러스터 된 마커의 색상을 변경하기 위한 마커 개수의 단계입니다.
Parameters
Name {Type} | Description |
---|---|
step{Array<Int>} | 숫자의 배열 |
Example
let markerCluster = MarkerCluster([])
markerCluster.setStep([50, 100, 150, 200])
func setStepColor(_ colors:Array<UIColor>)
Descript
클러스터 된 마커의 단계별 색상입니다.
Parameters
Name {Type} | Description |
---|---|
colors{Array<UIColor>} | 단계별 색상 |
Example
let markerCluster = MarkerCluster([])
markerCluster.setStepColor([.yellow, .systemPink, .orange, .red])
PlaMapCustom
Methods
init(position: CLLocationCoordinate2D, customView: UIView)
Descript
사용자 정의 view 를 포함하는 객체를 생성
Parameters
Name {Type} | Description |
---|---|
position{CLLocationCoordinate2D} | 지도상에 표시할 좌표 |
customView{UIView} | 사용자가 정의한 view |
Example
let customView = UIVIew(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let playMapCustom = PlayMapCustom(position: position: customView: CustomView)
func setCustomView(_ view: UIView)
Descript
사용자 정의 view 를 설정합니다.
Parameters
Name {Type} | Description |
---|---|
customView{UIView} | 사용자가 정의한 view |
Example
let customView = UIVIew(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let playMapCustom = PlayMapCustom(position: position: customView: CustomView)
let anotherCustomView = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
playMapCustom.setCustomView(anotherCustomView)
func removeCustomView()
Descript
사용자 정의 view 를 PlayMapCustom 객체에서 제거합니다.
Example
let customView = UIVIew(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
let position = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let playMapCustom = PlayMapCustom(position: position: customView: CustomView)
playMapCustom.removeCustomView()
PlayMapCustomCallout
Methods
backgroundImage
Descript
PlayCustomCallout 의 배경 이미지 property
Example
let customCallout = PlayMapCustomCallout(position: position,
frameSize:CGSize(width: 200, height: 100))
customCallout.backgroundImage = UIImage(named: "hyundai")
PlayMapAnimation
Methods
init(position: CLLocationCoordinate2D, animationView: UIView)
Descript
사용자 정의 Animation 를 포함하는 객체를 생성
Parameters
Name {Type} | Description |
---|---|
position{CLLocationCoordinate2D} | 지도상에 표시할 좌표 |
customView{UIView} | 사용자가 정의한 view |
Example
let animationView: AnimationView = AnimationView()
animationView.frame = CGRect(x:0, y:0, width:100, height:100 )
animationView.backgroundColor = .clear
animationView.animation = Animation.named(“lottie”)
let coord = CLLocationCoordinate2D(latitude: 37.56640, longitude: 126.97851)
let animation = PlayMapAnimation(position:coord, animationView:animationView)
PlayMapRestApi
Methods
func requestPoi(_ keyword:String, location:CLLocationCoordinate2D?, sort:Int?, intent:String?, from:Int?, size:Int?, language:Int?, completion:@escaping (Array<PoiInfo>?, Error?)->Void)
Descript
POI 통합 검색 요청
Parameters
Name {Type} | Description |
---|---|
keyword{String} | 검색할 문자열 |
location{CLLocationCoordinate2D} | 검색할 장소의 좌표 |
sort{int} | 정렬 옵션 (1=추천순, 2=명칭순, 3=거리순) |
intent{String} | 검색 의도 요청 (ex) "near_poi_class", "poi_name", "fts_poi") |
from{int} | 검색 결과 시작 위치 |
size{String} | 응답으로 받을 결과 개수 |
language{int} | 언어 설정 (0 : 영어, 3: 한국어-default) |
completion{Array<PoiInfo>} | 결과 클로져 |
Example
let api = PlayMapRestApi()
api.requestPoi(“현대”, location: center, sort: nil, intent: nil, from: nil, size: nil, language: nil) { (result, error)->Void in
if let pois = result {
for poi in pois {
if let pos = poi.center {
DispatchQueue.main.async {
let marker = PlayMapMarker(position: pos)
marker.title = poi.title
marker.subTitle = poi.addr
marker.tag = poi.poiId
self.mapView?.addMarker(marker)
}
}
}
DispatchQueue.main.async {
self.mapView?.fitMapBoundsToShowAllMarkers()
}
}
}
Return
Return 정보는 Document를 참고해주세요.
func requestPoiDetail(_ poiId:Int, language:Int?, completion:@escaping (PoiDetailInfo?, Error?)->Void)
Descript
POI 상세 정보 검색 요청
Parameters
Name {Type} | Description |
---|---|
poiId{int} | 검색할 POI ID |
language{int} | 언어 설정 (0 : 영어, 3: 한국어-default) |
completion{PoiDetailInfo} | 결과 클로져 |
Example
let api = PlayMapRestApi()
api.requestPoiDetail(111111, language: nil) { (result, error)->Void in
if let result = result {
var detail = ""
detail += String(format: "POI ID : %d\n", result.poiId == nil ? 0 : result.poiId!)
detail += String(format: "title : %@\n", result.title == nil ? "" : result.title!)
detail += String(format: "cname : %@\n", result.cname == nil ? "" : result.cname!)
detail += String(format: "addr : %@\n", result.addr == nil ? "" : result.addr!)
detail += String(format: "addrRoad : %@\n", result.addrRoad == nil ? "" : result.addrRoad!)
detail += String(format: "tele : %@\n", result.tele == nil ? "" : result.tele!)
detail += String(format: "center : %0.6f, %0.6f\n", result.center == nil ? 0 : result.center!.latitude, result.center == nil ? 0 : result.center!.longitude)
detail += String(format: "detailCode : %d\n", result.detailCode == nil ? "" : result.detailCode!)
detail += String(format: "gasoline : %d\n", result.price?.gasoline == nil ? "" : result.price!.gasoline!)
detail += String(format: "diesel : %d\n", result.price?.diesel == nil ? "" : result.price!.diesel!)
detail += String(format: "lpg : %d\n", result.price?.lpg == nil ? "" : result.price!.lpg!)
detail += String(format: "primiumGasoline : %d\n", result.price?.primiumGasoline == nil ? "" : result.price!.primiumGasoline!)
detail += String(format: "parkTotalNum : %d\n", result.parkingLot?.parkTotalNum == nil ? "" : result.parkingLot!.parkTotalNum!)
detail += String(format: "availableCount : %d\n", result.parkingLot?.availableCount == nil ? "" : result.parkingLot!.availableCount!)
detail += String(format: "bizHour : %d\n", result.parkingLot?.bizHour == nil ? "" : result.parkingLot!.bizHour!)
detail += String(format: "bizHourSat : %d\n", result.parkingLot?.bizHourSat == nil ? "" : result.parkingLot!.bizHourSat!)
detail += String(format: "bizHourSun : %d\n", result.parkingLot?.bizHourSun == nil ? "" : result.parkingLot!.bizHourSun!)
detail += String(format: "free : %d\n", result.parkingLot?.free == nil ? "" : result.parkingLot!.free!)
detail += String(format: "availableCar : %d\n", result.parkingLot?.availableCar == nil ? "" : result.parkingLot!.availableCar!)
detail += String(format: "basicMinute : %d\n", result.parkingLot?.basicMinute == nil ? "" : result.parkingLot!.basicMinute!)
detail += String(format: "basicFree : %d\n", result.parkingLot?.basicFee == nil ? "" : result.parkingLot!.basicFee!)
detail += String(format: "addMinute : %d\n", result.parkingLot?.addMinute == nil ? "" : result.parkingLot!.addMinute!)
detail += String(format: "addFee : %d\n", result.parkingLot?.addFee == nil ? "" : result.parkingLot!.addFee!)
detail += String(format: "oneDayFee : %d\n", result.parkingLot?.oneDayFee == nil ? "" : result.parkingLot!.oneDayFee!)
detail += String(format: "monthlyFee : %d\n", result.parkingLot?.monthlyFee == nil ? "" : result.parkingLot!.monthlyFee!)
detail += String(format: "echarge : %d\n", result.parkingLot?.echarge == nil ? "" : result.parkingLot!.echarge!)
detail += String(format: "echargeCd : %d\n", result.parkingLot?.echargeCd == nil ? "" : result.parkingLot!.echargeCd!)
detail += String(format: "startPoint : %d\n", result.tastyPlaceInfo?.startPoint == nil ? "" : result.tastyPlaceInfo!.startPoint!)
detail += String(format: "tastyPlaceInfo_menuPrice : %d\n", result.tastyPlaceInfo?.menuList?.menuPrice == nil ? "" : result.tastyPlaceInfo!.menuList!.menuPrice!)
self.simpleAlertView(detail, title: "POI 상세 정보", view: self)
}
}
Return
Return 정보는 Document를 참고해주세요.
func requestAroundPoi(_ depthText:String, radius:Int, sort:Int, location:CLLocationCoordinate2D?, priceType:String?, roadType:Int?, from:Int?, size:Int?, priorityHpay:String?, classList:Array<String>?, completion:@escaping (Array<FacilityInfo>?, Error?)->Void)
Descript
시설물 검색 요청
Parameters
Name {Type} | Description |
---|---|
depthText{String} | 시설물 분류 업종 명칭 |
radius{int} | 반경. m단위. 기본은 10000 |
sort{int} | 정렬 옵션 (1=추천순, 2=명칭순, 3=거리순) |
location{CLLocationCoordinate2D} | 해당 위치 좌표 |
roadType{int} | 해당 위치 도로종별 |
from{int} | 응답으로 받을 결과 시작 (0부터) |
size{int} | 응답으로 받을 결과 개수 (from값이 없을 경우 0부터) |
priorityHpay{String} | H-pay 가맹점 우선 표시 |
classList{Array<String>} | 종 내 하위 시설물(반복) |
completion{Array<FacilityInfo>} | 결과 클로져 |
Example
let api = PlayMapRestApi()
api.requestAroundPoi("주유소", radius: 5000, sort: 1, location: center, priceType: nil, roadType: nil, from: nil, size: nil, priorityHpay: nil, classList: nil) { (result, error)->Void in
if let pois = result {
for poi in pois {
if let pos = poi.center {
DispatchQueue.main.async {
let marker = PlayMapMarker(position: pos)
marker.title = poi.cname
self.mapView?.addMarker(marker)
}
}
}
DispatchQueue.main.async {
self.mapView?.fitMapBoundsToShowAllMarkers()
}
}
}
Return
Return 정보는 Document를 참고해주세요.
func requestGeocoding(_ keyword:String, sort:Int?, from:Int?, size:Int?, location:CLLocationCoordinate2D?, completion:@escaping (Array<AddressInfo>?, Error?)->Void)
Descript
Geocoding요청
Parameters
Name {Type} | Description |
---|---|
keyword{String} | 주소 검색어 |
sort{int} | 정렬 옵션 (1=추천순, 2=명칭순, 3=거리순) |
from{int} | 응답으로 받을 결과 시작 (0부터) |
size{int} | 응답으로 받을 결과 개수 (from값이 없을 경우 0부터) |
location{CLLocationCoordinate2D} | 해당 위치 좌표 |
completion{Array<AddressInfo>} | 결과 클로져 |
Example
let api = PlayMapRestApi()
api.requestGeocoding(“잠원동 36-36”, sort: nil, from: nil, size: nil, location: nil) { (result, error)->Void in
if let result = result {
for addrInfo in result {
if let center = addrInfo.center {
DispatchQueue.main.async {
self.mapView?.setCenter(CLLocationCoordinate2D(latitude: center.latitude, longitude: center.longitude), zoom: 19)
}
break
}
}
}
}
Return
Return 정보는 Document를 참고해주세요.
func requestReverseGeocoding(_ location:CLLocationCoordinate2D, addrType:String?, orderType:Int?, completion:@escaping (AddressInfo?, Error?)->Void)
Descript
Reverse Geocoding요청
Parameters
Name {Type} | Description |
---|---|
location{CLLocationCoordinate2D} | 해당 위치 좌표 |
addrType{String} | 응답으로 받을 주소 체계 (0=지번주소, 1=도로명주소) |
orderType{int} | 응답데이터 우선 순위 (0:주소 -> POI 검색하지않음, 1:POI > 주소 -> 라벨 일반 미구분 POI 우선, 2: 라벨 > POI > 주소 -> 라벨 우선) |
completion{AddressInfo} | 결과 클로져 |
Example
let api = PlayMapRestApi()
api.requestReverseGeocoding(center, addrType: nil, orderType: nil) { (result, error)->Void in
if let result = result {
DispatchQueue.main.async {
if let addr = result.addr {
let alert = UIAlertController(title: “”, message: addr, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "확인", style: UIAlertAction.Style.default, handler: nil))
view.present(alert, animated: true, completion: nil) }
}
}
}
Return
Return 정보는 Document를 참고해주세요.
func requestRoute(_ routeOptions:RouteOptions, completion:@escaping (Array<RouteResult>?, Error?)->Void)
Descript
경로 탐색 요청
Parameters
Name {Type} | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
routeOptions{RouteOptions} |
탐색 옵션
Properties
|
||||||||||||||||||||||||
completion{Array<RouteResult>} | 결과 클로져 |
Example
var routeOptions = RouteOptions()
routeOptions.startPoint = CLLocationCoordinate2D(latitude: 37.532283, longitude: 126.951886)
routeOptions.startName = "현대오토에버"
routeOptions.goalPoint = CLLocationCoordinate2D(latitude: 36.332272, longitude: 127.434053)
routeOptions.goalName = "대전역"
let api = PlayMapRestApi()
api.requestRoute(routeOptions) { (result, error)->Void in
if let result = result {
for routeResult in result {
var path:Array<CLLocationCoordinate2D> = []
for pos in routeResult.PosList {
let coord = CLLocationCoordinate2D(latitude: pos.Y, longitude: pos.X)
path.append(coord)
}
if path.count > 0 {
let polyline = PlayMapPolyline(coordinates: path)
polyline.strokeWidth = 4
polyline.strokeColor = .red
DispatchQueue.main.async {
self.mapView?.addPolyline(polyline)
self.mapView?.fitMapBoundsToShowAllPolylines()
}
}
}
let marker1 = PlayMapMarker(position: routeOptions.startPoint!)
marker1.icon = UIImage(named: "start")
let marker2 = PlayMapMarker(position: routeOptions.goalPoint!)
marker2.icon = UIImage(named: "end")
DispatchQueue.main.async {
self.mapView?.addMarker(marker1)
self.mapView?.addMarker(marker2)
}
}
}
Return
Return 정보는 Document를 참고해주세요.