visgl / react-map-gl

React friendly API wrapper around MapboxGL JS
http://visgl.github.io/react-map-gl/
Other
7.88k stars 1.35k forks source link

[Bug] Unable to use Mapbox map.setPaintProperty #2443

Open newguy123-creator opened 2 weeks ago

newguy123-creator commented 2 weeks ago

Description

So how on earth do I set this property? map.setPaintProperty('basemap', 'raster-opacity', 0.5) No matter where I add it, I get console error: this is not a function

Expected Behavior

It should make the map 50% see-through without affecting its container or any of my R3F 3D components.

Steps to Reproduce

    const see = () => {
        mapRef.current.setPaintProperty("basemap", "raster-opacity", 0.5);
    };

return(
<>
                <Map
                    {...viewState}
                    antialias
                    ref={mapRef}
                    mapboxAccessToken="TOKEN"
                    style={{ width: "100%", height: "100%" }}
                    mapStyle="mapbox://styles/mapbox/standard"
                    onMove={(evt) => setViewState(evt.viewState)}
                    onLoad={() => see()}
                >

                    <NavigationControl showCompass={true} />

                    <Canvas
                        shadows
                        latitude={lat}
                        longitude={long}
                   >

                        <MainLight />
                        <Site position={[-3.855, 0, 180.526]} />

                    </Canvas>

                </Map>
</>

Environment

Logs

Uncaught TypeError: mapRef.current.setPaintProperty is not a function