如何在 JQUERY 移动设备上放置 google 地图?
How to put a google map on JQUERY Mobile?
当尝试 运行 代码时,地图没有显示,它显示了这个错误"Google Maps API warning: NoApiKeys "
。有什么可能的解决方案?
这是我添加的脚本:
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
这些是我放在 js 文件中的代码:
$(document).ready(function () {
var myOptions = {
zoom: 11,
center: new google.maps.LatLng(1.363083, 103.909836),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
var myLatlng = new google.maps.LatLng(1.443107 , 103.795681);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "Map "
})
});
该错误表明您没有在 Google 地图 api 调用中包含 API 键。您需要前往 https://developers.google.com/maps/,注册一个 API 密钥,并将其包含在您的通话中。下面是一个使用 JS api.
的非常简单的例子
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY></script>
当尝试 运行 代码时,地图没有显示,它显示了这个错误"Google Maps API warning: NoApiKeys "
。有什么可能的解决方案?
这是我添加的脚本:
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
这些是我放在 js 文件中的代码:
$(document).ready(function () {
var myOptions = {
zoom: 11,
center: new google.maps.LatLng(1.363083, 103.909836),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
var myLatlng = new google.maps.LatLng(1.443107 , 103.795681);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "Map "
})
});
该错误表明您没有在 Google 地图 api 调用中包含 API 键。您需要前往 https://developers.google.com/maps/,注册一个 API 密钥,并将其包含在您的通话中。下面是一个使用 JS api.
的非常简单的例子<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY></script>