@react-google-maps/api 自动完成将结果严格限制在特定区域

问题描述

我正在使用 @react-google-maps/api 包获取自动完成结果。 但我只想从西班牙马略卡岛获得结果。

const bounds = {
    north: 39.980392,south: 39.254704,east: 3.463581,west: 2.263324,}

const restrictions = {
    country: 'es',}

…… ……

  render() {
    return (
        <div className="p-8">
            <LoadScript
                googleMapsApiKey="My API Key"
                libraries={["places"]}
            >
                <Autocomplete
                   onLoad={this.onFromload}
                   onPlaceChanged={this.onFromPlaceChanged}
                   bounds={bounds}
                   restrictions={restrictions}
                >
                  <TextField
                      className="mb-6 w-full"
                      label="From"
                      onChange={this.handleChange}
                      type="text"
                      name="from"
                      value={this.state.from}
                      validators={["required"]}
                      errorMessages={[
                         "this field is required"
                      ]}
                   />
               </Autocomplete>
           </LoadScript>
        </div>
     )
  }

结果仅限于国家/地区(西班牙)。 不限于特定的边界区域。

请帮帮我。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)