示例DirectionsRenderer正在崩溃

时间:2017-12-22 14:02:35

标签: google-maps google-maps-api-3 react-google-maps

我使用https://tomchentw.github.io/react-google-maps/#!/DirectionsRenderer

中的原始代码

我的组件:

export default class MyComponent extends React.Component {
render() {
    return (
        <main className="main--container">
            <MapWithADirectionsRenderer />;
        </main>
    );
}}

在与反应路由器呈现的容器中连接。

错误:

Uncaught TypeError: Cannot read property 'apply' of undefined
    at eval (Recompose.js:831)
    at eval (Recompose.js:831)
    at eval (Recompose.js:831)
    at eval (MyComponent.js:71)
    at Object.<anonymous> (app.bundle.js:12417)
    at __webpack_require__ (app.bundle.js:679)
    at fn (app.bundle.js:89)
    at eval (MyComponentContainer.js:14)
    at Object.<anonymous> (app.bundle.js:12410)
    at __webpack_require__ (app.bundle.js:679)

在任何页面上获取错误,即使MapWithADirectionsRenderer未呈现 如果下一个代码被删除,则仅在包含我的容器的页面上获取错误:

(props =>
    <GoogleMap
        defaultZoom={7}
        defaultCenter={new google.maps.LatLng(41.8507300, -87.6512600)}
    >
        {props.directions && <DirectionsRenderer directions={props.directions} />}
    </GoogleMap>
);

1 个答案:

答案 0 :(得分:0)

如果有人会遇到类似的问题,你应该像这样导入像这样的

import withScriptjs from "react-google-maps/lib/async/withScriptjs";
相关问题