Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should I change worldview? #237

Closed
venus-yangbo opened this issue Sep 20, 2023 · 1 comment
Closed

How should I change worldview? #237

venus-yangbo opened this issue Sep 20, 2023 · 1 comment

Comments

@venus-yangbo
Copy link

I am a developer from China and a Mapbox novice, I have encountered problems related to compliance, To this end, I checked the document and found the WorldView configuration item, But only Android Demo and JS Demo were found.
I encountered difficulties when I tried to implement it on the Flutter side, and I couldn't find the corresponding API. It took a while still failed to make progress, so I had to help the community help.

@venus-yangbo venus-yangbo changed the title How should I modify worldview? How should I change worldview? Sep 20, 2023
@venus-yangbo
Copy link
Author

I successfully achieved it! Although I am not sure if it is standard.

  /// change worldview
  Future _changeWorldview(MapboxMap mapboxMap, String worldview) async {
    await mapboxMap.style.setStyleLayerProperty(
      "admin-0-boundary-bg",
      "filter",
      [
        "all",
        ["==", ["get", "admin_level"], 0],
        ["==", ["get", "maritime"], "false"],
        ["match", ["get", "worldview"], ["all", worldview], true, false]
      ],
    );
    
    await mapboxMap.style.setStyleLayerProperty(
      "admin-0-boundary-disputed",
      "filter",
      [
        "all",
        ["==", ["get", "disputed"], "true"],
        ["==", ["get", "admin_level"], 0],
        ["==", ["get", "maritime"], "false"],
        ["match", ["get", "worldview"], ["all", worldview], true, false]
      ],
    );
    
    await mapboxMap.style.setStyleLayerProperty(
      "admin-0-boundary",
      "filter",
      [
        "all",
        ["==", ["get", "admin_level"], 0],
        ["==", ["get", "disputed"], "false"],
        ["==", ["get", "maritime"], "false"],
        ["match", ["get", "worldview"], ["all", worldview], true, false]
      ],
    );
  }

Use _changeWorldview(mapboxMap, "CN")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant