0
이 두 함수를 만들었고 pippo() 함수를 호출하면 "치명적인 오류 : 선택적 값의 래핑 중 예기치 않게 nil이 발견되었습니다"라는 오류 메시지가 나타납니다.이 오류를 수정하기 위해이 mapView를 수정했습니다. .addAnnotation (hello) into mapView? .addAnnotation (hello),하지만 주석을지도에 표시하지 않습니다. caricamappa에서 pippo를 호출하면 주석이 성공적으로 추가되지만, 함수로드 맵을 분리하고 주석을 추가하고 싶습니다. 그것은 가능한가?두 개의 함수가있는 mapView에 주석 추가
> func caricamappa(){
> let styleURL = NSURL(string: "mapbox://**")
> let mapView = MGLMapView(frame: view.bounds,
> styleURL: styleURL as URL?)
> mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
> // Set the map’s center coordinate and zoom level.
> mapView.setCenter(CLLocationCoordinate2D(latitude: 46.370417,
> longitude: 8.411713),
> zoomLevel: 13, animated: false)
> view.addSubview(mapView)
> mapView.delegate = self
> }
>
> func pippo(){
> let hello = MGLPointAnnotation()
> hello.coordinate = CLLocationCoordinate2D(latitude: 46.376362, longitude: 8.396907)
> hello.title = "Hello world!"
> hello.subtitle = "Welcome to my marker"
> // Add marker `hello` to the map.
> mapView.addAnnotation(hello)
>
> }
>
>
>
> override func viewDidLoad() {
> super.viewDidLoad()
> caricamappa()
> pippo()
>
감사합니다. 이제 주석을 볼 수 있지만 function func mapView (_ mapView : MGLMapView, imageFor annotation : MGLAnnotation) -> MGLAnnotationImage? { let point = 주석을? CustomPointAnnotation 및 pippo에이 함수를 사용할 수 없습니다. –
죄송합니다. 질문을 이해할 수 없습니다. 원래 게시물에 코드를 추가 할 수 있으면 도와 드리겠습니다. – Magnas