18
-i- Ver2.0 MGIS Open API – 지도 Viewer (iOS 용) DawulGeoinfo

MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-i- Ver2.0

MGIS Open API

– 지도 Viewer

(iOS 용)

DawulGeoinfo

Page 2: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-ii- Ver2.0

양면 인쇄

Page 3: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-iii- Ver2.0

변경 이력

변경코드 내 용 변경일자

1.0 초안 작성 11/20

2.0 바로이맵 버전 변경 15/12

Page 4: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-iv- Ver2.0

목차

1. 클래스 참조 ................................................................... 1

1.1. MNTMapView 클래스 .................................................................. 1

1.1.1. Initializer ............................................................................................... 1

1.1.2. Constants .............................................................................................. 1

1.1.3. Properties.............................................................................................. 1

1.1.4. Methods ................................................................................................ 2

1.2. MNTMapViewDelegate ................................................................ 3

1.2.1. Protocol Methods ................................................................................... 3

1.3. MNTileLayer ............................................................................... 4

1.3.1. Properties.............................................................................................. 4

1.3.2. Methods ................................................................................................ 4

1.4. MNTOverlayObject ...................................................................... 5

1.4.1. Properties.............................................................................................. 5

1.4.2. Relatied Classes ..................................................................................... 5

2. 튜토리얼 ........................................................................ 6

3. MapView SDK 샘플 ...................................................... 8

3.1. 초기화 ....................................................................................... 9

3.2. 지도 서비스 선택....................................................................... 9

3.3. Marker 매쉬업 ......................................................................... 10

3.4. Tooltip 매쉬업 .......................................................................... 10

3.5. InfoWindow 매쉬업 .................................................................. 11

3.6. 공간 객체 매쉬업..................................................................... 11

3.7. 거리재기 .................................................................................. 12

Page 5: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-v- Ver2.0

3.8. 면적 재기 ................................................................................ 12

3.9. 좌표 변환 ................................................................................ 12

Page 6: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-1- Ver1.0

1. 클래스 참조

지도 표출, 매쉬업 도구, 이벤트 처리를 빠르고 손쉽게 응용 어플리케이션에서 활용 가능

하도록 제공되는 라이브러리로 대표 클래스는 지도 뷰, 매쉬업도구, 이벤가 제공됩니다.

본 문서에서는 대표 클래스에 대한 정의를 서술하였고 세부 참조는 제공되는 개발용 도움말

문서를 참조 바랍니다.

class Description

MNTMapView 지도를 표현하는 View 클래스

MNTMapViewDelegate 지도 이벤트 프로토콜 정의

MNTTileLayer 타일지도들의 정보를 저장하고 있는 클래스

MNTOverlayObject 공간 정보를 표현하는 상위 객체

1.1. MNTMapView 클래스

@interface MNTMapView : UIView

지도를 표현하고, 컨트롤 하는 주요 함수들을 제공하는 메인 클래스

1.1.1. Initializer

Methods Description

- (id)initWithFrame:(CGRect)frame

setDelegate:(id<MNTMapViewDelegate>)delegate

authKey:(NSString*)_authKey

기본 초기화

(발급받은 인증키 값)

1.1.2. Constants

Methods Description

SGeoEllips {dkBessel1984 = 0, dkWgs84 = 1}; 타원체

SGeoSystem {dkGeographic = 0, dkTmWest = 1, dkTmMid = 2, dkTmEast =

3, dkKatec = 4, dkUtm52 = 5, dkUtm51 = 6, dkUtmKr=7, dkTmMid60=8};

좌표계

1.1.3. Properties

Methods Description

@property (nonatomic, readonly) MapView* mapView; 지도 개체

Page 7: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-2- Ver1.0

1.1.4. Methods

Methods Description

+ (NSString*)getAuthKey 인증키 반환 함수

- (void)changeMapScreenArea:(CGRect)frame 뷰에 보여지는 지도 화면 영역

을 변경하는 함수

- (void)reDrawMap 지도 뷰를 갱신하는 함수

- (BOOL)setTileLayer:(int)tileLayerID 화면에 표시될 타일 레이어 ID

를 설정하는 함수

- (MNTTileLayer*)getTileLayer 화면에 표시되고 있는 타일 레

이어를 반환하는 함수

- (MNTTileLayer*)getTileLayerById:(int)tileLayerId 타일 레이어 아이디를 통하여

해당 타일 레이어 객체를 반환

하는 함수

- (int)getTileLayerCount 전체 타일 레이어 개수를 반환

하는 함수

- (DGeoRect)getNowMBR 현재 뷰의 지도 영역을 리턴하

는 함수

- (void)setMapCenter:(DGeoPoint)coordXY

aniTime:(float)nAniTime

지도 중심 이동 함수

- (DGeoPoint)getMapCenter 지도 중심 반환 함수

- (void)setMapLevel:(int)nLevel aniTime:(float)nAniTime 지도 레벨 변경 함수

- (int)getMapLevel 지도 레벨 반환 함수

- (DGeoPoint)getMapCurPos 현재의 사용자 위치 반환 함수

- (void)zoomIn:(float)nAniTime 지도 레벨을 한단계 확대

- (void)zoomOut:(float)nAniTime 지도 레벨을 한단계 축소

- (void)setUserLocation:(DGeoPoint)coordXY

accuracy:(float)accuracy

사용자 위치를 지도에 설정하

는 함수

- (void)setUserLocationImage:(UIImage*)userLocationImage

centerXMove:(int)cxMove centerYMove:(int)cyMove

사용자 위치 표시 아이콘 이미

지를 설정하는 함수

- (void)showUserLoaction:(BOOL)bShow

bBoundaryShow:(BOOL)bBoundaryShow

bAnimation:(BOOL)bAnimation

사용자 위치 표시 유무 설정

함수

- (void)doMeasureDist:(BOOL)bStart 거리재기 설정 함수

- (void)doMeasureArea:(BOOL)bStart 면적재기 설정 함수

- (BOOL)addOverlay:(MNTOverlayObject*)obj 오버레이 객체를 추가하는 함

Page 8: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-3- Ver1.0

- (void)showOverlay:(int)objID bShow:(BOOL)bShow 오버레이 객체의 표시 유무 설

정 함수

- (BOOL)removeOverlay:(int)objID 오버레이 객체를 제거하는 함

- (void)removeAllOverlay 모든 오버레이 객체를 제거하

는 함수

- (DGeoPoint)geoSystemConv:(DGeoPoint)geoPoint

srcEllipse:(int)srcEllipse

srcSystem:(int)srcSystem

dstEllipse:(int)dstEllipse

dstSystem:(int)dstSystem

좌표 변환 함수

1.2. MNTMapViewDelegate

@protocol MNTMapViewDelegate <NSObject>

지도 이벤트를 처리하기 위한 프로토콜 메소드를 정의

1.2.1. Protocol Methods

Methods Description

- (void)onMapView:(MNTMapView *)mapView

initHandler:(MNTMapError *)error

지도 구동 시에 발생되는

에러 메시지 전달 이벤트

핸들러

- (void)onMapView:(MNTMapView *)mapView

touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

withLocation:(DGeoPoint)location

지도 영역 터치 시작

(Touch Down) 이벤트 핸

들러

- (void)onMapView:(MNTMapView *)mapView

touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

withLocation:(DGeoPoint)location

지도 영역 터치이동(Touch

Move) 이벤트 핸들러

- (void)onMapView:(MNTMapView *)mapView

touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

withLocation:(DGeoPoint)location

지도 영역 터치완료(Touch

Up) 시작 이벤트 핸들러

- (void)onMapViewTouchesCanceled:(MNTMapView *)mapView 지도 영역 터치 취소 이벤

트 핸들러

Page 9: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-4- Ver1.0

- (void)onMapViewLongTouched:(MNTMapView *)mapView

withLocation:(DGeoPoint)location

지도 영역 롱 터치 이벤트

핸들러

- (void)onMapView:(MNTMapView *)mapView

didChangedMapLevel:(int)level

지도 레벨 변경 이벤트 핸

들러

- (void)onMapView:(MNTMapView *)mapView

didChangedMapCenter:(DGeoPoint)location

지도 중심 좌표 변경 이벤

트 핸들러

- (void)onMapView:(MNTMapView *)mapView

didChangedMapRect:(DGeoRect)worldRect

지도 영역 변경 이벤트 핸

들러

- (void)onMapView:(MNTMapView *)mapView

overlayView:(MNTOverlayView*)overlayView

clickedOverlayObject:(MNTOverlayObject*)object

지도 오버레이 객체 선택

시의 이벤트 핸들러

1.3. MNTileLayer

@interface MNTTileLayer : NSObject

서버로 부터 수신한 표출 가능 지도 정보를 담고 있는 클래스

1.3.1. Properties

Methods Description

@property(nonatomic, retain) NSString* mapName; 지도 이름

@property(nonatomic, retain) NSString* image_host_url; 지도 호출 URL

@property double tileArea_MinX; 지도의 좌측 X좌표(UTM_K원

점)

@property double tileArea_MaxX; 지도의 우측 X좌표(UTM_K원

점)

@property double tileArea_MinY; 지도의 하단 Y좌표(UTM_K원

점)

@property double tileArea_MaxY; 지도의 상단 Y좌표(UTM_K원

점)

@property double originX; 지도의 시작 X 좌표

@property double originY; 지도의 시작 Y 좌표

@property int tileImageSize; 타일 크기 (픽셀단위)

1.3.2. Methods

Methods Description

Page 10: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-5- Ver1.0

- (int)addScale:(double)scale; 타일 레이어의 축적을 세팅하는 함수

- (double)getScaleByLevel:(int)nLevel 레벨에 대한 축적 정보를 반환하는 함수

- (int)getMinLevel 최소 레벨의 정보를 반환하는 함수

- (int)getMaxLevel 최대 레벨의 정보를 반환하는 함수

