谷歌api密钥在我的ios应用程序上不起作用




我已经在用phonegap开发的ios应用程序中插入了地理定位
当我打开我的map.html页面时,设备应该会在谷歌地图上显示我的位置。现在,当我打开map.html时,我收到了一个使用我的gps的请求,然后出现了一个错误:"谷歌禁用了此应用程序使用谷歌地图API。提供的密钥不是有效的谷歌API密钥,或者它未被授权用于此网站上的谷歌地图API Javascript v3。如果你是此应用程序的所有者,你可以在这里找到更多信息:https://developers.google.com/maps/documentation/javascript/tutorial#api_key">

所以问题是api密钥,我已经阅读了文档并在网上搜索过,但我无法解决它。我正在用我的ipad作为设备用xcode测试这个应用程序,它不在苹果商店里。如果我使用浏览器密钥,我不知道我需要使用哪个链接,如果我尝试使用ios密钥,它就不起作用。我尝试插入在phonegap安装过程中生成的捆绑包标识符(com.example.pas-si(和在我的苹果证书中签名的标识符(it.quidfarm.approva(。
我已经从开发者控制台激活了适当的api,我不会有配额问题,因为应用程序只在我的设备上
我认为有一些基础设置我没有以正确的方式设置。

我已经用Phonegap完成了我的应用程序,并使用此指南安装了地理本地化http://www.devx.com/wireless/implement-google-maps-api-on-phonegap-using-the-device-api.html
这是我的地图.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <title>Pas.si</title>
</head>
<body>
    <div data-role="page" id="page" style="background-color:transparent;" >
        <!-- ....Menu and other Html stuffs -->
         <div id="content">
            <div id="geolocation" style="width: 600px; height: 300px;">
            </div>
            <script type="text/javascript" src="phonegap.js"></script>
            <script type="text/javascript" src="js/mappa.js"></script>
            <script src="http://maps.googleapis.com/maps/api/js?key=MY-API-KEY&sensor=false">
            </script>
            <script type="text/javascript">
                app.initialize();
            </script>
         </div> <!-- END #content -->
  <!-- .... other Html stuffs -->
</div> <!-- END #page -->
   <!-- Java to shows a menu - not for geolocalization -->
   <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script type="text/javascript">
        $('#menu').click(function() {
         $('#listamenu').toggleClass('classmenub classmenua');
                });
    </script>
</body>
</html>

这是我的map.js

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var app = {
// Application Constructor
initialize: function() {
    this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicity call 'app.receivedEvent(...);'
onDeviceReady: function() {
    // Get our current location
    navigator.geolocation.getCurrentPosition(app.onSuccess, app.onError);
},
// Current location was found
// Show the map
onSuccess: function(position) {
    var longitude = position.coords.longitude;
    var latitude = position.coords.latitude;
    var latLong = new google.maps.LatLng(latitude, longitude);

    var mapOptions = {
        center: latLong,
        zoom: 16,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map=new google.maps.Map(document.getElementById("geolocation"), mapOptions);
},
// Current location could not be determined
// Show error
onError: function(error) {
    alert('code: '   + error.code   + 'n' + 'message: ' + error.message + 'n');
},
 };

我正在使用phonegap 3.3,Xcode 5.0.2。在操作系统10.8.5 的Mac Book pro上

谢谢你,很抱歉我的英语不好,希望你能理解这个问题。

由于GoogleMaps API v3不需要API密钥,因此您现在可以删除它。

将来,如果达到使用限制,您可能需要重新添加它。在这种情况下,您将希望进一步了解如何将应用程序命名空间添加到API密钥实例中。

相关内容

  • 没有找到相关文章

最新更新