Kakao 지도 화면을 보여주는 View Class.
MapView 객체를 통해 지도 종류 지정, 지도 화면 이동/확대/축소, 현위치 트래킹 및 나침반 모드, POI Item(MapPOIItem) 관리, Polyline(MapPolyline) 관리 등의 기능이 제공된다.
MapView.OpenAPIKeyAuthenticationResultListener, MapView.MapViewEventListener,
MapView.CurrentLocationEventListener, MapView.POIItemEventListener interface들을 구현하는 객체들을 등록하여 지도 모듈에서 발생하는 다양한 이벤트들을 통보받을 수 있다.
public MapView(Activity activity)
public MapView(Context context)
public MapView(Context context, AttributeSet attrs)
public MapView(Context context, AttributeSet attrs, int defStyle)
public static boolean isMapTilePersistentCacheEnabled()
지도 타일 이미지 Persistent Cache 기능 활성화 여부를 조회한다.
public static void setMapTilePersistentCacheEnabled(boolean enableCache)
지도 타일 이미지 Persistent Cache 기능은 네트워크를 통해 다운로드한 지도 이미지 데이터를 단말의 영구(persistent) 캐쉬 영역에 저장하는 기능이다.
같은 영역의 지도를 다시 로드할때 캐쉬에 저장된 지도 타일들은 네트워크를 거치지 않고 캐쉬에서 바로 로드하여 네트워크 사용량과 로딩 시간을 줄일 수 있다.
사용되지 않는 지도 타일 이미지 캐쉬 데이터는 MapView 동작 중에 자동으로 삭제되어 캐쉬 용량의 크기가 너무 커지지 않도록 조절된다.
Application의 Cache 영역 사용량이 부담이 되면 Cache 기능을 비활성화 하는 것이 좋다.
MapView가 동작하는 중에는 Cache 기능 활성화 설정 변경이 적용되지 않으며 MapView를 사용하기 전에 Cache 활성화 여부를 설정해야 한다.
일부 File I/O 성능이 좋지 않은 단말들에서는 캐쉬기능을 활성화 시 MapView의 성능이 떨어질수 있으며, 특정 단말들(SHW-M110S, SHW-M130K 등)은 File I/O 성능상의 이유로 setMapTilePersistentCacheEnabled() 메소드로 Cache 기능을 활성화 시키더라도 Cache 기능이 활성화되지 않는다.
enableCache
– Persistent Cache 기능 활성화 여부public static void clearMapTilePersistentCache()
Application의 cache 디렉토리(android.content.Context.getCacheDir())에 저장된 지도 타일 캐쉬 데이터를 모두 삭제한다.
MapView가 동작 중인 상태에서도 사용가능하다.
public void setOpenAPIKeyAuthenticationResultListener(MapView.OpenAPIKeyAuthenticationResultListener openAPIKeyAuthListener)
OpenAPIKeyAuthenticationResultListener interface를 구현하는 객체를 MapView 객체에 등록하여
APP KEY 인증 결과 이벤트를 통보받을 수 있다.
openAPIKeyAuthListener
– OpenAPIKeyAuthenticationResultListener interface 구현 객체public void setMapViewEventListener(MapView.MapViewEventListener mapViewEventListener)
MapViewEventListener interface를 구현하는 객체를 MapView 객체에 등록하여
지도 이동/확대/축소, 지도 화면 터치(Single Tap / Double Tap / Long Press) 이벤트를 통보받을 수 있다.
mapViewEventListener
– MapViewEventListener interface 구현 객체public void setCurrentLocationEventListener(MapView.CurrentLocationEventListener currentLocationEventListener)
CurrentLocationEventListener interface를 구현하는 객체를 MapView 객체에 등록하여
현위치 트래킹 이벤트를 통보받을 수 있다.
currentLocationEventListener
– CurrentLocationEventListener interface 구현 객체public void setPOIItemEventListener(MapView.POIItemEventListener poiItemEventListener)
POIItemEventListener interface를 구현하는 객체를 MapView 객체에 등록하여
POI 관련 이벤트를 통보받을 수 있다.
poiItemEventListener
– POIItemEventListener interface 구현 객체public MapView.MapType getMapType()
현재 보여주고 있는 지도 종류를 확인한다.
public void setMapType(MapView.MapType mapType)
지도 종류(기본 지도, 위성 지도, 하이브리드 지도)를 지정한다.
mapType
– 지도 종류public boolean isHDMapTileEnabled()
고해상도 지도 타일 사용 여부를 조회 한다.
화면의 한변이 480 pixel 이상인 단말에 대해서는 기본값이 true이며 그렇지 않은 경우엔 고해상도 지도 타일 사용 설정 기본값은 false로 설정되어 있다.
public void setHDMapTileEnabled(boolean enabled)
고해상도 지도 타일 사용 여부를 설정한다.
enabled
– 고해상도 지도 타일 사용 여부public void setCurrentLocationTrackingMode(MapView.CurrentLocationTrackingMode trackingMode)
현위치 트래킹 모드 및 나침반 모드를 설정한다.
– 현위치 트래킹 모드 : 지도화면 중심을 단말의 현재 위치로 이동시켜줌
– 나침반 모드 : 단말의 방향에 따라 지도화면이 회전됨
현위치 트래킹 모드만 On시키거나 현위치 트래킹 모드, 나침반 모드 둘다 On 시킬 수 있다.
현위치 트래킹/나침반 모드를 활성화 시키면 현위치 정보가 설정된 MapView.CurrentLocationEventListener 객체에 전달된다.
trackingMode
– 현위치 트랙킹 모드public MapView.CurrentLocationTrackingMode getCurrentLocationTrackingMode()
현재 설정된 현위치 트랙킹 모드를 확인한다.
public void setShowCurrentLocationMarker(boolean show)
현위치를 표시하는 아이콘(마커)를 화면에 표시할지 여부를 설정한다.
setCurrentLocationTrackingMode 메소드를
이용하여 현위치 트래킹 기능을 On 시키면 자동으로 현위치 마커가 보여지게 된다.
현위치 트래킹 기능을 Off한 후에 현위치 아이콘을 지도 화면에서 제거할 때 사용할 수 있다.
show
– 현위치 마커 표시 여부public boolean isShowingCurrentLocationMarker()
현위치를 표시하는 아이콘(마커)를 화면에 표시되는지 여부를 확인한다.
public void setCurrentLocationRadius(int meter)
현위치 마커를 중심으로 그릴 원의 반경을 지정한다.
meter
– 반경(단위:m)public void setCurrentLocationRadiusStrokeColor(int color)
현위치 마커를 중심으로 그릴 원의 선 색상을 지정한다.
color
– 선 색상, android.graphics.Color.argb(a, r, g, b)를 이용하여 지정한다.public void setCurrentLocationRadiusFillColor(int color)
현위치 마커를 중심으로 그릴 원의 채우기 색상을 지정한다.
color
– 채우기 색상, android.graphics.Color.argb(a, r, g, b)를 이용하여 지정한다.public void setCustomCurrentLocationMarkerImage(int id, MapPOIItem.ImageOffset anchorPointOffset)
현위치 아이콘으로 Custom 이미지를 사용하고자 하는 경우에 사용하고자 하는 Image의 resource id 와 지정한 이미지 상의 어느 지점이 현위치 좌표인지를 나타내는 ImageOffset 을 지정한다.
ImageOffset은 이미지 상의 Pixel 좌표를 지정한다. 이미지의 좌하단이 원점(0,0)이고 오른쪽 방향이 x+축, 위쪽 방향이 y+축이 된다.
예를들어, 이미지의 pixel 크기가 60×60인 Custom Image의 하단 변(edge)의 정중앙이 POI Item 좌표 지점에 해당된다면poiItem.setCustomImageAnchorPointOffset(new MapPOIItem.ImageOffset(30,0))
위와 같이 지정할 수 있다.
hdpi 기준으로 작업된 이미지를 지정하면 다른 dpi단말에서는 이미지가 자동으로 적절한 크기로 scaling되어 화면에 나타난다.
(단말의 dpi와 상관없이 물리적으로 비슷한 크기의 마커 이미지 크기로 보이도록)
public void setCustomCurrentLocationMarkerTrackingImage(int id, MapPOIItem.ImageOffset anchorPointOffset)
현위치 트래킹 아이콘으로 Custom 이미지를 사용하고자 하는 경우에 사용하고자 하는 Image의 resource id 와 지정한 이미지 상의 어느 지점이 현위치 좌표인지를 나타내는 ImageOffset 을 지정한다.
ImageOffset은 이미지 상의 Pixel 좌표를 지정한다. 이미지의 좌하단이 원점(0,0)이고 오른쪽 방향이 x+축, 위쪽 방향이 y+축이 된다.
예를들어, 이미지의 pixel 크기가 60×60인 Custom Image의 하단 변(edge)의 정중앙이 POI Item 좌표 지점에 해당된다면poiItem.setCustomImageAnchorPointOffset(new MapPOIItem.ImageOffset(30,0))
위와 같이 지정할 수 있다.
hdpi 기준으로 작업된 이미지를 지정하면 다른 dpi단말에서는 이미지가 자동으로 적절한 크기로 scaling되어 화면에 나타난다.
(단말의 dpi와 상관없이 물리적으로 비슷한 크기의 마커 이미지 크기로 보이도록)
public void setCustomCurrentLocationMarkerDirectionImage(int id, MapPOIItem.ImageOffset anchorPointOffset)
현위치 방향 아이콘으로 Custom 이미지를 사용하고자 하는 경우에 사용하고자 하는 Image의 resource id 와 지정한 이미지 상의 어느 지점이 현위치 좌표인지를 나타내는 ImageOffset 을 지정한다.
ImageOffset은 이미지 상의 Pixel 좌표를 지정한다. 이미지의 좌하단이 원점(0,0)이고 오른쪽 방향이 x+축, 위쪽 방향이 y+축이 된다.
예를들어, 이미지의 pixel 크기가 60×60인 Custom Image의 하단 변(edge)의 정중앙이 POI Item 좌표 지점에 해당된다면poiItem.setCustomImageAnchorPointOffset(new MapPOIItem.ImageOffset(30,0))
위와 같이 지정할 수 있다.
hdpi 기준으로 작업된 이미지를 지정하면 다른 dpi단말에서는 이미지가 자동으로 적절한 크기로 scaling되어 화면에 나타난다.
(단말의 dpi와 상관없이 물리적으로 비슷한 크기의 마커 이미지 크기로 보이도록)
public void setDefaultCurrentLocationMarker()
기본 제공되는 현위치 아이콘 이미지를 사용
public MapPoint getMapCenterPoint()
현재 지도 화면의 중심점을 조회한다.
public int getZoomLevel()
현재 지도 화면의 확대/축소 레벨을 조회 한다.
public float getMapRotationAngle()
현재 지도화면의 회전 각도(360 degree)를 조회 한다.
public void setMapCenterPoint(MapPoint centerPoint, boolean animated)
지도 화면의 중심점을 설정한다.
centerPoint
– 지도화면 중심점을 나타내는 MapPoint 객체public void setMapCenterPointAndZoomLevel(MapPoint centerPoint, int zoomLevel, boolean animated)
지도 화면의 중심점과 확대/축소 레벨을 설정한다.
centerPoint
– 지도화면 중심점을 나타내는 MapPoint 객체public void setZoomLevel(int zoomLevel, boolean animated)
지도 화면의 확대/축소 레벨을 설정한다.
zoomLevel
– 지도화면 확대 축소 레벨 값public void zoomIn(boolean animated)
지도 화면을 한단계 확대한다. (더 좁은 영역이 크게 보임)
확대/축소 레벨 값이 1 감소됨
animated
– 지도화면의 확대 시 애니매이션 효과를 적용할지 여부public void zoomOut(boolean animated)
지도 화면을 한단계 축소한다. (더 넓은 영역이 화면에 나타남)
확대/축소 레벨 값이 1 증가됨
animated
– 지도화면의 축소 시 애니매이션 효과를 적용할지 여부public void setMapRotationAngle(float angle, boolean animated)
지도 화면의 회전 각도를 설정한다.
angle
– 회전 각도 (0~360도)public void fitMapViewAreaToShowMapPoints(MapPoint[] mapPoints)
지정한 지도 좌표들이 모두 화면에 나타나도록 지도화면 중심과 확대/축소 레벨을 자동조절한다.
mapPoints
– 화면에 모두 보여주고자 하는 지도 좌표 리스트public void refreshMapTiles()
지도 화면에 나타나는 지도 타일들을 지도 타일 서버에서 다시 받아와서 갱신한다.
public void releaseUnusedMapTileImageResources()
지도 타일 이미지 캐쉬 데이터 들을 삭제하여 메모리를 확보할 수 있다.
public MapPOIItem[] getPOIItems()
지도화면에 보여주고 있는 POI 아이템 리스트를 조회할 수 있다.
public void addPOIItem(MapPOIItem poiItem)
지도화면에 POI Item 아이콘(마커)를 추가한다.
poiItem
– 추가할 POI Item 객체public void addPOIItems(MapPOIItem[] poiItems)
지도화면에 POI Item 아이콘(마커) 리스트를 추가한다.
poiItems
– 추가할 POI Item 객체 리스트public void selectPOIItem(MapPOIItem poiItem, boolean animated)
특정 POI Item 을 선택한다.
선택된 POI Item은 Callout Balloon(말풍선)이 아이콘(마커)위에 나타난다.
poiItem
– 선택할 POI Item 객체public void deselectPOIItem(MapPOIItem poiItem)
특정 POI Item 을 선택 해제한다.
선택 해제된 POI Item은 Callout Balloon(말풍선)이 POI 아이콘(마커)위에서 사라진다.
poiItem
– 선택 해제할 POI Item 객체public MapPOIItem findPOIItemByTag(int tag)
지도화면에 추가된 POI Item 들 중에서 tag값이 일치하는 POI Item을 찾는다.
tag
– 찾고자 하는 POI Item의 tag 값public MapPOIItem[] findPOIItemByName(String itemName)
지도화면에 추가된 POI Item 들 중에서 이름이 일치하는 POI Item 객체를 찾는다.
name
– 찾고자 하는 POI Item의 이름 문자열public void removePOIItem(MapPOIItem poiItem)
특정 POI Item을 지도화면에서 제거한다.
poiItem
– 제거하고자 하는 POI Item 객체public void removePOIItems(MapPOIItem[] poiItems)
POI Item 리스트를 지도화면에서 제거한다.
poiItems
– 제거하고자 하는 POI Item 객체 리스트public void removeAllPOIItems()
지도 화면에 추가된 모든 POI Item들을 제거한다.
public void fitMapViewAreaToShowAllPOIItems()
지도 화면에 추가된 모든 POI Item들이
화면에 나타나도록 지도 화면 중심과 확대/축소 레벨을 자동으로 조정한다.
public MapCircle[] getCircles()
public void addCircle(MapCircle circle)
지도화면에 circle 을 추가한다.
circle
– 추가할 MapCircle 객체public MapCircle findCircleByTag(int tag)
지도화면에 추가된 circle 들 중에서 tag값이 일치하는 circle 을 찾는다.
tag
– 찾고자 하는 circle 의 tag 값public void removeCircle(MapCircle circle)
특정 circle 을 지도화면에서 제거한다.
circle
– 제거하고자 하는 circle 객체public void removeAllCircles()
지도 화면에 추가된 모든 circle 을 제거한다.
public void fitMapViewAreaToShowCircle(MapCircle circle)
특정 Polyline의 모든 점들이 화면에 전부 나타나도록
지도 화면 중심과 확대/축소 레벨을 자동으로 조정한다.
polyline
– 화면에 보여주고자 하는 polylinepublic void fitMapViewAreaToShowAllCircle()
지도 화면에 추가된 모든 Polyline 들이
화면에 나타나도록 지도 화면 중심과 확대/축소 레벨을 자동으로 조정한다.
public MapPolyline[] getPolylines()
지도화면에 보여주고 있는 Polyline 리스트를 조회할 수 있다.
public void addPolyline(MapPolyline polyline)
지도화면에 Polyline을 추가한다.
polyline
– 추가할 Polyline 객체public MapPolyline findPolylineByTag(int tag)
지도화면에 추가된 Polyline들 중에서 tag값이 일치하는 Polyline을 찾는다.
tag
– 찾고자 하는 Polyline의 tag 값public void removePolyline(MapPolyline polyline)
특정 Polyline을 지도화면에서 제거한다.
polyline
– 제거하고자 하는 Polyline 객체public void removeAllPolylines()
지도 화면에 추가된 모든 Polyline을 제거한다.
public void fitMapViewAreaToShowPolyline(MapPolyline polyline)
특정 Polyline의 모든 점들이 화면에 전부 나타나도록
지도 화면 중심과 확대/축소 레벨을 자동으로 조정한다.
polyline
– 화면에 보여주고자 하는 polylinepublic void fitMapViewAreaToShowAllPolylines()
지도 화면에 추가된 모든 Polyline 들이
화면에 나타나도록 지도 화면 중심과 확대/축소 레벨을 자동으로 조정한다.
public void moveCamera(CameraUpdate cameraUpdate)
cameraUpdate 에 정의된 명령어에 따라 카메라를 재배치한다.
지도화면 위에 추가되는 POI Item에 해당하는 Class.
지도화면 위에 POI 아이콘(마커)를 추가하기 위해서는 MapPOIItem 객체를 생성하여 MapView 객체에 등록해 주어야 한다.MapView.addPOIItem(MapPOIItem)
MapView.addPOIItems(MapPOIItem[])
이미 제공되고 있는 POI Item 아이콘을 그대로 사용할 수도 있고, 개발자가 지정한 임의의 이미지를 POI Item 아이콘으로 사용할 수 있다.
MapView 객체에 등록된 POI Item을 사용자가 선택하면 POI Item 아이콘(마커)위에 말풍선(Callout Balloon)이 나타나게 되며 말풍선에는 POI Item 이름이 보여지게 된다.
단말 사용자가 길게 누른후(long press) 끌어서(dragging) 위치를 이동시킬 수 있는 Draggable POI Item 도 생성하여 MapView 에 등록할 수 있다.
public MapPOIItem()
public void setRotation(float rotation)
POI Item의 시계방향 rotation값을 지정한다.
default = 0.0f
rotation
– 각도(0.0f~360f)public void setAlpha(float alpha)
POI Item의 alpha값을 지정한다.
default = 1.0f
alpha
– 투명도(0.0f~1.0f)public float getAlpha()
alpha값을 가져온다.
public float getRotation()
rotation값을 가져온다.
public String getItemName()
POI Item 이름을 조회한다.
public void setItemName(String itemName)
POI Item 이름을 지정한다.
POI Item 아이콘이 선택되면 나타나는 말풍선(Callout Balloon)에 POI Item 이름이 보여지게 된다.
itemName
– POI Item 이름public MapPoint getMapPoint()
POI Item의 지도상 좌표를 조회한다.
public void setMapPoint(MapPoint mapPoint)
POI Item의 지도상 좌표를 설정한다.
mapPoint
– 좌표객체public MapPOIItem.MarkerType getMarkerType()
POI Item 아이콘(마커) 타입을 조회한다.
public void setMarkerType(MapPOIItem.MarkerType markerType)
POI Item 아이콘(마커) 타입을 설정한다.
기본 제공 POI Item 아이콘을 사용하거나, 개발자가 지정한 임의의 이미지를 POI Item 아이콘으로 사용할 수 있다.
default = MapPOIItem.MarkerType.BluePin
markerType
– POI Item 아이콘(마커) 타입public MapPOIItem.MarkerType getSelectedMarkerType()
public void setSelectedMarkerType(MapPOIItem.MarkerType markerType)
POI Item 선택 효과 아이콘(마커) 타입을 설정한다.
기본 제공 POI Item 아이콘을 사용하거나,
개발자가 지정한 임의의 이미지를 POI Item 선택 효과 아이콘으로 사용할 수 있다.
default = null
markerType
– POI Item 아이콘(마커) 타입public MapPOIItem.ShowAnimationType getShowAnimationType()
POI Item이 지도화면에 나타날때 애니매이션 종류 조회한다.
public void setShowAnimationType(MapPOIItem.ShowAnimationType showAnimationType)
POI Item이 지도화면에 나타날때 애니매이션 종류를 지정한다.
default = MapPOIItem.ShowAnimationType.NoAnimation
public boolean isShowCalloutBalloonOnTouch()
사용자가 POI Item 아이콘을 터치했을 때 말풍선(Callout Balloon)을 보여줄지 여부를 조회한다.
public void setShowCalloutBalloonOnTouch(boolean showCalloutBalloonOnTouch)
사용자가 POI Item 아이콘을 터치했을 때 말풍선(Callout Balloon)을 보여줄지 여부를 설정한다.
default = true
showCalloutBalloonOnTouch
– 터치 시 말풍선(Callout Balloon)을 보여줄지 여부public boolean isShowDisclosureButtonOnCalloutBalloon()
Disclosure Button 이미지 표시 여부 조회한다.
public void setShowDisclosureButtonOnCalloutBalloon(boolean showDisclosureButtonOnCalloutBalloon)
POI Item이 사용자에 의해 선택된 경우 나타나는 말풍선에 나타나는 글자 마지막에 Disclosure Button 이미지(꺽쇠(>)모양 이미지)를 표시할지 여부를 지정한다.
default = true
showDisclosureButtonOnCalloutBalloon
– Disclosure Button 이미지 표시 여부public void setLeftSideButtonResourceIdOnCalloutBalloon(int imageResourceId)
말풍선의 좌측 버튼에 개발자가 지정한 Custom 이미지를 사용하고자 하는 경우에 사용하고자 하는 Image의 resource id를 지정한다.
hdpi 기준으로 작업된 이미지를 지정하면 다른 dpi단말에서는 이미지가 자동으로 적절한 크기로 scaling되어 화면에 나타난다.
(단말의 dpi와 상관없이 물리적으로 비슷한 크기의 마커 이미지 크기로 보이도록)
public void setRightSideButtonResourceIdOnCalloutBalloon(int imageResourceId)
말풍선의 우측 버튼에 개발자가 지정한 Custom 이미지를 사용하고자 하는 경우에 사용하고자 하는 Image의 resource id를 지정한다.
hdpi 기준으로 작업된 이미지를 지정하면 다른 dpi단말에서는 이미지가 자동으로 적절한 크기로 scaling되어 화면에 나타난다.
(단말의 dpi와 상관없이 물리적으로 비슷한 크기의 마커 이미지 크기로 보이도록)
public int getLeftSideButtonResourceIdOnCalloutBalloon()
말풍선의 좌측 버튼에 개발자가 지정한 Custom 이미지 resource id를 가져온다.
public int getRightSideButtonResourceIdOnCalloutBalloon()
말풍선의 우측 버튼에 개발자가 지정한 Custom 이미지 resource id를 가져온다.
public boolean isDraggable()
POI Item이 사용자가 위치를 변경할 수 있는지 확인한다.
public void setDraggable(boolean draggable)
사용자가 위치를 변경할 수 있는 POI Item을 생성하려면 draggable property를 true로 설정한다.
Draggable POI Item을 사용자가 터치하면 POI Item을 사용자가 이동할 수 있음을 알려주는 안내문구가 지도화면에 나타난다.
사용자는 POI Item을 길게 누른 후(long press) 원하는 위치로 끌어서(dragging) 위치를 변경할 수 있다.
변경된 POI Item의 위치는 MapView.POIItemEventListener.onDraggablePOIItemMoved 메소드를 통해 통보받을 수 있다.
default = false
public int getTag()
POI Item 객체에 지정된 tag 값을 조회한다.
public void setTag(int tag)
POI Item 객체에 임의의 정수값(tag)을 지정할 수 있다.
MapView 객체에 등록된 POI Item들 중 특정 POI Item을 찾기 위한 식별자로 사용할 수 있다.
tag값을 반드시 지정해야 하는 것은 아니다.
public Object getUserObject()
해당 POI Item과 관련된 정보를 저장하고 있는 임의의 객체를 조회한다.
public void setUserObject(Object userObject)
해당 POI Item과 관련된 정보를 저장하고 있는 임의의 객체를 저장하고자 할때 사용한다.
사용자가 POI Item을 선택하는 경우 등에 선택된 POI Item과 관련된 정보를 손쉽게 접근할 수 있다.
public int getCustomImageResourceId()
markerType이 net.daum.mf.map.api.MapPOIItem.MarkerType.CustomImage인 경우
설정된 POI Item 아이콘 custom image의 resource id를 조회한다.
public int getCustomSelectedImageResourceId()
public void setCustomImageResourceId(int imageResourceId)
markerType이 net.daum.mf.map.api.MapPOIItem.MarkerType.CustomImage인 경우에만 지정한다.
기본 제공되는 POI Item 아이콘 이미지를 사용하지 않고, 개발자가 지정한 Custom 이미지를 사용하고자 하는 경우에
사용하고자 하는 Image의 resource id를 지정한다.
hdpi 기준으로 작업된 이미지를 지정하면 다른 dpi단말에서는 이미지가 자동으로 적절한 크기로
scaling되어 화면에 나타난다. (단말의 dpi와 상관없이 물리적으로 비슷한 크기의 마커 이미지 크기로 보이도록)
public void setCustomSelectedImageResourceId(int imageResourceId)
selectedMarkerType이 net.daum.mf.map.api.MapPOIItem.MarkerType.CustomImage인 경우에만 지정한다.
기본 제공되는 POI Item 아이콘 이미지를 사용하지 않고, 개발자가 지정한 Custom 이미지를 사용하고자 하는 경우에
사용하고자 하는 Image의 resource id를 지정한다.
hdpi 기준으로 작업된 이미지를 지정하면 다른 dpi단말에서는 이미지가 자동으로 적절한 크기로
scaling되어 화면에 나타난다. (단말의 dpi와 상관없이 물리적으로 비슷한 크기의 마커 이미지 크기로 보이도록)
public MapPOIItem.ImageOffset getCustomImageAnchorPointOffset()
Custom Image Anchor Point Offset 좌표를 조회한다.
public void setCustomImageAnchorPointOffset(MapPOIItem.ImageOffset customImageAnchorPointOffset)
markerType이 CustomImage 인 경우에만 지정한다.
customImageResourceId property에 지정한 이미지 상의 어느 지점이 POI Item의 좌표 지점에 해당하는 지를 설정한다.
이미지 상의 Pixel 좌표를 지정한다. 이미지의 좌하단이 원점(0,0)이고 오른쪽 방향이 x+축, 위쪽 방향이 y+축이 된다.
예를들어, 이미지의 pixel 크기가 60×60인 Custom Image의 하단 변(edge)의 정중앙이 POI Item 좌표 지점에 해당된다면poiItem.setCustomImageAnchorPointOffset(new MapPOIItem.ImageOffset(30,0))
위와 같이 지정할 수 있다.
값을 지정하지 않는 경우 이미지의 하단 중앙이 Anchor Point로 설정된다.
지도화면 위에 추가되는 Circle에 해당하는 Class.
MapCircle에 객체를 생성하여 MapView객체에 등록해 주어야 한다. MapView.addCircle(MapCircle)
public MapCircle(MapPoint center, int radius, int strokeColor, int fillColor)
public int getStrokeColor()
public void setStrokeColor(int strokeColor)
Circle의 선 색상을 지정한다.
strokeColor
– 선 색상, android.graphics.Color.argb(a, r, g, b)를 이용하여 지정한다.public int getFillColor()
public void setFillColor(int fillColor)
Circle의 채우기 색상을 지정한다.
fillColor
– 채우기 색상, android.graphics.Color.argb(a, r, g, b)를 이용하여 지정한다.public MapPoint getCenter()
public int getRadius()
public void setRadius(int radius)
Circle의 반경을 지정한다.
radius
– 반경(단위:m)public void setCenter(MapPoint center)
Circle의 중심점을 지정한다.
center
– 중심점의 좌표 객체public int getId()
public void setId(int id)
public int getTag()
Circle 객체에 지정된 tag 값을 조회한다.
public void setTag(int tag)
Circle 객체에 임의의 정수값(tag)을 지정할 수 있다.
net.daum.mf.map.api.MapView 객체에 등록된 Circle들 중 특정 Circle을 찾기 위한 식별자로 사용할 수 있다.
tag값을 반드시 지정해야 하는 것은 아니다.
이미지 상의 한 픽셀의 위치를 표현하는 데이터 구조
이미지의 좌하단이 offset (0,0)이 되고 오른쪽 방향이 x+ 위쪽 방향이 y+ 가 된다.
public MapPOIItem.ImageOffset(int offsetX,
int offsetY)
offsetX
– x 픽셀 좌표public int offsetX
x 픽셀 좌표
public int offsetY
y 픽셀 좌표
지도 화면 위 한 지점을 표현할 수 있는 Point Class.
지도 화면 위의 위치와 관련된 작업을 처리할 때 항상 MapPoint 객체를 사용한다.
MapPoint 객체는 위경도값(WGS84) 을 이용하여 생성하거나, 평면 좌표값(WCONG, CONG, WTM, …) 을 이용하여 생성할 수 있다.
public static MapPoint mapPointWithGeoCoord(double latitude, double longitude)
위경도 좌표 시스템(WGS84)의 좌표값으로 MapPoint 객체를 생성한다.
latitude
– 위도값public static MapPoint mapPointWithWCONGCoord(double xWCONG, double yWCONG)
WCONG 평면 좌표시스템의 좌표값으로 MapPoint 객체를 생성한다.
xWCONG
– WCONG x 좌표값public static MapPoint mapPointWithCONGCoord(double xCONG, double yCONG)
CONG 평면 좌표시스템의 좌표값으로 MapPoint 객체를 생성한다.
xCONG
– CONG x 좌표값public static MapPoint mapPointWithScreenLocation(double xPixel, double yPixel)
MapView의 좌상단 기준 Pixel 좌표값으로 MapPoint 객체를 생성한다.
xPixel
– Pixel x 좌표값public MapPoint.GeoCoordinate getMapPointGeoCoord()
MapPoint 객체가 나타내는 지점의 좌표값을 위경도 좌표시스템(WGS84)의 좌표값으로 조회한다.
public MapPoint.PlainCoordinate getMapPointWCONGCoord()
MapPoint 객체가 나타내는 지점의 좌표값을 WCONG 평면좌표계의 좌표값으로 조회한다.
public MapPoint.PlainCoordinate getMapPointCONGCoord()
MapPoint 객체가 나타내는 지점의 좌표값을 CONG 평면좌표계의 좌표값으로 조회한다.
public MapPoint.PlainCoordinate getMapPointScreenLocation()
MapPoint 객체가 나타내는 지점의 좌표값을 MapView 좌상단 기준 Pixel 좌표값으로 조회한다.
Geoid 타원체 상의 한 점을 표현하는 지도 좌표 타입 (WGS84)
위도(latitude)와 경도(longitude)값으로 구성된다.
public MapPoint.GeoCoordinate(double latitude, double longitude)
latitude
– 위도 값public double latitude
위도 값
public double longitude
경도 값
Geoid 상의 구면 좌표를 평면으로 프로젝션한 지도 좌표 정보를 저장하는 데이터 구조
평면 좌표 체계로는 WCONG, CONG, WTM, .. 등이 있다.
public MapPoint.PlainCoordinate(double x, double y)
x
– x 좌표값public double x
x 좌표값
public double y
y 좌표값
public MapPointBounds(MapPoint bottomLeft, MapPoint topRight)
public final MapPoint bottomLeft
public final MapPoint topRight
public boolean contains(MapPoint mapPoint)
public MapPoint getCenter()
지도화면 위에 추가되는 Polyline에 해당하는 Class.
Polyline은 여러 개의 점들을 순서대로 연결한 선들의 집합이다.
지도화면 위에 Polyline을 추가하여 경로나 영역등을 표현할 수 있다.
지도화면 위에 Polyline을 추가하기 위해서는 MapPolyline 객체를 생성하여 MapView 객체에 등록해 주어야 한다.
MapView.addPolyline(MapPolyline)
public MapPolyline()
public MapPolyline(int pointListCapacity)
pointListCapacity
– Polyline을 구성하는 점들의 좌표를 저장하는 Array의 메모리 할당 크기 (Polyline의 점 개수를 지정한다.)public Object[] getPointList()
Polyline을 구성하는 점들의 리스트를 조회한다.
public int getPointCount()
Polyline을 구성하는 점들의 개수를 조회한다.
public MapPoint getPoint(int index)
(index + 1) 번째 점을 조회한다.
index
– 조회하고자 하는 점의 Indexpublic void addPoint(MapPoint mapPoint)
Polyline에 점 하나를 추가한다.
Polyline 객체가 MapView에 등록된 후에는 점들을 추가해도 지도화면에 반영되지 않는다.
mapPoint
– 추가하고자 하는 점의 좌표 객체public void addPoints(MapPoint[] mapPoints)
Polyline에 점 리스트를 추가한다.
Polyline 객체가 MapView에 등록된 후에는 점들을 추가해도 지도화면에 반영되지 않는다.
mapPoints
– 추가하고자 하는 점들의 좌표 객체 리스트public int getLineColor()
public void setLineColor(int lineColor)
Polyline의 선 색상을 지정한다.
lineColor
– 선 색상, android.graphics.Color.argb(a, r, g, b)를 이용하여 지정한다.public int getTag()
Polyline 객체에 지정된 tag 값을 조회한다.
public void setTag(int tag)
Polyline 객체에 임의의 정수값(tag)을 지정할 수 있다.
MapView 객체에 등록된 Polyline들 중 특정 Polyline을 찾기 위한 식별자로 사용할 수 있다.
tag값을 반드시 지정해야 하는 것은 아니다.
지도 좌표를 주소 정보로 변환(Reverse Geo-Coding)하는 기능을 제공하는 Class
public MapReverseGeoCoder(String AppKey,
MapPoint mapPoint,
MapReverseGeoCoder.ReverseGeoCodingResultListener resultListener,
Activity contextActivity)
AppKey
– Native APP KEYpublic void startFindingAddress()
Reverse Geo-coding(Asynchronous) 서비스를 요청한다.
주소 정보는 비동기 방식으로 listener 객체에 전달된다.
public void cancelFindingAddress()
Reverse Geo-coding(Asynchronous) 서비스 요청을 취소한다.
public static String findAddressForMapPoint(String AppKey, MapPoint mapPoint)
동기(Synchronous, Blocking) 방식으로 Reverse Geo-coding 을 수행한다.
메소드를 호출한 thread는 Reverse Geo-Coding 서비스가 수행되는 동한 block된 후
변환된 주소정보를 리턴받는다.
AppKey
– Native APP KEYpublic CameraUpdateFactory()
public static CameraUpdate newMapPoint(MapPoint mapPoint)
지도 화면을 현재의 확대/축소 레벨을 유지한 상태로 설정한 중심점으로 이동한다.
mapPoint
– 이동하는 지도 화면의 중심점public static CameraUpdate newMapPoint(MapPoint mapPoint, float zoomLevel)
지도 화면을 설정한 확대/축소 레벨로 조정 및 설정한 중심점으로 이동한다.
mapPoint
– 이동하는 지도 화면의 중심점zoomLevel
– 변경된 지도 확대/축소 레벨public static CameraUpdate newMapPointAndDiameter(MapPoint mapPoint, float diameter)
설정한 중심점으로 이동하면서 지정한 직경(meter) 영역이 보이도록 줌레벨이 조정된다.
지정한 영역의 padding 값은 0
mapPoint
– 이동하는 지도 화면의 중심점diameter
– 직경(지름), meter단위public static CameraUpdate newMapPointAndDiameter(MapPoint mapPoint, float diameter, int padding)
설정한 중심점으로 이동하면서 지정한 직경(meter) 영역이 보이도록 줌레벨이 조정된다.
mapPoint
– 이동하는 지도 화면의 중심점diameter
– 직경(지름), meter단위padding
– 지정한 영역의 padding 값public static CameraUpdate newMapPointBounds(MapPointBounds mapPointBounds)
지정한 영역이 화면에 나타나도록 지도화면 중심과 확대/축소 레벨을 자동조절한다.
지정한 영역의 padding 값은 0.
mapPointBounds
– 화면에 보여주고자 하는 영역 (MapPoint 타입의 좌하단 지점과 우상단 지점을 인자로 갖는 구조체)public static CameraUpdate newMapPointBounds(MapPointBounds mapPointBounds, int padding)
padding 값을 반영한 지정한 영역이 화면에 지정된 나타나도록 지도화면 중심과 확대/축소 레벨을 자동조절한다.
bounds
– 화면에 보여주고자 하는 영역 (MapPoint 타입의 좌하단 지점과 우상단 지점을 인자로 갖는 구조체)padding
– 지정한 영역의 padding 값public static CameraUpdate newMapPointBounds(MapPointBounds mapPointBounds,
int padding,
float minZoomLevel,
float maxZoomLevel)
padding 값을 반영한 지정한 영역이 화면에 지정된 나타나도록 하되 지정한 최소 레벨과 최대 레벨 범위 안의 지도화면 중심과 확대/축소 레벨을 자동조절 한다.
bounds
– 화면에 보여주고자 하는 영역 (MapPoint 타입의 좌하단 지점과 우상단 지점을 인자로 갖는 구조체)padding
– 지정한 영역의 padding 값minZoomLevel
– 지도 화면 최대 확대 레벨 값 (-2~12, 값이 작을수록 더 좁은 영역이 화면이 보임. 지도 화면이 확대됨)maxZoomLevel
– 지도 화면 최대 축소 레벨 값 (-2~12, 값이 클수록 더 넓은 영역이 화면이 보임. 지도 화면이 축소됨)CurrentLocationEventListener interface를 구현하는 객체를 MapView 객체에 등록하여
현위치 트래킹 이벤트를 통보받을 수 있다.
void onCurrentLocationUpdate(MapView mapView, MapPoint currentLocation, float accuracyInMeters)
단말의 현위치 좌표값을 통보받을 수 있다.
MapView.setCurrentLocationTrackingMode 메소드를 통해
사용자 현위치 트래킹 기능이 켜진 경우(CurrentLocationTrackingMode.TrackingModeOnWithoutHeading, CurrentLocationTrackingMode.TrackingModeOnWithHeading)
단말의 위치에 해당하는 지도 좌표와 위치 정확도가 주기적으로 delegate 객체에 통보된다.
mapView
– MapView 객체void onCurrentLocationDeviceHeadingUpdate(MapView mapView, float headingAngle)
단말의 방향(Heading) 각도값을 통보받을 수 있다.
MapView.setCurrentLocationTrackingMode 메소드를 통해
사용자 현위치 트래킹과 나침반 모드가 켜진 경우(CurrentLocationTrackingMode.TrackingModeOnWithHeading)
단말의 방향 각도값이 주기적으로 delegate 객체에 통보된다.
mapView
– MapView 객체void onCurrentLocationUpdateFailed(MapView mapView)
현위치 갱신 작업에 실패한 경우 호출된다.
mapView
– MapView 객체void onCurrentLocationUpdateCancelled(MapView mapView)
현위치 트랙킹 기능이 사용자에 의해 취소된 경우 호출된다.
처음 현위치를 찾는 동안에 현위치를 찾는 중이라는 Alert Dialog 인터페이스가 사용자에게 노출된다.
첫 현위치를 찾기전에 사용자가 취소 버튼을 누른 경우 호출 된다.
mapView
– MapView 객체MapViewEventListener interface를 구현하는 객체를 MapView 객체에 등록하여
지도 이동/확대/축소, 지도 화면 터치(Single Tap / Double Tap / Long Press) 이벤트를 통보받을 수 있다.
void onMapViewInitialized(MapView mapView)
MapView가 사용가능 한 상태가 되었음을 알려준다.
onMapViewInitialized()가 호출된 이후에 MapView 객체가 제공하는 지도 조작 API들을 사용할 수 있다.
void onMapViewCenterPointMoved(MapView mapView, MapPoint mapCenterPoint)
지도 중심 좌표가 이동한 경우 호출된다.
mapView
– MapView 객체void onMapViewZoomLevelChanged(MapView mapView, int zoomLevel)
지도 확대/축소 레벨이 변경된 경우 호출된다.
mapView
– MapView 객체void onMapViewSingleTapped(MapView mapView, MapPoint mapPoint)
사용자가 지도 위를 터치한 경우 호출된다.
mapView
– MapView 객체void onMapViewDoubleTapped(MapView mapView, MapPoint mapPoint)
사용자가 지도 위 한 지점을 더블 터치한 경우 호출된다.
mapView
– MapView 객체void onMapViewLongPressed(MapView mapView, MapPoint mapPoint)
사용자가 지도 위 한 지점을 길게 누른 경우(long press) 호출된다.
mapView
– MapView 객체void onMapViewDragStarted(MapView mapView, MapPoint mapPoint)
사용자가 지도 드래그를 시작한 경우 호출된다.
mapView
– MapView 객체void onMapViewDragEnded(MapView mapView, MapPoint mapPoint)
사용자가 지도 드래그를 끝낸 경우 호출된다.
mapView
– MapView 객체void onMapViewMoveFinished(MapView mapView, MapPoint mapPoint)
지도의 이동이 완료된 경우 호출된다.
mapView
– MapView 객체OpenAPIKeyAuthenticationResultListener interface를 구현하는 객체를 MapView 객체에 등록하여
APP KEY 인증 결과 이벤트를 통보받을 수 있다.
void onDaumMapOpenAPIKeyAuthenticationResult(MapView mapView, int resultCode, String resultMessage)
설정한 APP KEY값을 인증 서버에 요청하여 인증 여부를 통보받을 수 있다.
APP KEY 는 Android Application Package Name당 하나씩 카카오 개발자 APP KEY 발급 페이지 를 통해서 발급할 수 있다.
mapView
– MapView 객체POIItemEventListener interface를 구현하는 객체를 MapView 객체에 등록하여
POI 관련 이벤트를 통보받을 수 있다.
void onPOIItemSelected(MapView mapView, MapPOIItem poiItem)
단말 사용자가 POI Item을 선택한 경우 호출된다.
사용자가 MapView 에 등록된 POI Item 아이콘(마커)를 터치한 경우 호출된다.
mapView
– MapView 객체@Deprecated
void onCalloutBalloonOfPOIItemTouched(MapView mapView, MapPOIItem poiItem)
Deprecated.
mapView
– MapView 객체void onCalloutBalloonOfPOIItemTouched(MapView mapView,
MapPOIItem poiItem,
MapPOIItem.CalloutBalloonButtonType buttonType)
void onDraggablePOIItemMoved(MapView mapView, MapPOIItem poiItem, MapPoint newMapPoint)
단말 사용자가 길게 누른 후(long press) 끌어서(dragging) 위치 이동이 가능한 POI Item의 위치를 이동시킨 경우 호출된다.
이동가능한 POI Item을 Draggable POI Item 이라 한다.
mapView
– MapView 객체Reverse Geo-Coding 결과를 비동기적으로 통보받는 listener 객체가 구현해야하는 interface
void onReverseGeoCoderFoundAddress(MapReverseGeoCoder rGeoCoder, String addressString)
주소를 찾은 경우 호출된다.
rGeoCoder
– MapReverseGeoCoder 객체void onReverseGeoCoderFailedToFindAddress(MapReverseGeoCoder rGeoCoder)
Reverse Geo-Coding 서비스 호출에 실패한 경우 호출된다.
rGeoCoder
– MapReverseGeoCoder 객체현위치 트랙킹 타입 enumeration
public static final MapView.CurrentLocationTrackingMode TrackingModeOff
현위치 트랙킹 모드 및 나침반 모드 Off
public static final MapView.CurrentLocationTrackingMode TrackingModeOnWithoutHeading
현위치 트랙킹 모드 On, 단말의 위치에 따라 지도 중심이 이동한다. 나침반 모드는 꺼진 상태
public static final MapView.CurrentLocationTrackingMode TrackingModeOnWithHeading
현위치 트랙킹 모드 On + 나침반 모드 On, 단말의 위치에 따라 지도 중심이 이동하며 단말의 방향에 따라 지도가 회전한다.(나침반 모드 On)
지도 종류 enumeration
public static final MapView.MapType Standard
기본 지도
public static final MapView.MapType Satellite
위성 지도
public static final MapView.MapType Hybrid
하이브리드 지도
POI Item 말풍선 버튼 타입 enumeration
public static final MapPOIItem.CalloutBalloonButtonType MainButton
public static final MapPOIItem.CalloutBalloonButtonType LeftSideButton
public static final MapPOIItem.CalloutBalloonButtonType RightSideButton
POI Item 아이콘(마커) 타입 enumeration
public static final MapPOIItem.MarkerType BluePin
파란색 핀
public static final MapPOIItem.MarkerType RedPin
빨간색 핀
public static final MapPOIItem.MarkerType YellowPin
노란색 핀
public static final MapPOIItem.MarkerType CustomImage
개발자가 지정한 POI Item 아이콘 이미지 사용
POI Item이 화면에 추가될때 애니매이션 타입 enumeration
public static final MapPOIItem.ShowAnimationType NoAnimation
애니매이션 없음
public static final MapPOIItem.ShowAnimationType DropFromHeaven
POI Item 아이콘이 하늘에서 지도 위로 떨어지는 애니매이션
public static final MapPOIItem.ShowAnimationType SpringFromGround
POI Item 아이콘이 땅위에서 스프링처럼 튀어나오는 듯한 애니매이션