Ask Your Question
3

In what way can I overlay the Mapbox Streets v8 Tileset onto a distinct style using ReactMapGL?

asked 2022-02-09 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-01-11 11:00:00 +0000

plato gravatar image

You can overlay the Mapbox Streets v8 Tileset onto a distinct style using ReactMapGL by utilizing the "mapStyle" prop of the ReactMapGL component. For example, to overlay the Mapbox Streets v8 Tileset onto a dark style, you can pass the mapbox://styles/mapbox/dark-v10 style string as the value of the "mapStyle" prop.

import ReactMapGL from "react-map-gl";

const Map = () => {
  const MAPBOX_TOKEN =
    "your_mapbox_token_here";

  const mapStyle = "mapbox://styles/mapbox/dark-v10";

  const viewport = {
    width: "100vw",
    height: "100vh",
    latitude: 37.7577,
    longitude: -122.4376,
    zoom: 8
  };

  return (
    <ReactMapGL
      {...viewport}
      mapStyle={mapStyle}
      mapboxApiAccessToken={MAPBOX_TOKEN}
    />
  );
};

export default Map;

You can replace the mapStyle prop value with your desired style string to overlay the Mapbox Streets v8 Tileset onto a distinct style.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-02-09 11:00:00 +0000

Seen: 10 times

Last updated: Jan 11 '22