Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
544 views
in Technique[技术] by (71.8m points)

reactjs - How do I overlay satellite scene data on basemap in Deck.gl?

I have a question on the bounds of TileLayer.

I am fetching cropped tiles from a tile server and provide them to TileLayer's "data".

It works well and it shows my raster file well. However, when my viewpoint moves out of raster files' bounds,

it shows following error & webpage.

{"errorMessage": "Tile 11/1745/795 is outside image bounds"}

https://user-images.githubusercontent.com/70316208/101444110-211c1980-3962-11eb-9099-b5e46c45cec4.png

useEffect(() => {
    fetch(endpoint + raster_path)
      .then((res) => {
        if (res.ok) return res.json();
        // throw new Error("Network response was not ok.");
      })
      .then((data) => {
        setTiles(data);
      });
  }, [raster_path]);

  const tileLayer = new TileLayer({
    data: [tiles.tiles + color],
    maxRequests: 6,

    pickable: true,
    onViewportLoad: null,
    autoHighlight: false,
    highlightColor: [60, 60, 60, 40],
    minZoom: 0,
    maxZoom: 19,
    tileSize: 512 / devicePixelRatio,
    extent: [tiles.bounds],
    maxCacheSize: 30,

    renderSubLayers: (props) => {
      const {
        bbox: { west, south, east, north },
      } = props.tile;
      console.log(props);

      return [
        new BitmapLayer(props, {
          data: null,
          image: props.data,
          bounds: [west, south, east, north],
        }),
      ];
    },
  });

  const layers = [
    tileLayer,
  ];

  return (
    <div>
      <DeckGL
        initialViewState={viewport}
        views={new MapView({ repeat: true })}
        controller={true}
        layers={[layers]}
        onViewportChange={handleViewportChange}
      >
        <ReactMapGL
          {...viewport}
          width="100%"
          height="100%"
          onViewportChange={handleViewportChange}
          mapboxApiAccessToken={process.env.REACT_APP_MAPBOX_TOKEN}
          mapStyle="mapbox://styles/mapbox/streets-v9"
        ></ReactMapGL>
      </DeckGL>
    </div>
  );
}
question from:https://stackoverflow.com/questions/65897584/how-do-i-overlay-satellite-scene-data-on-basemap-in-deck-gl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...