Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Mapbox viewcontroller auto closing as soon as it opens #4742

Open
iamkhan001 opened this issue Jan 8, 2025 · 1 comment
Open

[Bug]: Mapbox viewcontroller auto closing as soon as it opens #4742

iamkhan001 opened this issue Jan 8, 2025 · 1 comment

Comments

@iamkhan001
Copy link

Mapbox Navigation SDK version

11.9.0

Steps to reproduce

Hi there,

I have created a simple Mapbox example following Mapbox integration steps.
But when I open the view controller it closes immediately

I have integrated native Mapbox SDK in my react native project.

below is how I'm calling the Mapbox view controller


import Foundation
import UIKit
import React

@objc(IMapsModule) class IMapsModule: NSObject {
  
  @objc func startNavigationActivity(_ tripId: String) {
    
    print("startNavigationActivity \(tripId)")
    NSLog("%@", tripId);

    DispatchQueue.main.async {
           // execute your code
        let vc = ViewController()
        let rctVc = RCTPresentedViewController()
        vc.modalPresentationStyle = .fullScreen
        rctVc?.present(vc, animated: true)
    }
    
  }
  
}

ViewController code

import UIKit
import MapboxMaps

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        let mapView = MapView(frame: view.bounds)
        let cameraOptions = CameraOptions(center:
            CLLocationCoordinate2D(latitude: 39.5, longitude: -98.0),
            zoom: 2, bearing: 0, pitch: 0)
        mapView.mapboxMap.setCamera(to: cameraOptions)
        mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

        view.addSubview(mapView)
    }
}

Expected behavior

It should keep the Mapbox view controller screen open

Actual behavior

The Mapbox view controller is closing

Is this a one-time issue or a repeatable issue?

repeatable

@iamkhan001 iamkhan001 added the bug Something isn’t working label Jan 8, 2025
@kried
Copy link
Contributor

kried commented Jan 8, 2025

Hi @iamkhan001

The sample code you provided only shows the Maps SDK usage and no Navigation SDK. The provided version v11.9.0 is the Maps SDK, not the Nav SDK version. The mapbox/mapbox-maps-ios project can be more suitable for Maps-related questions.

The problem you described seems more related to the React Native Configuration than to the usage of Mapbox SDKs. There are no reasons for the map view controller to be closed. Please look at the logic of how you change screens in your app.

1.mp4

You can also check, that you configured the public access token in your app.

It might be useful to take a look at a community-maintained React Native library

@kried kried removed the bug Something isn’t working label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants