11#import " PluginLayerExample.h"
22
3+ @interface PluginLayerExample () {
4+
5+ }
6+
7+ @property BOOL logFeatures;
8+
9+ @end
10+
11+
312@implementation PluginLayerExample
413
514
615// This is the layer type in the style that is used
716+(MLNPluginLayerCapabilities *)layerCapabilities {
817
918 MLNPluginLayerCapabilities *tempResult = [[MLNPluginLayerCapabilities alloc ] init ];
10- tempResult.layerID = @" plugin-layer-test " ;
19+ tempResult.layerID = @" maplibre::filter_features " ;
1120 tempResult.requiresPass3D = YES ;
21+ tempResult.supportsReadingTileFeatures = YES ;
1222 return tempResult;
1323
1424}
1525
26+ -(id )init {
27+ if (self = [super init ]) {
28+ self.logFeatures = NO ;
29+ }
30+ return self;
31+ }
32+
1633// The overrides
17- -(void )onRenderLayer {
18- NSLog (@" PluginLayerExample: On Render Layer" );
34+ -(void )onRenderLayer : (MLNMapView *)mapView
35+ renderEncoder : (id <MTLRenderCommandEncoder >)renderEncoder {
36+ // NSLog(@"PluginLayerExample: On Render Layer");
1937
2038}
2139
@@ -24,7 +42,54 @@ -(void)onUpdateLayer {
2442}
2543
2644-(void )onUpdateLayerProperties : (NSDictionary *)layerProperties {
27- // NSLog(@"Layer Properties: %@", layerProperties);
45+ // NSLog(@"Layer Properties: %@", layerProperties);
46+ }
47+
48+ -(void )featureLoaded : (MLNPluginLayerTileFeature *)tileFeature {
49+
50+ // Writing a single string since the tile loading is multithreaded and the output can get interwoven
51+ NSMutableString *outputStr = [NSMutableString string ];
52+ [outputStr appendFormat: @" Tile Feature (id:%@ ) Properties: %@ \n " , tileFeature.featureID, tileFeature.featureProperties];
53+
54+ for (NSValue *v in tileFeature.featureCoordinates ) {
55+
56+ CLLocationCoordinate2D coord;
57+ [v getValue: &coord];
58+
59+ [outputStr appendFormat: @" -> (%f , %f ) \n " , coord.latitude, coord.longitude];
60+
61+ }
62+
63+ NSLog (@" Feature: %@ " , outputStr);
64+ }
65+
66+ -(void )featureUnloaded : (MLNPluginLayerTileFeature *)tileFeature {
67+ // NSLog(@"Tile Features Unloaded: %@", tileFeature.featureProperties);
68+
69+ }
70+
71+
72+ - (void )onFeatureLoaded : (MLNPluginLayerTileFeature *)tileFeature {
73+
74+ [self featureLoaded: tileFeature];
75+
76+ }
77+
78+ // / Called when a set of features are loaded from the tile
79+ - (void )onFeatureCollectionLoaded : (MLNPluginLayerTileFeatureCollection *)tileFeatureCollection {
80+ // NSLog(@"Feature Collection Loaded for tile: %@", tileFeatureCollection.tileID);
81+ for (MLNPluginLayerTileFeature *feature in tileFeatureCollection.features ) {
82+ [self featureLoaded: feature];
83+ }
84+
85+ }
86+
87+ // / Called when a set of features are unloaded because the tile goes out of scene/etc
88+ - (void )onFeatureCollectionUnloaded : (MLNPluginLayerTileFeatureCollection *)tileFeatureCollection {
89+ // NSLog(@"Feature Collection Unloaded for tile: %@", tileFeatureCollection.tileID);
90+ for (MLNPluginLayerTileFeature *feature in tileFeatureCollection.features ) {
91+ [self featureUnloaded: feature];
92+ }
2893}
2994
3095@end
0 commit comments