Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 即使启用了计费帐户,我仍然得到;状态:超过“查询限额”;在使用谷歌地图的地方api_Reactjs_Google Maps_Google Maps Api 3_Google Places Api_Google Console Developer - Fatal编程技术网

Reactjs 即使启用了计费帐户,我仍然得到;状态:超过“查询限额”;在使用谷歌地图的地方api

Reactjs 即使启用了计费帐户,我仍然得到;状态:超过“查询限额”;在使用谷歌地图的地方api,reactjs,google-maps,google-maps-api-3,google-places-api,google-console-developer,Reactjs,Google Maps,Google Maps Api 3,Google Places Api,Google Console Developer,我已经启用了计费功能,但在使用了很少的时间并提出了很少的请求后,我收到了: 您已超过此API的每日请求配额。如果您没有设置自定义每日请求配额,请验证您的项目是否有活动的计费帐户:有关使用限制和Google Maps JavaScript API服务的更多信息,请参阅: [react places autocomplete]:从谷歌地图API获取数据时出错。 请检查此处的文档() 状态:超出查询限制 有人能帮忙解决这个问题吗 我使用的是React js,public/index.html中的脚本代

我已经启用了计费功能,但在使用了很少的时间并提出了很少的请求后,我收到了:

您已超过此API的每日请求配额。如果您没有设置自定义每日请求配额,请验证您的项目是否有活动的计费帐户:有关使用限制和Google Maps JavaScript API服务的更多信息,请参阅:

[react places autocomplete]:从谷歌地图API获取数据时出错。
请检查此处的文档()
状态:超出查询限制

有人能帮忙解决这个问题吗

我使用的是React js,public/index.html中的脚本代码是

<script src="https://maps.googleapis.com/maps/api/js?key=MY_KEY_HERE&libraries=places"></script>

实际上,在这里我用我生成的密钥代替了我的密钥,它工作了1小时,非常好,后来它显示了这个错误

我选择地点的代码是

import React, { Component } from 'react';
import Toper3 from './Toper3';
import { MDBContainer, MDBRow, MDBCol, MDBBtn, MDBInput,MDBCard, MDBCardBody } from 'mdbreact'; 
import { Fragment } from 'react';
import axios from 'axios';
import PlacesAutocomplete, { geocodeByAddress, geocodeByPlaceId, getLatLng } from 'react-places-autocomplete';
import TimeField from 'react-simple-timefield';

const isObject = val => {
    return typeof val === 'object' && val !== null;
  };

  const classnames = (...args) => {
    const classes = [];
    args.forEach(arg => {
      if (typeof arg === 'string') {
        classes.push(arg);
      } else if (isObject(arg)) {
        Object.keys(arg).forEach(key => {
          if (arg[key]) {
            classes.push(key);
          }
        });
      } else {
        throw new Error(
          '`classnames` only accepts string or object as arguments'
        );
      }
    });

    return classes.join(' ');
  };


class FindaRide extends Component {
    constructor(props) {
        super(props);

        this.state = {
            info : [],
            source: '',
            post_address_obj: {},
            errorMessage: '',
            latitude: null,
            longitude: null,
            isGeocoding: false,   
            d_post_address_obj: {},
            d_errorMessage: '',
            d_latitude: null,
            d_longitude: null,
            d_isGeocoding: false,                      
            destination : ''
        }
        }
        handleSourceAddressChange = address => {
            // console.log(address);
            this.setState({
              source: address,
              latitude: null,
              longitude: null,
              errorMessage: ""
            });
          };
          handleDestinationAddressChange = address => {
            // console.log(address);
            this.setState({
              destination: address,
              d_latitude: null,
              d_longitude: null,
              d_errorMessage: ""
            });
          }; 
          refine(){
              alert("refinement");
              const result = this.state.info.filter(word => word.source ==this.state.source&&word.destination==this.state.destination);
              console.log("filtered "+result.length);
              this.props.history.push({pathname : `findlist`, state : {details : this.props.location.state.details,info : this.state.info}}); 

          }
          handleSubmit = (event) => {
            event.preventDefault();
            axios.get('http://127.0.0.1:8000/api2/')
            .then(res=>{
                this.setState({
                    info : res.data
                });
                //console.log(res.data);
                this.refine();

            })                
        }            
    render() {
        return (
            <div>
                <Toper3 >{this.props.location.state.details.firstname} {this.props.location.state.details.lastname}</Toper3>
                <br/>              
                <MDBContainer>
                <MDBRow>

                <MDBCol md="6" className="mb-4"  > {/*style={{ maxWidth: "22rem" }}*/}
                <MDBCard color="indigo" text="white" className="text-center" align="center" style={{ maxWidth: "22rem" }}>
                    <MDBCardBody align = "center" >
                            FILL IN THE DETAILS TO FIND A RIDE
                    </MDBCardBody>
                </MDBCard> 
                </MDBCol>   
                </MDBRow> 
                <form onSubmit={this.handleSubmit}>
                <MDBRow>
                    <MDBCol md="6" className="mb-4">

                    <label> Source </label>

                    <PlacesAutocomplete
                    value={this.state.source}
                    onChange={this.handleSourceAddressChange}
                    >
                    {({ getInputProps, suggestions, getSuggestionItemProps }) => {
                    return (
                        <div className="Demo__search-bar-container">
                        <div className="Demo__search-input-container">
                            <input
                            {...getInputProps({
                                placeholder: "Tag the location",
                                className: "Demo__search-input"
                            })}
                            />
                            {this.state.source.length > 0 && (
                            <button
                                className="Demo__clear-button"
                                onClick={this.handleCloseClick}
                            >
                                x
                            </button>
                            )}
                        </div>
                        {suggestions.length > 0 && (
                            <div className="Demo__autocomplete-container">
                            {suggestions.map(suggestion => {
                                const className = classnames("Demo__suggestion-item", {
                                "Demo__suggestion-item--active": suggestion.active
                                });

                                return (
                                /* eslint-disable react/jsx-key */
                                <div
                                    {...getSuggestionItemProps(suggestion, {
                                    className
                                    })}
                                >
                                    <strong>
                                    {suggestion.formattedSuggestion.mainText}
                                    </strong>{" "}
                                    <small>
                                    {suggestion.formattedSuggestion.secondaryText}
                                    </small>
                                </div>
                                );
                                /* eslint-enable react/jsx-key */
                            })}
                            <div className="Demo__dropdown-footer">
                                <div>
                                <img
                                    src="http://files.hostgator.co.in/hostgator254362/image/powered-by-google.png"
                                    className="Demo__dropdown-footer-image"
                                />
                                </div>
                            </div>
                            </div>
                        )}
                        </div>
                    );
                    }}
                </PlacesAutocomplete>
                </MDBCol>
                </MDBRow>
                <MDBRow>
                <MDBCol md="6" className="mb-4">
                <MDBInput
                label="SOURCE"
                group
                type="text"
                validate
                error="wrong"
                success="right"
                value = {this.state.source}
                style={{ maxWidth: "18rem" }}
                //icon="envelope"
                required
                />      
                </MDBCol>
                </MDBRow>                  
                <MDBRow>
                    <MDBCol md="6" className="mb-4">

                    <label> Destination </label>

                    <PlacesAutocomplete
                    value={this.state.destination}
                    onChange={this.handleDestinationAddressChange}
                    >
                    {({ getInputProps, suggestions, getSuggestionItemProps }) => {
                    return (
                        <div className="Demo__search-bar-container">
                        <div className="Demo__search-input-container">
                            <input
                            {...getInputProps({
                                placeholder: "Tag the location",
                                className: "Demo__search-input"
                            })}
                            />
                            {this.state.destination.length > 0 && (
                            <button
                                className="Demo__clear-button"
                                onClick={this.handleCloseClick}
                            >
                                x
                            </button>
                            )}
                        </div>
                        {suggestions.length > 0 && (
                            <div className="Demo__autocomplete-container">
                            {suggestions.map(suggestion => {
                                const className = classnames("Demo__suggestion-item", {
                                "Demo__suggestion-item--active": suggestion.active
                                });

                                return (
                                /* eslint-disable react/jsx-key */
                                <div
                                    {...getSuggestionItemProps(suggestion, {
                                    className
                                    })}
                                >
                                    <strong>
                                    {suggestion.formattedSuggestion.mainText}
                                    </strong>{" "}
                                    <small>
                                    {suggestion.formattedSuggestion.secondaryText}
                                    </small>
                                </div>
                                );
                                /* eslint-enable react/jsx-key */
                            })}
                            <div className="Demo__dropdown-footer">
                                <div>
                                <img
                                    src="http://files.hostgator.co.in/hostgator254362/image/powered-by-google.png"
                                    className="Demo__dropdown-footer-image"
                                />
                                </div>
                            </div>
                            </div>
                        )}
                        </div>
                    );
                    }}
                </PlacesAutocomplete>
                </MDBCol>
                </MDBRow>

                 <MDBRow>
                <MDBCol md="6" className="mb-4">
                <MDBInput
                label="DESTINATION"
                group
                type="text"
                validate
                error="wrong"
                success="right"
                value = {this.state.destination}
                style={{ maxWidth: "18rem" }}
                //icon="envelope"
                required
                />      
                </MDBCol>
                </MDBRow>                          
                <br/>
                <br/>                                                         
                <MDBRow>  
                <MDBCol md="4" className="mb-4">                   

                <label> DateofJourney </label>    
                <input type = "date" value = {this.state.date} onChange={this.handledatechange} />  {/*(onChange = {event => this.setState({date:event.target.value})} required*/}
                </MDBCol>
                </MDBRow> 

                <MDBRow>
                <MDBCol md="6" className="mb-4">
                <MDBInput
                label="anything to say"
                group
                type="text"
                validate
                error="wrong"
                success="right"
                value = {this.state.ats} onChange={this.handleatschange}
                style={{ maxWidth: "18rem" }}
                icon="envelope"
                required
                />      
                </MDBCol>
                </MDBRow>                                                              
                    <MDBRow>  
                    <MDBCol md="6" className="mb-4">                   
                    <Fragment>

                    <MDBBtn gradient="blue" type="submit">Submit</MDBBtn>
                    </Fragment>  
                    </MDBCol>
                </MDBRow> 
                </form>
                </MDBContainer>                    
            </div>
        );
    }
}

