javascript - 谷歌地图“仅用于开发目的”
问题描述
我的谷歌地图显示不正确。它显示“仅用于开发目的”,谷歌说我需要创建并启用一个计费帐户并创建一个 API 密钥。我已经这样做了,但是我需要在代码中更改或添加一些东西吗?
// Get the HTML DOM element that will contain your map
// We are using a div with id="map" seen below in the <body>
var mapElement = document.getElementById('map');
var map = new google.maps.Map(mapElement, mapOptions);
var image = 'http://filmservice.no/wp-content/themes/filmservice16/img/ikon/map-marker.png';
var marker = new google.maps.Marker({
position: new google.maps.LatLng(59.969826, 10.905725),
animation: google.maps.Animation.DROP,
map: map,
icon: image,
title: 'Filmservice AS'
});
function toggleBounce() {
if (marker.getAnimation() !== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
解决方案
您需要进行的更改实际上是在您的 HTML 标记中,其中包含 google maps API 脚本:
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script>
有关更多信息,请参阅https://developers.google.com/maps/documentation/javascript/tutorial上的教程。
推荐阅读
- javascript - Typescript,Angular:使用 mailto 将超链接添加到邮件正文
- php - php如何在mysql的for循环中生成动态数据库连接
- machine-learning - 实体类型识别:从描述中找到实体的主要类型
- php - PHP插入准备好的语句
- javascript - 如何从 url 地址中删除引号?
- polymer - 将 Polymer 1.6.x 组件升级到版本 3 的最佳策略是什么?
- android - 两个recyclerview未在一个布局中显示
- python - 连接python列表中的单个元素
- java - 修改匿名函数以调用 Kotlin 中的另一个匿名函数
- sql - 无法识别 SQL 作为关键字