summaryrefslogtreecommitdiff
path: root/platform/ios/app
diff options
context:
space:
mode:
authorituaijagbone <i.ijagbone@gmail.com>2016-09-29 16:44:10 -0700
committerJesse Bounds <jesse@rebounds.net>2016-10-14 14:59:28 -0700
commitf558f6bc4a12fc621589c0b0f50d42c18e00453c (patch)
treec43e9b4722d72b8220e936719cbe14a8f9fa5958 /platform/ios/app
parent242c7f8fe62eb863cf300855aee2f04022311288 (diff)
downloadqtlocation-mapboxgl-f558f6bc4a12fc621589c0b0f50d42c18e00453c.tar.gz
[ios, macos] Add feature initializer
This adds a features initializer to MGLGeoJSONSource. The initializer takes shapes and converts them to JSON representation before passing to core. This also adds methods to the MGLShape concrete subclasses so that they can represent themselves in NSDictionary form suitable for transforming to JSON (GeoJSON).
Diffstat (limited to 'platform/ios/app')
-rw-r--r--platform/ios/app/MBXViewController.m26
1 files changed, 26 insertions, 0 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 5a3c56af69..3ee405fd04 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -61,6 +61,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsRuntimeStylingRows) {
MBXSettingsRuntimeStylingFilteredFill,
MBXSettingsRuntimeStylingFilteredLines,
MBXSettingsRuntimeStylingNumericFilteredFill,
+ MBXSettingsRuntimeStylingStyleQuery,
};
typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
@@ -304,6 +305,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
@"Style Fill With Filter",
@"Style Lines With Filter",
@"Style Fill With Numeric Filter",
+ @"Style Query For GeoJSON",
]];
break;
case MBXSettingsMiscellaneous:
@@ -429,6 +431,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
case MBXSettingsRuntimeStylingNumericFilteredFill:
[self styleNumericFilteredFills];
break;
+ case MBXSettingsRuntimeStylingStyleQuery:
+ [self styleQuery];
+ break;
default:
NSAssert(NO, @"All runtime styling setting rows should be implemented");
break;
@@ -785,6 +790,27 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
});
}
+
+- (void)styleQuery
+{
+ CGRect queryRect = CGRectInset(self.mapView.bounds, 100, 200);
+ NSArray *features = [self.mapView visibleFeaturesInRect:queryRect];
+
+// NSMutableArray *polygonFeatures = [NSMutableArray array];
+// for (id<MGLFeature> feature in features) {
+// if ([feature isMemberOfClass:[MGLPolygonFeature class]]) {
+// [polygonFeatures addObject:feature];
+// }
+// }
+
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"query-id" features:features options:nil];
+ [self.mapView.style addSource:source];
+
+ MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"query-layer-id" source:source];
+ fillLayer.fillColor = [UIColor blueColor];
+ [self.mapView.style addLayer:fillLayer];
+}
+
- (IBAction)startWorldTour
{
_isTouringWorld = YES;