我正在尝试找到一个如何在 admin-on-rest 框架 (https://marmelab.com/admin-on-rest/( 中使用任何 Google Maps React 组件(如这个 - https://github.com/istarkov/google-map-react
(的示例。有人有可看的吗?
谢谢。
-
npm install --save react-google-maps
# 或yarn add react-google-maps
-
import { GoogleMap,withScriptjs,withGoogleMap, Marker } from "react-google-maps"
3.
export const MyMapComponent = withScriptjs(withGoogleMap((props) =>
<GoogleMap
defaultZoom={8}
defaultCenter={{ lat: 24.715297, lng: 46.671848 }}>
{props.isMarkerShown && <Marker position={{ lat: 24.715297, lng: 46.671848 }} />}
</GoogleMap>))
- 在您的导出常量帖子中创建例如
<MyMapComponent
isMarkerShown
googleMapURL="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places"
loadingElement={<div style={{ height: `100%` }} />}
containerElement={<div style={{ height: `400px`,width:`500px`,paddingTop:`100px` }} />}
mapElement={<div style={{ height: `100%` }} />}/>
希望这个帮助