summaryrefslogtreecommitdiff
path: root/platform/ios/app
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-11-22 15:54:38 +0100
committerFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-12-06 13:59:56 +0100
commitdc2dc31c0bdd4f0b27412125032bfa694ade26b9 (patch)
treea573ec5e83342e1a4dcd9f335a8fbc2ee0db4cfd /platform/ios/app
parent9456bec1721f5cd69e7813c68b829db4c7ff9660 (diff)
downloadqtlocation-mapboxgl-dc2dc31c0bdd4f0b27412125032bfa694ade26b9.tar.gz
[ios, macos] MGLGeoJSONSource can now be initialized with any shape
Diffstat (limited to 'platform/ios/app')
-rw-r--r--platform/ios/app/MBXViewController.m19
1 files changed, 11 insertions, 8 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 8a2ccee413..de1a337e42 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -877,7 +877,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
- (void)styleQuery
{
CGRect queryRect = CGRectInset(self.mapView.bounds, 100, 200);
- NSArray *features = [self.mapView visibleFeaturesInRect:queryRect];
+ NSArray *visibleFeatures = [self.mapView visibleFeaturesInRect:queryRect];
NSString *querySourceID = @"query-source-id";
NSString *queryLayerID = @"query-layer-id";
@@ -895,9 +895,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
[self.mapView.style removeSource:source];
}
-
dispatch_async(dispatch_get_main_queue(), ^{
- MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:querySourceID features:features options:nil];
+ MGLShapeCollectionFeature *features = [MGLShapeCollectionFeature shapeCollectionWithShapes:visibleFeatures];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:querySourceID shape:features options:nil];
[self.mapView.style addSource:source];
MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:queryLayerID source:source];
@@ -950,7 +950,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
feature.identifier = @"leaf-feature";
feature.attributes = @{@"color": @"red"};
- MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"leaf-source" features:@[feature] options:nil];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"leaf-source" shape:feature options:nil];
[self.mapView.style addSource:source];
MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"leaf-fill-layer" source:source];
@@ -1026,7 +1026,10 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
MGLPolygonFeature *smallBoxFeature = [MGLPolygonFeature polygonWithCoordinates:smallBox count:sizeof(smallBox)/sizeof(smallBox[0])];
MGLPolygonFeature *largeBoxFeature = [MGLPolygonFeature polygonWithCoordinates:largeBox count:sizeof(largeBox)/sizeof(largeBox[0])];
- MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"mutable-data-source-features-id" features:@[smallBoxFeature] options:nil];
+ MGLShapeCollectionFeature *collection = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[smallBoxFeature]];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"mutable-data-source-features-id"
+ shape:collection
+ options:nil];
[self.mapView.style addSource:source];
MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"mutable-data-layer-features-id" source:source];
@@ -1035,7 +1038,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
[self.mapView.style addLayer:layer];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- source.features = @[largeBoxFeature];
+ source.shape = largeBoxFeature;
});
}
@@ -1049,7 +1052,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
{36.99508088541243, -109.04007911682129},
};
MGLPointCollectionFeature *feature = [MGLPointCollectionFeature pointCollectionWithCoordinates:coordinates count:4];
- MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"wiggle-source" features:@[feature] options:nil];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithIdentifier:@"wiggle-source" shape:feature options:nil];
[self.mapView.style addSource:source];
MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"wiggle-layer" source:source];
@@ -1116,7 +1119,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
MGLPolylineFeature *routeLine = [MGLPolylineFeature polylineWithCoordinates:coords count:count];
- MGLGeoJSONSource *routeSource = [[MGLGeoJSONSource alloc] initWithIdentifier:@"style-route-source" features:@[routeLine] options:nil];
+ MGLGeoJSONSource *routeSource = [[MGLGeoJSONSource alloc] initWithIdentifier:@"style-route-source" shape:routeLine options:nil];
[self.mapView.style addSource:routeSource];
MGLLineStyleLayer *baseRouteLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"style-base-route-layer" source:routeSource];