"google api is already presented"



谷歌地图"loading"和错误信息

MapScreen文件在react app.

const libs = ['places'];
return (
<div className="full-box">
<LoadScript libraries={libs} googleMapsApiKey={googleApiKey}>
<GoogleMap
id="smaple-map"
mapContainerStyle={{ height: '100%', width: '100%' }}
center={center}
zoom={15}
onLoad={onLoad}
onIdle={onIdle}
>
<StandaloneSearchBox
onLoad={onLoadPlaces}
onPlacesChanged={onPlacesChanged}
>
<div className="map-input-box">
<input type="text" placeholder="Enter your address"></input>
<Button type="button" onClick={onConfirm}>
Confirm
</Button>
</div>
</StandaloneSearchBox>
<Marker position={location} onLoad={onMarkerLoad}></Marker>
</GoogleMap>
</LoadScript>
</div>
);

我得到这个错误时,试图实现谷歌地图api到我的电子商务应用程序。我读过其他线程说我只能有一个,但是,我在整个应用程序上只有一个loadscript标签,所以这并没有解决我的问题。希望我没有掩盖一些愚蠢的东西,但我已经被这个错误困了几天了,现在试图找到一个解决方案。

由于实例化LoadScript组件的位置导致google api已经存在。

你需要将LoadScript移动到一个不会呈现的父组件中。最好的地方是靠近你的树的根部。

请查看此问题以获得更清晰的信息。

相关内容

最新更新