Google Place API 限制 - 不是使用限制

Google Place API Limit - NOT usage limit

本文关键字:Place API 限制 Google      更新时间:2023-09-26

我已经设法启动并运行了Google Places,但是我可以添加的国家/地区变量的数量似乎有限制。我的代码基于他们的一个示例:

https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-hotelsearch

但是每次我尝试将一个国家/地区添加到var countries部分并重新加载页面时,我都会得到一个空白页面,底部只有一个下拉菜单和一些文本。

我可以添加到 Google 地方信息的国家/地区变量数量是否有限制?

更新:

添加额外的国家/地区。

javascript与上面的例子相同:

var map, places, infoWindow; 
 var markers = []; 
 var autocomplete; var countryRestrict = { 'country': 'uk' };
 var MARKER_PATH = 'maps.gstatic.com/intl/en_us/mapfiles/marker_green'; 
 var hostnameRegexp = new RegExp('^https?://.+?/');
 var countries = { 
 'at': { 
 center: new google.maps.LatLng(47.5, 14.5), 
 zoom: 6 }, 
 'be': { 
 center: new google.maps.LatLng(50.5, 4.4),
 zoom: 6 },

然后在HTML中有一个下拉菜单:

<div id="controls"> 
<select id="country"> 
<option value="at">Austria</option>

我很确定这不是编码问题,更重要的是当包括超过 18 个国家/地区时,它似乎停止工作。

很抱歉耽搁了。

var countries = {
  'at': { 
    center: new google.maps.LatLng(47.0, 14.5), 
    zoom: 6 }, 
  'be': { 
    center: new google.maps.LatLng(52.5, 4.4),
    zoom: 6 },
  'cz': { 
    center: new google.maps.LatLng(49.817492, 15.472962), 
    zoom: 6 }, 
  'bz': { 
    center: new google.maps.LatLng(17.189877, -88.497650),
    zoom: 6 },
  'hn': { 
    center: new google.maps.LatLng(15.199999, -86.241905), 
    zoom: 6 }, 
  'cr': { 
    center: new google.maps.LatLng(9.748917, -83.753428),
    zoom: 6 },
  'co': { 
    center: new google.maps.LatLng(4.570868, -74.297333),
    zoom: 6 },
  'au': {
    center: new google.maps.LatLng(-25.3, 133.8),
    zoom: 4
  },
  'br': {
    center: new google.maps.LatLng(-14.2, -51.9),
    zoom: 3
  },
  'ca': {
    center: new google.maps.LatLng(62, -110.0),
    zoom: 3
  },
  'fr': {
    center: new google.maps.LatLng(46.2, 2.2),
    zoom: 5
  },
  'de': {
    center: new google.maps.LatLng(51.2, 10.4),
    zoom: 5
  },
  'mx': {
    center: new google.maps.LatLng(23.6, -102.5),
    zoom: 4
  },
  'nz': {
    center: new google.maps.LatLng(-40.9, 174.9),
    zoom: 5
  },
  'it': {
    center: new google.maps.LatLng(41.9, 12.6),
    zoom: 5
  },
  'za': {
    center: new google.maps.LatLng(-30.6, 22.9),
    zoom: 5
  },
  'es': {
    center: new google.maps.LatLng(40.5, -3.7),
    zoom: 5
  },
  'pt': {
    center: new google.maps.LatLng(39.4, -8.2),
    zoom: 6
  },
  'us': {
    center: new google.maps.LatLng(37.1, -95.7),
    zoom: 3
  },
  'uk': {
    center: new google.maps.LatLng(54.8, -4.6),
    zoom: 5
  }
};

和 html:

<div id="controls">
      <select id="country">
        <option value="all">All</option>
        <option value="bz">Belize</option>
        <option value="cz">Czech Republic</option>
        <option value="hn">Honduras</option>
        <option value="cr">Costa Rica</option>
        <option value="co">Colombia</option>
        <option value="at">Austria</option>
        <option value="be">Belgium</option>
        <option value="au">Australia</option>
        <option value="br">Brazil</option>
        <option value="ca">Canada</option>
        <option value="fr">France</option>
        <option value="de">Germany</option>
        <option value="mx">Mexico</option>
        <option value="nz">New Zealand</option>
        <option value="it">Italy</option>
        <option value="za">South Africa</option>
        <option value="es">Spain</option>
        <option value="pt">Portugal</option>
        <option value="us" selected>U.S.A.</option>
        <option value="uk">United Kingdom</option>
      </select>
    </div>