Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Cannot add MGL*StyleLayer for custom vector sources #6251

Closed
boundsj opened this issue Sep 6, 2016 · 2 comments
Closed

Cannot add MGL*StyleLayer for custom vector sources #6251

boundsj opened this issue Sep 6, 2016 · 2 comments
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS runtime styling
Milestone

Comments

@boundsj
Copy link
Contributor

boundsj commented Sep 6, 2016

Platform: iOS
Mapbox SDK version: 3.4.0 alpha 4

Steps to trigger behavior

  1. Create and locally host a TileJSON document that points to a valid vector tileset (i.e. [https://vector.mapzen.com/osm/all/{z}/{x}/{y}.mvt]
  2. Create an MGLVectorSource that uses a URL pointed at the previously created TileJSON (adjust ATS permissions to allow this on iOS)
  3. Create a style layer (i.e. MGLFillStyleLayer) for the vector source and add it to the map's style

Expected behavior

You see the vector source data visually represented by the added style.

Actual behavior

No change to the map.

cc @1ec5 @frederoni

@boundsj boundsj added bug iOS Mapbox Maps SDK for iOS runtime styling labels Sep 6, 2016
@boundsj boundsj added this to the ios-v3.4.0 milestone Sep 6, 2016
@boundsj boundsj assigned boundsj and unassigned boundsj Sep 8, 2016
@boundsj
Copy link
Contributor Author

boundsj commented Sep 13, 2016

With the fix for #6252 came the ability to address and style vector source layers. Since 3.4.0 alpha 4 you can style the layers of a vector source that you host. For example, assuming you are hosting a TileJSON document locally that points to Mapzen's vector tile service, you can write:

- (void)mapViewDidFinishLoadingMap:(MGLMapView *)mapView {
    NSURL *url = [NSURL URLWithString:@"http://localhost:8000/osm.layer"];
    MGLVectorSource *vectorSource = [[MGLVectorSource alloc] initWithSourceIdentifier:@"mapzen" URL:url];
    [self.mapView.style addSource:vectorSource];

    MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithLayerIdentifier:@"filllayer" source:vectorSource sourceLayer:@"buildings"];
    fillLayer.fillColor = [UIColor magentaColor];
    [self.mapView.style addLayer:fillLayer];
}

and see the filled buildings:

screen shot 2016-09-12 at 6 05 45 pm

@boundsj boundsj closed this as completed Sep 13, 2016
@boundsj
Copy link
Contributor Author

boundsj commented Sep 13, 2016

Correction: the ability to address a sources layer does exist on master but not in a published alpha release. The next alpha release will have this functionality.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS runtime styling
Projects
None yet
Development

No branches or pull requests

1 participant