Google 地图和地点 API 超出了此 API 的请求配额

  • 本文关键字:API 请求 地图 Google javascript
  • 更新时间 :
  • 英文 :


我在000webhost上创建了网站。 我在上面使用地图并创建新的谷歌 API 密钥,但问题是当我第一次通过消息点击 API 时超过了您的"此 API 的请求配额",在我第一次使用新的 API 密钥点击 API 之前,我从未点击过它。 这是我的 PHP 脚本。 我需要帮助

function initMap() {
var map = new google.maps.Map(document.getElementById('show_map'), {
center: {lat: 33.6518, lng: 73.1566},
zoom: 13
});
var input = document.getElementById('shopadd');
var options = {
types: ['(cities)'],
componentRestrictions: {country: 'pk'}
};
var autocomplete = new google.maps.places.Autocomplete(input,options);
// Bind the map's bounds (viewport) property to the autocomplete object,
// so that the autocomplete requests use the current map bounds for the
// bounds option in the request.
autocomplete.bindTo('bounds', map);
// Set the data fields to return when the user selects a place.
autocomplete.setFields(['address_components', 'geometry', 'name']);
autocomplete.setOptions({strictBounds: true});
var infowindow = new google.maps.InfoWindow();
var infowindowContent = document.getElementById('infowindow-content');
infowindow.setContent(infowindowContent);
var marker = new google.maps.Marker({
map: map,
anchorPoint: new google.maps.Point(0, -29)
});
autocomplete.addListener('place_changed', function() {
infowindow.close();
marker.setVisible(false);
var place = autocomplete.getPlace();
if (!place.geometry) {
// User entered the name of a Place that was not suggested and
// pressed the Enter key, or the Place Details request failed.
window.alert("No details available for input: '" + place.name + "'");
return;
}
var location = "Address " + place.formatted_address;
location += "Latitude " + place.geometry.location.lat();
location += "Longitude " + place.geometry.location.lng();
var lat = place.geometry.location.lat();
document.getElementById('lat').value = lat;
var lng = place.geometry.location.lng();
document.getElementById('lng').value = lng;
// If the place has a geometry, then present it on a map.
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);  // Why 17? Because it looks good.
}
marker.setPosition(place.geometry.location);
marker.setVisible(true);
var add = '';
if (place.address_components.length>0) {
add = add.concat(
(place.address_components[0] && place.address_components[0].short_name || ''),' ',
(place.address_components[1] && place.address_components[1].short_name || ''),' ',
(place.address_components[2] && place.address_components[2].short_name || ''),' ');
}
document.getElementById('add').value = add;
infowindowContent.children['place-icon'].src = place.icon;
infowindowContent.children['place-name'].textContent = place.name;
infowindowContent.children['place-address'].textContent = add;
infowindow.open(map, marker);
});
// Sets a listener on a radio button to change the filter type on Places
// Autocomplete.
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key="my key"&libraries=places&callback=initMap" async defer></script>

谷歌改变了他们的定价模式。新计划为您提供了更大的灵活性,并可以控制如何使用我们的 API。您可以根据需要使用或多或少,并且只需为每月使用的内容付费。
截至2018年7月16日:

  • Google Maps Platform API 按 SKU 计费。
  • 跟踪每个产品 SKU 的使用情况,一个 API 可能有多个产品 SKU。
  • 成本的计算公式为:SKU 使用情况 x 每次使用的价格。
  • 对于每个结算帐号,对于符合条件的 Google 地图平台 SKU,每个月都会获得 200 美元的 Google 地图平台信用额度,并自动应用于符合条件的 SKU。

有关更多信息,请访问此链接

最新更新