Skip to content

mapbox/ambient-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ambient Light Mapbox iOS Demo

Mapbox Maps SDK for iOS demo app that demonstrates ambient light-based map styling.

Would be nice to live in London, wouldn't it.

Getting started

  1. Run pod install to download the Mapbox iOS SDK via Cocoapods
  2. Open ambient-light.xcworkspace in Xcode
  3. Insert your Mapbox access token in AppDelegate.m
  4. Build amazing cartographic things

Detecting ambient light

This is a bit of a lie: Apple does not expose any direct ambient light sensing API to developers, so this demo uses screen brightness as a proxy.

This relies on the user having auto brightness enabled, which isn’t always a given (and there’s no easy way to detect if that’s on, either).

Generally this technique works well and is the same that’s used in Tweetbot.

How the UI works

The slider controls the screen brightness threshold at which the map will change styles — e.g., farther left will switch to the dark style at a lower screen brightness.

A reasonable threshold is about 35%, or somewhat left of center.

Current brightness is indicated by a vertical line on top of the slider bar.

Annoying gif demo

Does not work in simulator

This does not really work in the simulator as brightness is hardcoded to 50%, but you can still drag the slider to change styles.

Need help?

If you haven’t already, read the official project overview from Mapbox and have a look at the API reference. The Mapbox tag on Stack Overflow is a great place to ask questions (that are often answered by Mapboxers). Mapbox also offers tons of help resources.

Found a bug?

If you’ve found a bug in the Mapbox Maps SDK for iOS, please take a bit to report it on the project repo.

Releases

No releases published

Packages