export default FindaRide;
import React,{Component}来自'React';
从“/Toper3”导入Toper3;
从“mdbreact”导入{MDBContainer、MDBRow、MDBCol、MDBBtn、MDBInput、MDBCard、MDBCardBody};
从“react”导入{Fragment};
从“axios”导入axios;
从“react places autocomplete”导入PlacesAutocomplete,{geocodeByAddress,geocodeByPlaceId,getLatLng};
从“反应简单时间域”导入时间域;
常量isObject=val=>{
返回typeof val=='object'&&val!==null;
};
常量类名=(…参数)=>{
常量类=[];
args.forEach(arg=>{
如果(参数类型=='string'){
类。推送(arg);
}else if(isObject(arg)){
Object.keys(arg.forEach)(key=>{
如果(参数[键]){
类。推(键);
}
});
}否则{
抛出新错误(
“`classnames`只接受字符串或对象作为参数”
);
}
});
返回类。加入(“”);
};
类FindaRide扩展组件{
建造师(道具){
超级(道具);
此.state={
信息:[],
来源:“”,
邮寄地址:{},
错误消息:“”,
纬度:空,
经度:空,
isGeocoding:错误,
地址:{},
d_错误消息:“”,
d_纬度:零,
d_经度:空,
d_is地理编码:错误,
目标:“”
}
}
handleSourceAddressChange=地址=>{
//控制台日志(地址);
这是我的国家({
资料来源:地址:,
纬度:空,
经度:空,
错误信息:“
});
};
handleDestinationAddressChange=地址=>{
//控制台日志(地址);
这是我的国家({
目的地:地址:,
d_纬度:零,
d_经度:空,
d_错误消息:“
});
}; 
精炼{
警惕(“细化”);
const result=this.state.info.filter(word=>word.source==this.state.source&&word.destination==this.state.destination);
console.log(“过滤”+结果.length);
this.props.history.push({pathname:`findlist`,state:{details:this.props.location.state.details,info:this.state.info}});
}
handleSubmit=(事件)=>{
event.preventDefault();
axios.get()http://127.0.0.1:8000/api2/')
。然后(res=>{
这是我的国家({
信息:资源数据
});
//console.log(res.data);
这个;
})                
}            
render(){
返回(
{this.props.location.state.details.firstname}{this.props.location.state.details.lastname}

{/*style={{maxWidth:“22rem”}}*/} 填写详细信息以找到一辆车 来源 {({getInputProps,suggestions,getSuggestionItemProps})=>{ 返回( {this.state.source.length>0&&( x )} {suggestions.length>0&&( {suggestions.map(suggestion=>{ const className=classnames(“演示建议项”{ “演示建议-项目--活动”:suggestion.active }); 返回( /*eslint禁用react/jsx键*/ {suggestion.formattedSuggestion.mainText} {“} {suggestion.formattedSuggestion.secondaryText} ); /*eslint启用react/jsx键*/ })} )