Use Google Maps API key from configs (#76)

This commit is contained in:
Abhinav Jha 2020-07-10 13:05:27 +05:30 committed by GitHub
parent a3ec3b3854
commit 5ec134eae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 22 deletions

View File

@ -11,6 +11,7 @@ import PickMyLocation from "./PickMyLocation";
import styled from "styled-components"; import styled from "styled-components";
interface MapComponentProps { interface MapComponentProps {
apiKey: string;
widgetId: string; widgetId: string;
isDisabled?: boolean; isDisabled?: boolean;
isVisible?: boolean; isVisible?: boolean;
@ -159,7 +160,7 @@ class MapComponent extends React.Component<MapComponentProps> {
return ( return (
<MapWrapper onMouseLeave={this.props.disableDrag}> <MapWrapper onMouseLeave={this.props.disableDrag}>
<MyMapComponent <MyMapComponent
googleMapURL="https://maps.googleapis.com/maps/api/js?key=AIzaSyC2H_twoNbEKMm9Q0nYAh7715Dplg2asCI&v=3.exp&libraries=geometry,drawing,places" googleMapURL={`https://maps.googleapis.com/maps/api/js?key=${this.props.apiKey}&v=3.exp&libraries=geometry,drawing,places`}
loadingElement={<MapContainerWrapper />} loadingElement={<MapContainerWrapper />}
containerElement={<MapContainerWrapper />} containerElement={<MapContainerWrapper />}
mapElement={<MapContainerWrapper />} mapElement={<MapContainerWrapper />}

View File

@ -36,8 +36,6 @@ class MapWidget extends BaseWidget<MapWidgetProps, WidgetState> {
enablePickLocation: VALIDATION_TYPES.BOOLEAN, enablePickLocation: VALIDATION_TYPES.BOOLEAN,
allowZoom: VALIDATION_TYPES.BOOLEAN, allowZoom: VALIDATION_TYPES.BOOLEAN,
zoomLevel: VALIDATION_TYPES.NUMBER, zoomLevel: VALIDATION_TYPES.NUMBER,
// onMarkerClick: VALIDATION_TYPES.ACTION_SELECTOR,
// onCreateMarker: VALIDATION_TYPES.ACTION_SELECTOR,
}; };
} }
@ -114,25 +112,6 @@ class MapWidget extends BaseWidget<MapWidgetProps, WidgetState> {
} }
}; };
// componentDidMount() {
// super.componentDidMount();
// if (this.props.mapCenter) {
// this.updateWidgetMetaProperty("center", this.props.mapCenter);
// }
// }
//
// componentDidUpdate(prevProps: MapWidgetProps) {
// super.componentDidUpdate(prevProps);
// if (
// this.props.mapCenter &&
// prevProps.mapCenter &&
// (this.props.mapCenter.lat !== prevProps.mapCenter.lat ||
// this.props.mapCenter.lng !== prevProps.mapCenter.lng)
// ) {
// this.updateWidgetMetaProperty("center", this.props.mapCenter);
// }
// }
getPageView() { getPageView() {
return ( return (
<> <>
@ -154,6 +133,7 @@ class MapWidget extends BaseWidget<MapWidgetProps, WidgetState> {
)} )}
{google.enabled && ( {google.enabled && (
<MapComponent <MapComponent
apiKey={google.apiKey}
widgetId={this.props.widgetId} widgetId={this.props.widgetId}
isVisible={this.props.isVisible} isVisible={this.props.isVisible}
zoomLevel={this.props.zoomLevel} zoomLevel={this.props.zoomLevel}