-2

I am using @react-google-maps/api and I have a custom map style. I have a map that uses the style, then I try to load it like this:

const API_KEY = process.env.REACT_APP_GOOGLE_MAPS_API_KEY;
const MAP_ID = process.env.REACT_APP_GOOGLE_MAPS_MAP_ID;

const Map = () => {
    const { isLoaded } = useJsApiLoader({
        id: 'google-map-script',
        googleMapsApiKey: API_KEY,
        mapIds: [MAP_ID],
    });

    return (
        <Wrapper>
            <GoogleMap />
        </Wrapper>
   )
};

ReactDOM.render(<Map/>,document.getElementById('root'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-google-maps-api@1.0.8/lib/index.min.js"></script>
<div id='root'></div>

But the styles don't load, and I don't get any error messages from the JS, neither in the network tab. Am I missing a step, and how can I check if my map is the one being loaded

Note: The account has billing enabled and a credit card added so this is not caused by development only restrictions

1 Answers1

1

The problem was that it has to be passed as a option to the GoogleMap component like that

<GoogleMap
    options={{ mapId: MAP_ID }}
>

Thanks @MrUpsidown, for proposing this solution