Map Styles Extensions
Map Styles Extensions
The TomTom Maps SDK gives you the ability to use either online or offline styles in your mobile application.
If you choose to use offline styles, they will be imported to your app with the Maps SDK package. Thanks to that, the styles will already be included in your app at download time. The styles are added to the Maps SDK package by default.
If you choose to use online styles, they will be downloaded into your application when the map is displayed for the first time. Thanks to that, your mobile app size is smaller at the app’s download time so your app downloadable is lighter. In this case you need to exclude offline styles from the SDK.
To use the offline style framework, no actions are required because offline styles are attached to the map by default. To use the offline style library, no actions are required because offline styles are attached to the map by default i.e. the offline style framework 'TomTomOnlineSDKMapsStyle' will be added automatically while fetching 'TomTomOnlineSDKMaps'.
If offline styles are not attached to the project, nor online style is setup for the map, a black screen will render in mapView.
To exclude offline styles from the TomTomOnlineSDKMaps framework, use an exclude declaration when the TomTomOnlineSDKMaps framework is declared as shown in the following code example.
When offline styles are excluded, the online styles should be set up.
let mapStyleConfiguration = TTMapStyleDefaultConfiguration() let mapConfig = TTMapConfigurationBuilder.create().withMapStyleConfiguration(mapStyleConfiguration).build() let mapView = TTMapView(mapConfiguration: mapConfig)
TTMapStyleDefaultConfiguration *style = [[TTMapStyleDefaultConfiguration alloc] init]; TTMapConfiguration *config = [[[[[TTMapConfigurationBuilder createBuilder] withMapKey:Key.Map] withTrafficKey:Key.Traffic] withMapStyleConfiguration:style] build]; TTMapView *mapView = [[TTMapView alloc] initWithMapConfiguration:config];
self.view = mapView; self.mapView = mapView;
You can set up online styles in
let mapStyleConfiguration = TTMapStyleConfiguration(styleURL: "<style json>") let mapConfig = TTMapConfigurationBuilder.create().withMapStyleConfiguration(mapStyleConfiguration).build() let mapView = TTMapView(mapConfiguration: mapConfig)
TTMapStyleConfiguration *mapStyleConfiguration = [[TTMapStyleConfiguration alloc] initWithStyleURL:@"<style json>"]; TTMapConfiguration *mapConfig = [[[TTMapConfigurationBuilder createBuilder] withMapStyleConfiguration:mapStyleConfiguration] build]; TTMapView *mapView = [[TTMapView alloc] initWithMapConfiguration:mapConfig];
Styling from source
You can use your offline style files in a similar manner to online hosted ones. You need just to pass a file path to the JSON file in your project as styleUrl.
If you want to use