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

Clustering empty #1

Closed
nitrag opened this issue Sep 26, 2016 · 7 comments
Closed

Clustering empty #1

nitrag opened this issue Sep 26, 2016 · 7 comments

Comments

@nitrag
Copy link
Contributor

nitrag commented Sep 26, 2016

I've followed your clustering example (here) and my mapview is coming up empty (no points). Is there something else that needs to be done outside this file? Like in the map's style itself on Mapbox Studio Editor? Or on mapView itself?

Sidenote: trying to clone your example project and get it working but running into difficulties...

@nitrag
Copy link
Contributor Author

nitrag commented Sep 26, 2016

Ok, I got your project working, had to convert to Swift 3 and hack swiftyjson to get past a bug.

Anyway, when you click on Clustering the first time, nothing happens. I waited 30 seconds or so. I go back to the main table view and click on Clustering again, it works almost instantly!

Is this a Mapbox Bug?

@rmnblm
Copy link
Owner

rmnblm commented Sep 26, 2016

Hi @nitrag

First, it wasn't necessary to convert SwiftyJSON to Swift 3 by hand. If your CocoaPods version isn't >= 1.1.0 (you can check this with pod --version), CocoaPods will install an older version which isn't Swift 3 compatible (I honestly don't know why, but I could fix this by installing a pre-release version of CocoaPods with sudo gem install cocoapods --pre). I just checked the SwiftyJSON repo and it seems that @zhigang1992 updated SwiftyJSON a few days ago. I'll check if this problem still exist.

Second, I was not able to reproduce your problem. To answer your question: No, there has nothing to be done outside of the file. On what iPhone with which iOS version are you running the examples? What about the other examples, do they work properly?
It may be a Mapbox bug, let me investigate this further for you.

@rmnblm
Copy link
Owner

rmnblm commented Sep 26, 2016

Okay, I just tried to do a pod install with CocoaPods version 1.0.1 and the problem with SwiftyJSON still occurs, even when it downloads SwiftyJSON 3.1.0.

$ pod install
Analyzing dependencies
Fetching podspec for `Mapbox-iOS-SDK` from `https://raw.githubusercontent.com/mapbox/mapbox-gl-native/ios-v3.4.0-alpha.4/platform/ios/Mapbox-iOS-SDK.podspec`
Downloading dependencies
Installing Mapbox-iOS-SDK (3.4.0-alpha.4)
Installing SwiftyJSON (3.1.0)
Generating Pods project
Integrating client project

So it's still required to have a CocoaPods version >= 1.1.0 to install all required dependencies. Also see this issue which addresses this problem: SwiftyJSON/SwiftyJSON#647

@nitrag
Copy link
Contributor Author

nitrag commented Sep 27, 2016

Dunno man, now it works fine. Only difference is I upgraded to latests cocoapods.

gem install cocoapods --pre
git clone https://github.com/rmnblm/mapbox-ios-examples.git

cd mapbox-ios-examples
pod install
#setup Keys.plist
#open xcworkspace
#change iOS "Team"
#change build target to "iPhone 6"
#build and run
#works!

Back to my main issue with not seeing any data. I was calling loadData() within viewDidAppear(). Not good. Based on another example I switched to use: func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) and voila! Loads perfectly well!

@rmnblm
Copy link
Owner

rmnblm commented Sep 27, 2016

I noticed the example and updated all view controllers in this repo loading the data in the func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) function, see commit here.

Maybe the Mapbox Team (@1ec5 or @boundsj) should clarify which method to use when loading map data?

@1ec5
Copy link
Contributor

1ec5 commented Sep 27, 2016

Yes, we don’t have official examples yet, but MGLMapViewDelegate.mapViewDidFinishLoadingMap(_:) is a fine place to put anything that depends on the style being loaded, since the style loads asynchronously. Note also mapbox/mapbox-gl-native#6412, for which we’re planning to add an additional delegate method, probably MGLMapViewDelegate.mapView(_:didFinishLoadingStyle:). Eventually, I think we’ll add an MGLMapView.setStyle(_:completionHandler:) method that takes a closure, as described in mapbox/mapbox-gl-native#6386 (comment), but that’s a little ways off.

@rmnblm
Copy link
Owner

rmnblm commented Sep 27, 2016

As I'm digging more and more into Mapbox on iOS, I can't wait for this feature to be implemented because I totally need this! Some ETA about this feature?

PS: This feature would partly solve mapbox/mapbox-gl-native#6361 because calling mapView.style().layer(withIdentifier: "...") gives me a "EXC_BAD_ACCESS" exception when the styles haven't been initialized yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants