From 4b6ca63d34e2ba0eccda9173e15010b6e7ee1a8f Mon Sep 17 00:00:00 2001 From: DAZABAMUKER Date: Thu, 22 Feb 2024 14:50:07 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EC=9D=80=EC=88=98=EB=8B=98=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=EC=83=89=20=EC=84=A4=EC=A0=95=ED=95=98=EC=84=B8?= =?UTF-8?q?=EC=9A=94=20=EC=83=89=EB=A7=8C=20=EC=B6=94=EA=B0=80=ED=95=98?= =?UTF-8?q?=EB=A9=B4=20=EB=90=A9=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TravelLiner/TravelLiner/KakaoMapView.swift | 54 ++++++++++++++-------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/TravelLiner/TravelLiner/KakaoMapView.swift b/TravelLiner/TravelLiner/KakaoMapView.swift index a51d610..2d046a3 100644 --- a/TravelLiner/TravelLiner/KakaoMapView.swift +++ b/TravelLiner/TravelLiner/KakaoMapView.swift @@ -54,6 +54,7 @@ struct KakaoMapView: UIViewRepresentable { //self.day_old = self.day } if !points.isEmpty { + //context.coordinator.createRouteStyleSet(day: self.day) context.coordinator.createRouteline(day: self.day, points: self.points) DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) { self.points = [] @@ -161,40 +162,53 @@ struct KakaoMapView: UIViewRepresentable { } // RouteStyleSet을 생성한다. - func createRouteStyleSet() { + func createRouteStyleSet(day: Int) { let mapView = self.controller?.getView("mapview") as? KakaoMap let manager = mapView?.getRouteManager() let _ = manager?.addRouteLayer(layerID: "RouteLayer", zOrder: 0) - let poiImage = UIImage(systemName: "arrowtriangle.up.fill")?.withTintColor(UIColor(red: 0.32, green: 0.68, blue: 0.95, alpha: 1.00)) - let poiResize = resizeImage(image: poiImage!, targetSize: CGSizeMake(20.0, 20.0)) - let patternImages = [poiResize, UIImage(systemName: "arrowtriangle.right.fill"), UIImage(systemName: "arrowshape.up.circle.fill")] + //let patternImages = [poiResize, UIImage(systemName: "arrowtriangle.right.fill"), UIImage(systemName: "arrowshape.up.circle.fill")] - // StyleSet에 pattern을 추가한다. - let styleSet = RouteStyleSet(styleID: "routeStyleSet1") - styleSet.addPattern(RoutePattern(pattern: patternImages[0]!, distance: 60, symbol: nil, pinStart: false, pinEnd: false)) + // styleSet.addPattern(RoutePattern(pattern: patternImages[1]!, distance: 6, symbol: nil, pinStart: true, pinEnd: true)) // styleSet.addPattern(RoutePattern(pattern: patternImages[2]!, distance: 6, symbol: UIImage(named: "route_pattern_long_airplane.png")!, pinStart: true, pinEnd: true)) - let colors = [ - UIColor(red: 0.68, green: 0.87, blue: 1.00, alpha: 1.00) + //MARK: - 은수님 경로색 여기 추가하세요 + let colors = [ // 색 여기 추가하세요 + UIColor(red: 0.68, green: 0.87, blue: 1.00, alpha: 1.00), + UIColor.black, + UIColor.red, + UIColor.green, + UIColor.blue, + UIColor.brown, + UIColor.cyan, + UIColor.darkGray ] - + //MARK: - 은수님 경로안 화살표 색 여기 추가하세요 + let patternColors = [ + UIColor(red: 0.32, green: 0.68, blue: 0.95, alpha: 1.00) + ] + //MARK: - 은수님 경로 아웃라인 여기 추가하세요 let strokeColors = [ UIColor.black ] + // 위 색 array 개수 동일하게 맞추세요 - let patternIndex = [-1, 0, 1, 2] - // 총 4개의 스타일을 생성한다. - for index in 0 ..< colors.count { - // 각 스타일은 1개의 표출 시작 레벨 = 0 인 PerLevelStyle을 갖는다. 즉, 전 레벨에서 동일하게 표출된다. - // Style의 패턴인덱스가 -1로 지정되는 경우, 패턴을 사용하지 않고 컬러만 사용한다. - let routeStyle = RouteStyle(styles: [PerLevelRouteStyle(width: 18, color: colors[index], strokeWidth: 4, strokeColor: strokeColors[index], level: 0, patternIndex: 0)]) + // StyleSet에 pattern을 추가한다. + for dayIndex in 0...day { + //MARK: - 은수님 주석 보고 변경하세요 + let patternImage = UIImage(systemName: "arrowtriangle.up.fill")?.withTintColor(patternColors[0]/*patternColors[dayIndex]로 변경하세요*/) + let patternResize = resizeImage(image: patternImage!, targetSize: CGSizeMake(20.0, 20.0)) + let styleSet = RouteStyleSet(styleID: "routeStyleSet\(dayIndex)") + styleSet.addPattern(RoutePattern(pattern: patternResize, distance: 60, symbol: nil, pinStart: false, pinEnd: false)) + + let routeStyle = RouteStyle(styles: [PerLevelRouteStyle(width: 16, color: colors[dayIndex], strokeWidth: 3, strokeColor: strokeColors[0]/*strokeColors[dayIndex]로 변경하세요*/, level: 0, patternIndex: 0)]) styleSet.addStyle(routeStyle) + + manager?.addRouteStyleSet(styleSet) } - manager?.addRouteStyleSet(styleSet) } func createRouteline(day: Int, points: [Places]) { @@ -212,7 +226,6 @@ struct KakaoMapView: UIViewRepresentable { // let points = (self.positions.days.filter({ $0.date == day }).first?.places ?? []).sorted(by: {$0.sequence < $1.sequence}).map{ // MapPoint(longitude: $0.longitude, latitude: $0.latitude) // } - print(self.day) let Points = points.map{MapPoint(longitude: $0.longitude, latitude: $0.latitude)} let segs = RouteSegment(points: Points, styleIndex: 0) //let seg = RouteSegment(points: points, styleIndex: styleIndex) @@ -228,7 +241,7 @@ struct KakaoMapView: UIViewRepresentable { // } // Route 생성을 위해 ID, styleID, zOrder, segment를 전달한다. - let routeOption = RouteOptions(styleID: "routeStyleSet1", zOrder: 0) + let routeOption = RouteOptions(styleID: "routeStyleSet\(day-1)", zOrder: 0) routeOption.segments = [segs] let routes = layer?.addRoute(option: routeOption) @@ -347,7 +360,8 @@ struct KakaoMapView: UIViewRepresentable { createLabelLayer() createPoiStyle() createPois(day: 1) - createRouteStyleSet() + createRouteStyleSet(day: positions.days.count-1) + print(positions.days.count-1, "!") createRouteline(day: 1, points: []) } From 91a722861cd90df6435175dbb61673ea47acaf94 Mon Sep 17 00:00:00 2001 From: eunsu Date: Thu, 22 Feb 2024 16:07:19 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=A3=BC=EC=84=9D=EB=82=B4=EC=9A=A9?= =?UTF-8?q?=EB=94=B0=EB=9D=BC=20=EC=83=89=20=EC=B6=94=EA=B0=80=20=EB=B0=8F?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TravelLiner/.DS_Store | Bin 6148 -> 6148 bytes .../TravelLiner.xcodeproj/project.pbxproj | 4 +-- TravelLiner/TravelLiner/KakaoMapView.swift | 23 +++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/TravelLiner/.DS_Store b/TravelLiner/.DS_Store index 835529adfca2129db0b074ba3bc10330f26fc78d..8c4794da81ca4ba1ef753a50783f56819ca136cc 100644 GIT binary patch delta 216 zcmZoMXfc=|#>B!ku~2NHo+2a1#(>?7ix)66F>*{+V3wM!#GW~copy$WFQ&Oq_DBDf^joD2R{eU-J2&ee`lV|FXG6-$iTn^G?rm= Igvc6Z01fFhI{*Lx delta 95 zcmZoMXfc=|#>B)qu~2NHo+2a5#(>?7j4YECSfwVbv1}7D*HJJuvNWsJQK&YwFf`Lq yFtaq7{DEchW-$&ymWd6?o7p+|Ie^+X3vzsCp3E=e$iV;vj0_Acn