CesiumGS/cesium

Cannot use CSS sprites in ProviderViewModel

Open

#3792 opened on Mar 30, 2016

View on GitHub
 (3 comments) (0 reactions) (0 assignees)JavaScript (11,758 stars) (3,324 forks)batch import
category - widgetsgood first issuetype - enhancement

Description

When creating a ProviderViewModel, the iconUrl points to a single image.

For example, as per the documentation:

imageryViewModels.push(new Cesium.ProviderViewModel({
     name : 'Open\u00adStreet\u00adMap',
     iconUrl : Cesium.buildModuleUrl('Widgets/Images/ImageryProviders/openStreetMap.png'),
     tooltip : 'OpenStreetMap (OSM) is a collaborative project to create a free editable \
map of the world.\nhttp://www.openstreetmap.org',
     creationFunction : function() {
         return Cesium.createOpenStreetMapImageryProvider({
             url : '//a.tile.openstreetmap.org/'
         });
     }
 }));

However as a class cannot be specified, it is not possible to use CSS sprites (i.e. bundling multiple icons in the same image).

A possible fix would be that of modifying Widgets/BaseLayerPicker/BaseLayerPicker.js, so that instead of

    providerIcon.className = 'cesium-baseLayerPicker-itemIcon';

the assigned class were something like:

    providerIcon.className = 'cesium-baseLayerPicker-itemIcon <uniqueClassName>';

I can create a Pull Request if I get guidance on how to generate the unique class.

Contributor guide