I have created a project that should display Google Map, but I constantly get a maps displayed with watermark and a warning in a console: Google Maps JavaScript API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys. Here's the React code snippet:
import React, { Fragment } from "react";
import { useJsApiLoader, GoogleMap, Marker } from "@react-google-maps/api";
const GoogleMapComp = () => {
const { isLoaded } = useJsApiLoader({
googleMapsApiKey: process.env.key,
});
const center = { lat: 42.4414, lng: 19.2624 };
if (!isLoaded) {
return (
<div>
<p>Loading...</p>
</div>
);
}
return (
<Fragment>
<GoogleMap
center={center}
zoom={15}
mapContainerStyle={{
width: "100%",
height: "100%",
}}
options={{
zoomControl: false,
streetViewControl: false,
mapTypeControl: false,
fullscreenControl: false,
}}
>
<Marker position={center} />
</GoogleMap>
</Fragment>
);
};
export default GoogleMapComp;
I have tried to read documentation and create new API in google cloud platform, but nothing seems to help. Please, help!