【问题标题】:Google map and places api exceeded your request quota for this APIGoogle 地图和地点 API 超出了您对此 API 的请求配额
【发布时间】:2019-02-03 21:53:02
【问题描述】:

我在 000webhost 上创建了网站。我在上面使用地图并创建新的google 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>

【问题讨论】:

    标签: javascript


    【解决方案1】:

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

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

    欲了解更多信息,请访问Link

    【讨论】:

      猜你喜欢
      • 2019-08-21
      • 2019-02-23
      • 2016-11-08
      • 2019-01-12
      • 1970-01-01
      • 1970-01-01
      • 2014-12-07
      • 2016-10-30
      相关资源
      最近更新 更多