- (DGeoRect)getMBRDGeoRect 지도 영역 정보를 반환하는 함수

1.4. MNTOverlayObject

@protocol MNTOverlay <NSObject>

@interface MNTOverlayObject : NSObject <MNTOverlay>

공간 정보를 표현하는 상위 객체

1.4.1. Properties

Methods Description

@property (nonatomic, retain) MNTOverlayView*

_parentOverlayView

지도 개체에 생성된 오버레이 뷰

포인트

@property (nonatomic, readonly) MNTOverlayObject*

attachedParent

부모 포인트

@property (nonatomic, readonly) MNTOverlayObject*

attachedClient

자식 포인트

1.4.2. Relatied Classes

MNTMarker Class, MNTToolTip Class, MNTInfoWindow Class, MNTCircle Class, MNTPolyline

Class, MNTPolygon Class 와 연계되어 사용됨.

Page 11: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-6- Ver1.0

2. 튜토리얼

XCode를 다운로드 받는 과정

1) XCode 개발툴은 애플 개발자

사이트(https://developer.apple.com/devcenter/ios/index.action) 에서 다운로드 받을 수

있습니다. 아래 그림은 이 사이트의 초기 화면입니다.

아래의 Downloads 탭의 Xcode 4 를 누르고 들어가서 개발 툴을 설치한다.

Page 12: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-7- Ver1.0

2) 서울시 open api 제공 사이트에서 iOS용 map toolkit을 다운로드 받습니다.

3) 아래의 방법으로 개발하고자 하는 프로그램에 map toolkit 라이브러리를 적용합니다.

A) Distribute,MapAPI 폴더를 라이브러리 파일을 적용하려는 프로젝트 디렉토리에

복사합니다.

B) Xcode 툴에서 임포트 하여 프로젝트에 포함시킵니다. (Finder 에서 파일 및 디렉토리를

끌어다 놓으면 됩니다)

C) 아래의 사진과 같이 Build Settings를 수정합니다.

([Linking Tab] >> Other Linker Flags : -lstdc++을 입력)

Page 13: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-8- Ver1.0

3. MapView SDK 샘플

MapViewSDK에서 제공되는 API를 활용하여 샘플 프로그램과 샘프 코드를 제공합니다.

MapNTechSample iOS용 프로젝트 소스 파일

<구동 초기 화면>

Page 14: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-9- Ver1.0

3.1. 초기화

지도 객체를 생성하고 초기 지도 정보를 설정합니다.

참조 – ViewController.m의viewDidLoad 함수 참조

아래의 프로토콜 메소드의 error 가 정상(nil)이면 지도 조작 정보를 설정한다.

⌘ 에러가 발생한 경우에는 정상적인 지도 표시가 어려움으로 이에 대한 적절한 조치를 취

해야 합니다.

(Error Code : -100 : 지도 정보 수신 실패

-200 : 인증 실패 )

3.2. 지도 서비스 선택

다국어 지도를 선택합니다. 제공되는 지도의 종류는 일반지도(국문,영문,일문,중문간체,중문번

체), 항공지도(국문,영문,일문,중문간체,중문번체)를 제공합니다.

참조 - ViewController.m의btnMapSelectAction () 함수 참조

Page 15: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-10- Ver1.0

3.3. Marker 매쉬업

지도위의 지점에 이미지 또는 텍스트로 매쉬업 합니다.

참조 - ViewController.m의actionAddPin () 함수 참조

3.4. Tooltip 매쉬업

지도 위의 지점에 툴팁으로 매쉬업 합니다.

참조 - ViewController.m의actionAddToolTipBtn () 함수 참조

Page 16: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-11- Ver1.0

3.5. InfoWindow 매쉬업

지도 위의 지점에 인포윈도우로 매쉬업 합니다.

참조 - ViewController.m의 actionAddInfoWidowBtn () 함수 참조

3.6. 공간 객체 매쉬업

Point, Polyline, Polygon, Circle, Envelope의 공간 객체를 지도 위에 매쉬업 한다.

참조 - ViewController.m의 actionOverlay () 함수 참조

Page 17: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-12- Ver1.0

3.7. 거리재기

지도 위에서 Touch를 통하여 거리를 측정합니다.

참조 - ViewController.m의 actionMeasureDistBtn () 함수 참조

3.8. 면적 재기

지도 위에서 Touch를 통하여 면적을 측정합니다.

참조 - ViewController.m의 actionMeasureAreaBtn () 함수 참조

3.9. 좌표 변환

단말기의 GPS 에서 측위되는 좌표를 GRS80 TM 중부원점 평면 좌표계로 변환합니다.

참조 - MapViewSDKActivity.java의 onLocationChanged () 함수 참조

Page 18: MGIS Open API - Seoulmap.seoul.go.kr/smgis/ucdoc/sdk/ios/MGIS_MapViewer_iOS_Doc.pdf · 좌표 변환 ..... 12 -1- ver1.0 1. 클래스 참조 지도 표출, 매쉬업 도구, 이벤트

-13- Ver1.0

양면 인쇄