2021. 4. 16. 03:02ㆍ아이폰 개발
iOS앱에서 애플맵을 사용하여 개발할때 참고할 만한 레퍼런스:
www.raywenderlich.com/7738344-mapkit-tutorial-getting-started#toc-anchor-004
MapKit Tutorial: Getting Started
Learn to use the powerful MapKit framework to build an interactive map, displaying location details and launching Maps for driving directions.
www.raywenderlich.com
medium.com/swlh/add-a-map-to-your-app-with-mapkit-and-core-location-ios-swift-guide-8ea9c236d895
Add a Map to your App with MapKit and Core Location— iOS Swift Guide
Apple offers to developers tools to integrate Geolocation and Map features to their Apps with MapKit and CoreLocation…
medium.com
위의 첫번째 튜토리얼에서 geojson 파일을 Bundle에서 찾지 못할때 조치 방법
The issue is that the file isn't being copied to your app bundle. To fix it:
Click your project
Click your target
Select Build Phases
Expand Copy Bundle Resources
Click '+' and select your file.
stackoverflow.com/questions/41775563/bundle-main-pathforresourceoftypeindirectory-returns-nil
Bundle.main.path(forResource:ofType:inDirectory:) returns nil
Try not to laugh or cry -- I'm just getting back into coding after 20 years out... I've spent more than 4 hours looking at references and trying code snippets to get Bundle.main.path to open my tex...
stackoverflow.com
MapKit 상에서 long press를 이용하여 마커 표시하기
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
let longTapGesture = UILongPressGestureRecognizer(target: self, action: #selector(longTap))
mapView.addGestureRecognizer(longTapGesture)
}
@objc func longTap(sender: UIGestureRecognizer){
print("long tap")
if sender.state == .began {
let locationInView = sender.location(in: mapView)
let locationOnMap = mapView.convert(locationInView, toCoordinateFrom: mapView)
addAnnotation(location: locationOnMap)
}
}
func addAnnotation(location: CLLocationCoordinate2D){
let annotation = MKPointAnnotation()
annotation.coordinate = location
annotation.title = "Some Title"
annotation.subtitle = "Some Subtitle"
self.mapView.addAnnotation(annotation)
}
}
extension ViewController: MKMapViewDelegate{
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard annotation is MKPointAnnotation else { print("no mkpointannotaions"); return nil }
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId) as? MKPinAnnotationView
if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true
pinView!.rightCalloutAccessoryView = UIButton(type: .infoDark)
pinView!.pinTintColor = UIColor.black
}
else {
pinView!.annotation = annotation
}
return pinView
}
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
print("tapped on pin ")
}
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control == view.rightCalloutAccessoryView {
if let doSomething = view.annotation?.title! {
print("do something")
}
}
}
}
medium.com/@calmone/ios-mapkit-in-swift-4-drop-the-pin-at-the-point-of-long-press-2bed878fdf93
iOS MapKit in Swift 4 : Drop the pin at the point of long press
Preview
medium.com
swift-it-world.tistory.com/24?category=419192
Swift 현재 위치 받아오기 (위도, 경도)
CoreLocation을 이용하여 위치정보를 받아와 위도 경도를 알아낼 수 있습니다. 주석에 각 코드의 설명을 적어놓았습니다. Info.plist에 Privacy - Location When In Use Usage Description을 추가하여 Value 부분..
swift-it-world.tistory.com