GMSDatasetFeatureLayer Class Reference

GMSDatasetFeatureLayer Class Reference

Overview

An interface representing a feature layer for a dataset.

The featureType of a GMSDatasetFeatureLayer will always be GMSFeatureTypeDataset.

Inherits GMSFeatureLayer.

Properties

NSString * datasetID
 ID of the dataset.
BOOL available
 Determines if the data-driven GMSFeatureLayer is available.
GMSFeatureStyle *_Nullable(^)(T) style
 Styling block to be applied to all features in this layer.

Member Function Documentation

- (instancetype) initWithFeatureType: (GMSFeatureType)  featureType

Create a feature layer instance for testing.

This method should be used for your unit tests only. In production, GMSFeatureLayer instances should only be created by the SDK.


Property Documentation

- (NSString*) datasetID [read, assign]

ID of the dataset.

- (BOOL) available [read, assign, inherited]

Determines if the data-driven GMSFeatureLayer is available.

Data-driven styling requires the Metal Framework, a valid map ID and that the feature type be applied. If NO, styling for the GMSFeatureLayer returns to the default and events are not triggered.

- (GMSFeatureStyle* _Nullable(^ style)(T)) [read, write, assign, inherited]

Styling block to be applied to all features in this layer.

The style block is applied to all visible features in the viewport when the setter is called, and is run multiple times for the subsequent features entering the viewport.

The function is required to be deterministic and return consistent results when it is applied over the map tiles. If any styling specs of any feature would be changed, style must be set again. Changing behavior of the style block without calling the style setter will result in undefined behavior, including stale and/or shattered map renderings. See the example below:

 {.swift}
 var selectedPlaceIDs = Set<String>()
 var style = FeatureStyle(fill: .red, stroke: .clear, strokeWidth: 0)
 layer.style = { feature in
   selectedPlaceIDs.contains(feature.placeID) ? style : nil
 }


 selectedPlaceIDs.insert("foo")

 style = FeatureStyle(fill: .clear, stroke: .blue, strokeWidth: 1.5)


 layer.style = { feature in
   selectedPlaceIDs.contains(feature.placeID) ? style : nil
 }