Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core, android, ios, macos] Added Traffic Day/Night to default styles
Browse files Browse the repository at this point in the history
The Styles API section of the Mapbox API Documentation site now lists Traffic Day v2 and Traffic Night v2, so this change adds those styles to all the places where styles are listed.

Also switched iosapp and macosapp to unversioned style factory methods since MGLStyleDefaultVersion is no longer applicable for all styles.
  • Loading branch information
1ec5 committed May 12, 2017
1 parent 9e384b7 commit 4d6f545
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 39 deletions.
1 change: 1 addition & 0 deletions platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to
* Derived source attribution [#8630](https://github.com/mapbox/mapbox-gl-native/pull/8630)
* Consistent use of duration unit [#8578](https://github.com/mapbox/mapbox-gl-native/pull/8578)
* Swedish localization [#8883](https://github.com/mapbox/mapbox-gl-native/pull/8883)
* Streets v10, Outdoors v10, Satellite Streets v10, Traffic Day v2, Traffic Night v2 [#6301](https://github.com/mapbox/mapbox-gl-native/pull/6301)

## 5.0.2 - April 3, 2017

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Style {
* constants means your map style will always use the latest version and may change as we
* improve the style
*/
@StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS})
@StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT})
@Retention(RetentionPolicy.SOURCE)
public @interface StyleUrl {
}
Expand Down Expand Up @@ -67,4 +67,22 @@ public class Style {
* improve the style.
*/
public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v10";

/**
* Traffic Day: Color-coded roads based on live traffic congestion data. Traffic data is currently
* available in
* <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select
* countries</a>. Using this constant means your map style will always use the latest version and
* may change as we improve the style.
*/
public static final String TRAFFIC_DAY = "mapbox://styles/mapbox/traffic-day-v2";

/**
* Traffic Night: Color-coded roads based on live traffic congestion data, designed to maximize
* legibility in low-light situations. Traffic data is currently available in
* <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select
* countries</a>. Using this constant means your map style will always use the latest version and
* may change as we improve the style.
*/
public static final String TRAFFIC_NIGHT = "mapbox://styles/mapbox/traffic-night-v2";
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@
<string name="mapbox_style_dark" translatable="false">mapbox://styles/mapbox/dark-v9</string>
<string name="mapbox_style_satellite" translatable="false">mapbox://styles/mapbox/satellite-v9</string>
<string name="mapbox_style_satellite_streets" translatable="false">mapbox://styles/mapbox/satellite-streets-v10</string>
<string name="mapbox_style_traffic_day" translatable="false">mapbox://styles/mapbox/traffic-day-v2</string>
<string name="mapbox_style_traffic_night" translatable="false">mapbox://styles/mapbox/traffic-night-v2</string>
</resources>
62 changes: 62 additions & 0 deletions platform/darwin/src/MGLStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,68 @@ MGL_EXPORT
*/
+ (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version;

/**
Returns the URL to the current version of the
<a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Day</a>
style.
Traffic Day color-codes roads based on live traffic congestion data. Traffic
data is currently available in
<a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>.
@warning The return value may change in a future release of the SDK. If you use
any feature that depends on a specific aspect of a default style – for
instance, the minimum zoom level that includes roads – use the
`-trafficDayStyleURLWithVersion:` method instead. Such details may change
significantly from version to version.
*/
+ (NSURL *)trafficDayStyleURL;

/**
Returns the URL to the given version of the
<a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Day</a>
style as of publication.
Traffic Day color-codes roads based on live traffic congestion data. Traffic
data is currently available in
<a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>.
@param version A specific version of the style.
*/
+ (NSURL *)trafficDayStyleURLWithVersion:(NSInteger)version;

/**
Returns the URL to the current version of the
<a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Night</a>
style.
Traffic Night color-codes roads based on live traffic congestion data and is
designed to maximize legibility in low-light situations. Traffic data is
currently available in
<a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>.
@warning The return value may change in a future release of the SDK. If you use
any feature that depends on a specific aspect of a default style – for
instance, the minimum zoom level that includes roads – use the
`-trafficNightStyleURLWithVersion:` method instead. Such details may change
significantly from version to version.
*/
+ (NSURL *)trafficNightStyleURL;

/**
Returns the URL to the given version of the
<a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Night</a>
style as of publication.
Traffic Night color-codes roads based on live traffic congestion data and is
designed to maximize legibility in low-light situations. Traffic data is
currently available in
<a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>.
@param version A specific version of the style.
*/
+ (NSURL *)trafficNightStyleURLWithVersion:(NSInteger)version;

#pragma mark Accessing Metadata About the Style

/**
Expand Down
4 changes: 3 additions & 1 deletion platform/darwin/src/MGLStyle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ + (NSURL *)name##StyleURL##WithVersion:(NSInteger)version { \
MGL_DEFINE_STYLE(dark, dark)
MGL_DEFINE_STYLE(satellite, satellite)
MGL_DEFINE_STYLE(satelliteStreets, satellite-streets)
MGL_DEFINE_STYLE(trafficDay, traffic-day)
MGL_DEFINE_STYLE(trafficNight, traffic-night)

// Make sure all the styles listed in mbgl::util::default_styles::orderedStyles
// are defined above and also declared in MGLStyle.h.
static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
static_assert(8 == mbgl::util::default_styles::numOrderedStyles,
"mbgl::util::default_styles::orderedStyles and MGLStyle have different numbers of styles.");

// Hybrid has been renamed Satellite Streets, so the last Hybrid version is hard-coded here.
Expand Down
12 changes: 10 additions & 2 deletions platform/darwin/test/MGLStyleTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,16 @@ - (void)testVersionedStyleURLs {
@(mbgl::util::default_styles::satelliteStreets.url));
XCTAssertEqualObjects([MGLStyle satelliteStreetsStyleURLWithVersion:99].absoluteString,
@"mapbox://styles/mapbox/satellite-streets-v99");

static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
XCTAssertEqualObjects([MGLStyle trafficDayStyleURLWithVersion:mbgl::util::default_styles::trafficDay.currentVersion].absoluteString,
@(mbgl::util::default_styles::trafficDay.url));
XCTAssertEqualObjects([MGLStyle trafficDayStyleURLWithVersion:99].absoluteString,
@"mapbox://styles/mapbox/traffic-day-v99");
XCTAssertEqualObjects([MGLStyle trafficNightStyleURLWithVersion:mbgl::util::default_styles::trafficNight.currentVersion].absoluteString,
@(mbgl::util::default_styles::trafficNight.url));
XCTAssertEqualObjects([MGLStyle trafficNightStyleURLWithVersion:99].absoluteString,
@"mapbox://styles/mapbox/traffic-night-v99");

static_assert(8 == mbgl::util::default_styles::numOrderedStyles,
"MGLStyleTests isn’t testing all the styles in mbgl::util::default_styles.");
}

Expand Down
2 changes: 2 additions & 0 deletions platform/default/mbgl/util/default_styles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const DefaultStyle light = { "mapbox://styles/mapbox/light-v9",
const DefaultStyle dark = { "mapbox://styles/mapbox/dark-v9", "Dark", 9 };
const DefaultStyle satellite = { "mapbox://styles/mapbox/satellite-v9", "Satellite", 9 };
const DefaultStyle satelliteStreets = { "mapbox://styles/mapbox/satellite-streets-v10", "Satellite Streets", 10 };
const DefaultStyle trafficDay = { "mapbox://styles/mapbox/traffic-day-v2", "Traffic Day", 2 };
const DefaultStyle trafficNight = { "mapbox://styles/mapbox/traffic-night-v2", "Traffic Night", 2 };

} // namespace default_styles
} // end namespace util
Expand Down
3 changes: 3 additions & 0 deletions platform/default/mbgl/util/default_styles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ extern const DefaultStyle light;
extern const DefaultStyle dark;
extern const DefaultStyle satellite;
extern const DefaultStyle satelliteStreets;
extern const DefaultStyle trafficDay;
extern const DefaultStyle trafficNight;

const DefaultStyle orderedStyles[] = {
streets, outdoors, light, dark, satellite, satelliteStreets,
trafficDay, trafficNight,
};
const size_t numOrderedStyles = sizeof(orderedStyles) / sizeof(DefaultStyle);

Expand Down
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT

* Added support for 3D extrusion of buildings and other polygonal features via the `MGLFillExtrusionStyleLayer` class and the `fill-extrusion` layer type in style JSON. ([#8431](https://github.com/mapbox/mapbox-gl-native/pull/8431))
* MGLMapView and MGLTilePyramidOfflineRegion now default to version 10 of the Mapbox Streets style. Similarly, several style URL class methods of MGLStyle return URLs to version 10 styles. Unversioned variations of these methods are no longer deprecated. `MGLStyleDefaultVersion` should no longer be used with any style other than Streets. ([#6301](https://github.com/mapbox/mapbox-gl-native/pull/6301))
* Added class methods to MGLStyle that correspond to the new [Traffic Day and Traffic Night](https://www.mapbox.com/blog/live-traffic-maps/) styles. ([#6301](https://github.com/mapbox/mapbox-gl-native/pull/6301))
* MGLSymbolStyleLayer’s `iconImageName`, `iconScale`, `textFontSize`, `textOffset`, and `textRotation` properties can now be set to a source or composite function. ([#8544](https://github.com/mapbox/mapbox-gl-native/pull/8544), [#8590](https://github.com/mapbox/mapbox-gl-native/pull/8590), [#8592](https://github.com/mapbox/mapbox-gl-native/pull/8592), [#8593](https://github.com/mapbox/mapbox-gl-native/pull/8593))
* Fixed an issue where setting the `MGLVectorStyleLayer.predicate` property failed to take effect if the relevant source was not in use by a visible layer at the time. ([#8653](https://github.com/mapbox/mapbox-gl-native/pull/8653))
* Fixed an issue causing a composite function’s highest zoom level stop to be misinterpreted. ([#8613](https://github.com/mapbox/mapbox-gl-native/pull/8613), [#8790](https://github.com/mapbox/mapbox-gl-native/pull/8790))
Expand Down
16 changes: 10 additions & 6 deletions platform/ios/app/MBXViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1542,14 +1542,18 @@ - (IBAction)cycleStyles:(__unused id)sender
@"Dark",
@"Satellite",
@"Satellite Streets",
@"Traffic Day",
@"Traffic Night",
];
styleURLs = @[
[MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion],
[MGLStyle outdoorsStyleURLWithVersion:MGLStyleDefaultVersion],
[MGLStyle lightStyleURLWithVersion:MGLStyleDefaultVersion],
[MGLStyle darkStyleURLWithVersion:MGLStyleDefaultVersion],
[MGLStyle satelliteStyleURLWithVersion:MGLStyleDefaultVersion],
[MGLStyle satelliteStreetsStyleURLWithVersion:MGLStyleDefaultVersion],
[MGLStyle streetsStyleURL],
[MGLStyle outdoorsStyleURL],
[MGLStyle lightStyleURL],
[MGLStyle darkStyleURL],
[MGLStyle satelliteStyleURL],
[MGLStyle satelliteStreetsStyleURL],
[MGLStyle trafficDayStyleURL],
[MGLStyle trafficNightStyleURL],
];
NSAssert(styleNames.count == styleURLs.count, @"Style names and URLs don’t match.");

Expand Down
1 change: 1 addition & 0 deletions platform/macos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Added support for 3D extrusion of buildings and other polygonal features via the `MGLFillExtrusionStyleLayer` class and the `fill-extrusion` layer type in style JSON. ([#8431](https://github.com/mapbox/mapbox-gl-native/pull/8431))
* MGLMapView and MGLTilePyramidOfflineRegion now default to version 10 of the Mapbox Streets style. Similarly, several style URL class methods of MGLStyle return URLs to version 10 styles. Unversioned variations of these methods are no longer deprecated. `MGLStyleDefaultVersion` should no longer be used with any style other than Streets. ([#6301](https://github.com/mapbox/mapbox-gl-native/pull/6301))
* Added class methods to MGLStyle that correspond to the new [Traffic Day and Traffic Night](https://www.mapbox.com/blog/live-traffic-maps/) styles. ([#6301](https://github.com/mapbox/mapbox-gl-native/pull/6301))
* MGLSymbolStyleLayer’s `iconImageName`, `iconScale`, `textFontSize`, `textOffset`, and `textRotation` properties can now be set to a source or composite function. ([#8544](https://github.com/mapbox/mapbox-gl-native/pull/8544), [#8590](https://github.com/mapbox/mapbox-gl-native/pull/8590), [#8592](https://github.com/mapbox/mapbox-gl-native/pull/8592), [#8593](https://github.com/mapbox/mapbox-gl-native/pull/8593))
* Fixed an issue where setting the `MGLVectorStyleLayer.predicate` property failed to take effect if the relevant source was not in use by a visible layer at the time. ([#8653](https://github.com/mapbox/mapbox-gl-native/pull/8653))
* Fixed an issue causing a composite function’s highest zoom level stop to be misinterpreted. ([#8613](https://github.com/mapbox/mapbox-gl-native/pull/8613), [#8790](https://github.com/mapbox/mapbox-gl-native/pull/8790))
Expand Down
22 changes: 16 additions & 6 deletions platform/macos/app/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1217" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -395,6 +395,16 @@
<action selector="showStyle:" target="-1" id="NTT-Y1-EqU"/>
</connections>
</menuItem>
<menuItem title="Traffic Day" tag="7" keyEquivalent="7" id="m9S-sv-Dch">
<connections>
<action selector="showStyle:" target="-1" id="lXM-BW-dDw"/>
</connections>
</menuItem>
<menuItem title="Traffic Night" tag="8" keyEquivalent="8" id="yVS-VL-Xsy">
<connections>
<action selector="showStyle:" target="-1" id="eAD-br-oBB"/>
</connections>
</menuItem>
<menuItem title="Custom Style…" id="L0h-86-2cU">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand Down Expand Up @@ -643,7 +653,7 @@ CA
<rect key="frame" x="0.0" y="0.0" width="350" height="84"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0IK-AW-Gg3">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0IK-AW-Gg3">
<rect key="frame" x="18" y="45" width="89" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Access token:" id="Ptd-FI-M5A">
<font key="font" metaFont="system"/>
Expand All @@ -654,7 +664,7 @@ CA
<accessibilityConnection property="link" destination="7sb-sf-oJU" id="U0t-jC-oQ7"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7sb-sf-oJU">
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7sb-sf-oJU">
<rect key="frame" x="113" y="42" width="197" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="jlV-TC-NUv">
<font key="font" metaFont="system"/>
Expand Down Expand Up @@ -723,7 +733,7 @@ CA
<rect key="frame" x="-1" y="20" width="402" height="281"/>
<clipView key="contentView" id="J9U-Yx-o2S">
<rect key="frame" x="1" y="0.0" width="400" height="280"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" autosaveColumns="NO" headerView="MAZ-Iq-hBi" id="Ato-Vu-HYT">
<rect key="frame" x="0.0" y="0.0" width="423" height="257"/>
Expand Down
Loading

0 comments on commit 4d6f545

Please sign in to comment.