我正在尝试使用google maps javasrcipt API 3将google地图嵌入到我的网站中。我已经生成了一个密钥,并按如下方式输入:
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzSyBZsRvsDrBFh4-kVadHK&sensor=true">
</script>(查看前一行代码中的参数key= )。
当我打开我的应用程序时,我得到一个通知,我输入的密钥是无效的,地图崩溃了。
有人能在这方面帮我吗!
发布于 2014-03-13 08:00:21
当您通过javascript加载其他API时,将使用浏览器密钥。
您可以使用Maps API和Javascript API简化您的include
<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=true"></script>
<script src="https://apis.google.com/js/client.js?onload=init"></script>在你的代码中,比如Fusion表,你可以这样添加它:
function init() {
gapi.client.load('fusiontables', 'v1', function() {
gapi.client.setApiKey( "YOUR_BROWSER_API_KEY_HERE" );
//Other stuff to do on loading this
gapi.client.fusiontables.query.sql({sql:["SELECT * FROM", TABLE_NAME].join(' '), fields:'rows, columns'}).execute( function(json) {
//Do what you need to parse the json response
//Set up KML Layers
//etc... make sure to check if maps is loaded too
json.rows.forEach( function(t) {
console.log( t );
});
});
});
}你将能够用这种方式做授权的东西(不是OAuth 2.0)。
https://stackoverflow.com/questions/22353463
复制相似问题