【发布时间】:2017-05-22 19:23:09
【问题描述】:
我正在尝试找到一个示例,说明如何在 admin-on-rest 框架 (https://marmelab.com/admin-on-rest/) 中使用任何 Google Maps React 组件(例如这个 - https://github.com/istarkov/google-map-react)。
有人看吗?
谢谢。
【问题讨论】:
标签: google-maps reactjs admin-on-rest
我正在尝试找到一个示例,说明如何在 admin-on-rest 框架 (https://marmelab.com/admin-on-rest/) 中使用任何 Google Maps React 组件(例如这个 - https://github.com/istarkov/google-map-react)。
有人看吗?
谢谢。
【问题讨论】:
标签: google-maps reactjs admin-on-rest
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%` }} />}/>
希望对你有所帮助
【讨论】: