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

map.flyTo avoids crossing the antimeridian when projection is globe #12779

Open
ollfkaih opened this issue Jun 29, 2023 · 1 comment
Open

map.flyTo avoids crossing the antimeridian when projection is globe #12779

ollfkaih opened this issue Jun 29, 2023 · 1 comment
Labels

Comments

@ollfkaih
Copy link

mapbox-gl-js version: 2.15.0

browser: Firefox 114.0.2 (or latest chrome also)

Steps to Trigger Behavior

  1. Try to fly from somewhere far east in the eastearn hemisphere to somewhere west in the western hemisphere.

With a globe projection, the map will go westwards (around the world), while other projections like the mercator projection will go eastwards (the shorter route).
This is related to #2071 and #1853.

Link to Demonstration

Screen.Recording.2023-06-29.at.16.11.24.mov

Code to reproduce:

map.flyTo({
  center: [180, 0],
});
setTimeout(() => {
  map.flyTo({
    center: [-180, 0],
  });
}, 2500);

Expected Behavior

Take the shortest possible path.

Actual Behavior

Stays on w=0 and goes "the wrong way around" the globe.

@blumk
Copy link

blumk commented Dec 30, 2023

Issue still exists in v3.0.1

Example

Plotting line between San Francisco and Auckland does not render shortest path:

image

    <Map
      mapLib={import("mapbox-gl")}
      initialViewState={{
        longitude: -100,
        latitude: 40,
        zoom: 1,
      }}
      style={{ width: "100vw", height: "100vh" }}
      mapStyle="mapbox://styles/blumk/clqrgy8cf00cu01ob4nrufv5k"
      mapboxAccessToken={mapboxToken}
      onRender={(event) => event.target.resize()}
    >
      <Source
        id="polylineLayer"
        type="geojson"
        data={{
          type: "Feature",
          properties: {},
          geometry: {
            type: "LineString",
            coordinates: [
              [174.7917, -37.008],
              [-122.375, 37.6188],
            ],
          },
        }}
      >
        <Layer
          id="lineLayer"
          type="line"
          source="my-data"
          layout={{
            "line-join": "round",
            "line-cap": "round",
          }}
          paint={{
            "line-color": "rgba(3, 170, 238, 0.5)",
            "line-width": 5,
          }}
        />
      </Source>
    </Map>

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

No branches or pull requests

3 participants