Skip to content

Add toggles in NavigationMapboxMap for traffic and incident data - #1226

Merged
Guardiola31337 merged 2 commits into
masterfrom
dan-add-incidents
Aug 24, 2018
Merged

Guardiola31337 merged 2 commits into
masterfrom
dan-add-incidents

Conversation

@danesfeder

@danesfeder danesfeder commented Aug 20, 2018 •

Copy link
Copy Markdown
Contributor

Searches the given map style for traffic / incident data and, if found, will hide or show the layers.

TODO:

  • Finish implementation, testing traffic toggle against preview-day-v3
  • NavigationMapboxMap javadoc
  • Tests

cc @1ec5

@danesfeder danesfeder added ⚠️ DO NOT MERGE PR should not be merged! feature New feature request. navigation-ui labels Aug 20, 2018
@danesfeder danesfeder added this to the 0.18.0 milestone Aug 20, 2018
@danesfeder danesfeder self-assigned this Aug 20, 2018
private void updateLayerVisibility(String layerIdentifier, List<String> sourceIdentifiers,
List<Layer> layers, boolean isVisible) {
for (Layer layer : layers) {
if (!(layer instanceof LineLayer)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the relevant layers may be SymbolLayers rather than LineLayers.

Timber.d("sourceIdentifier %s", sourceIdentifier);
String layerId = layer.getId();
Timber.d("layerId %s", layerId);
if (sourceIdentifiers.contains(sourceIdentifier) && layerId.contains(layerIdentifier)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source layer ID needs to match exactly; it isn’t enough for it to contain the source layer ID we’re looking for.

Timber.d("***** ***** ***** *****");
String sourceIdentifier = ((LineLayer) layer).getSourceLayer();
Timber.d("sourceIdentifier %s", sourceIdentifier);
String layerId = layer.getId();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We’re interested in the layer’s source layer’s ID, not the ID of the layer in the style.

@danesfeder

danesfeder commented Aug 21, 2018 •

Copy link
Copy Markdown
Contributor Author

@1ec5 I added some updates, but the data in the if check still seems to be incorrect.

I'm looking for layer.sourceIdentifier and layer.sourceLayerIdentifier from what I'm seeing in the iOS code. For both Android LineLayer and SymbolLayer I only see #getSourceLayer(). So I guess I'm missing the ability to retrieve the String mapbox://mapbox.mapbox-traffic-v1 from the Layer.

Thanks for the review, appreciate your 👀 on this.

@1ec5

1ec5 commented Aug 21, 2018

Copy link
Copy Markdown
Contributor

I'm looking for layer.sourceIdentifier and layer.sourceLayerIdentifier from what I'm seeing in the iOS code. For both Android LineLayer and SymbolLayer I only see #getSourceLayer(). So I guess I'm missing the ability to retrieve the String mapbox://mapbox.mapbox-traffic-v1 from the Layer.

sourceLayerIdentifier translates to getSourceLayer(), but indeed, there’s no equivalent to sourceIdentifier in the Android map SDK: mapbox/mapbox-gl-native#12691. In the meantime, you’ll have to assume that the style isn’t using any source that also has an incidents layer (or whatever the ID ends up being).

@danesfeder

Copy link
Copy Markdown
Contributor Author

This is working now without the sourceIdentifier logic. Thanks for opening that gl ticket and clarifying that @1ec5

ezgif com-video-to-gif

@danesfeder
danesfeder force-pushed the dan-add-incidents branch 2 times, most recently from dc0d599 to 0bb4c87 Compare August 22, 2018 15:01
@danesfeder danesfeder changed the title [WIP] Add toggles in NavigationMapboxMap for traffic and incident data Add toggles in NavigationMapboxMap for traffic and incident data Aug 22, 2018
@danesfeder danesfeder added ✓ ready for review and removed ⚠️ DO NOT MERGE PR should not be merged! labels Aug 22, 2018
@danesfeder

Copy link
Copy Markdown
Contributor Author

@Guardiola31337 @devotaaabel tests and javadoc added - this is ready for 👀

@devotaaabel devotaaabel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I don't have much context on this stuff so I'd say @Guardiola31337 should still review


class MapIncidents {

private static final String INCIDENTS_LAYER_ID = "incidents";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called closures now.

@1ec5 1ec5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. A couple non-critical comments follow.

}

private boolean isInvalid(Layer layer) {
return !(layer instanceof LineLayer || layer instanceof SymbolLayer);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The double negative is a little confusing. Consider calling the method isValid() and removing the !.

}

// TODO find sourceIdentifier for Layer https://github.com/mapbox/mapbox-gl-native/issues/12691
private List<String> findSourceIdentifiersFor(String tileSetIdentifier) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is unused due to mapbox/mapbox-gl-native#12691. Should it be deleted or commented out until a getSource() or getSourceId() is available?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and deleted the unused code but added the changes as a new commit so we'll be able to recover the code from 462bb0a when mapbox/mapbox-gl-native#12691 lands.

…incidents and traffic apis in navigation mapbox map
@Guardiola31337

Copy link
Copy Markdown
Contributor

@1ec5 addressed your comments. Feel free to give it a final round of 👀

@Guardiola31337
Guardiola31337 merged commit 281c6e7 into master Aug 24, 2018
@Guardiola31337
Guardiola31337 deleted the dan-add-incidents branch August 24, 2018 14:08
@Guardiola31337 Guardiola31337 mentioned this pull request Aug 24, 2018
11 tasks done
@danesfeder danesfeder added the backwards incompatible Requires a SEMVER major version change. label Sep 17, 2018
@Guardiola31337 Guardiola31337 removed the backwards incompatible Requires a SEMVER major version change. label Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants