-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use the defaultStyles constant on Android apps #1462
Comments
|
Why not? My reason for not moving it into the |
I think it should be considered part of the library. If a third-party wanted to build an app with style-switching functionality, they should |
The bundled styles aren't technically part of the library either; they're just there because we package them with the apps. |
They are part of the library on iOS — we package a |
Hmm good idea @incanus. |
Punting off of b2 since the bundled styles haven't changed since b1 and nothing under the hood has moved here that makes this any more urgent. |
@1ec5 is looking to implement this in #2746 (comment) for iOS. On Android I decided to just have a class that provides static constants in the |
Moved mbgl::util::default_styles to a more appropriate location, where iOS platform code can also find it. Moved -[MGLMapView bundledStyleURLs] (which is now deprecated) and the style switcher in iosapp to default_styles. Added a collection of convenience methods for getting style URLs. It makes little sense to layer an enum atop this, as MapKit does, because MGLMapView styles aren’t limited to this set. A good analogy is UIColor. This also makes for a good entry point for future runtime styling APIs. Introduced independent constants for each default style, because it’s more common to need access to a particular style than to iterate over them. This fact is apparent in the MGLStyle class, which now uses macros and assertions to ensure that it’s kept up-to-date with changes in default_styles. /ref #1462
Moved mbgl::util::default_styles to a more appropriate location, where iOS platform code can also find it. Moved -[MGLMapView bundledStyleURLs] (which is now deprecated) and the style switcher in iosapp to default_styles. Added a collection of convenience methods for getting style URLs. It makes little sense to layer an enum atop this, as MapKit does, because MGLMapView styles aren’t limited to this set. A good analogy is UIColor. This also makes for a good entry point for future runtime styling APIs. Introduced independent constants for each default style, because it’s more common to need access to a particular style than to iterate over them. This fact is apparent in the MGLStyle class, which now uses macros and assertions to ensure that it’s kept up-to-date with changes in default_styles. /ref mapbox#1462
On Android we have: /**
* <p>
* Style provides URLs to several professional styles designed by Mapbox.
* </p>
* These styles are all ready to go in your app. To load one, pass it into {@link MapView#setStyleUrl(String)}
*
* @see MapView#setStyleUrl(String)
*/
public class Style {
/**
* Indicates the parameter accepts one of the values from {@link Style}.
*/
@StringDef({MAPBOX_STREETS, EMERALD, LIGHT, DARK, SATELLITE, SATELLITE_STREETS})
@Retention(RetentionPolicy.SOURCE)
public @interface StyleUrl {
}
// IMPORTANT: If you change any of these you also need to edit them in strings.xml
/**
* Mapbox Streets: A complete basemap, perfect for incorporating your own data.
*/
public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v8";
/**
* Emerald: A versatile style, with emphasis on road networks and public transit.
*/
public static final String EMERALD = "mapbox://styles/mapbox/emerald-v8";
/**
* Light: Subtle light backdrop for data visualizations.
*/
public static final String LIGHT = "mapbox://styles/mapbox/light-v8";
/**
* Dark: Subtle dark backdrop for data visualizations.
*/
public static final String DARK = "mapbox://styles/mapbox/dark-v8";
/**
* Satellite: A beautiful global satellite and aerial imagery layer.
*/
public static final String SATELLITE = "mapbox://styles/mapbox/satellite-v8";
/**
* Satellite Streets: Global satellite and aerial imagery with unobtrusive labels.
*/
public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-hybrid-v8";
} Since @friedbunny removed iOS label, I think this is resolved for both platforms! |
Yup, iOS happened in #2746. |
It seems the current way is not as requested in this issue. We should fetch: and match those urls on the -> if we change |
On the iOS side, we're relying on a compile-time assertion that the number of default styles hasn't changed since we last updated the iOS-specific list. We also have a unit test to the same effect. |
Obsolete. |
The MacOS and Linux app are now using the defaultStyles as the list of styles we can select from. The iOS and Android apps should use the same list.
defaultStyles was added at #1443
/cc @incanus
The text was updated successfully, but these errors were encountered: