HTML
<div class="google-map">
<div class="map" id="map" data-address="Gatterholzgasse 14, 1120 Wien">
</div>
JS
google.maps.event.addDomListener(window, 'load', initMap);
function initMap() {
var geocoder = new google.maps.Geocoder();
var $maps = $('.map');
if($maps.length) {
$maps.each(function() {
var map = this;
var $map = $(this);
var address = $map.data('address');
var latLng, gMap, pin;
geocoder.geocode({ 'address' : address }, function(results, status) {
if( status == google.maps.GeocoderStatus.OK ) {
latLng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
} else {
console.log("Geocoding unsuccessful. Reason: " + status);
latLng = new google.maps.LatLng(48.1792339,16.3194208,17);
}
var styledMap = new google.maps.StyledMapType(mapStyle, { name: 'Styled Map' });
gMap = new google.maps.Map(map, {
center: latLng,
zoom: 17,
disableDefaultUI: true,
scrollwheel: true
});
gMap.mapTypes.set('map_style', styledMap);
gMap.setMapTypeId('map_style');
pin = new google.maps.Marker({
position: latLng,
map: gMap,
icon: './img/google-map/map-pin.png',
title: 'Gatterholzgasse 14, 1120 Wien'
});
});
});
}
}
Google Chrome控制台错误
Geocoding Service: You have exceeded your daily request quota for this API. For more information on usage limits and the Google Maps JavaScript API services please see: https://developers.google.com/maps/documentation/javascript/usage
Geocoding unsuccessful. Reason: OVER_QUERY_LIMIT
You have exceeded your request quota for this API. See https://developers.google.com/maps/documentation/javascript/error-messages?utm_source=maps_js&utm_medium=degraded&utm_campaign=billing#api-key-and-billing-errors
我试图更改API密钥,但没有任何改变。
我读到每天的免费访问限制是25000个唯一身份访问者,但我绝对没有。
任何建议将不胜感激。预先感谢