簡體   English   中英

嘗試按地址獲取GPS坐標時,我應該在哪里添加Google API密鑰?

[英]Where should i add the Google API key when i try to get gps coordinates by address?

我想我將地圖Google API密鑰添加到了錯誤的位置。 請幫我:

相關的API密鑰也更新資源:

    <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyAzSgqQEZ..........KMsLlN4</string>


 @Override
        protected String doInBackground(String... strings) {
            String response;
            try {
                String address = strings[0];
                HttpDataHandler http = new HttpDataHandler();

                String url = String.format("http://maps.googleapis.com/maps/api/geocode/json?address=%s&key=AIzaSyAzSgqQEZS1K1...........KMsLlN4", address);

            response = http.getHTTPData(url);
                return response;
            } catch (Exception ex) {

            }
            return null;
        }

我沒有得到任何結果,我想我還是訪問被拒絕......我應該在哪里放呢?

從官方文檔->

got to the gradle.properties file and add a value with name GOOGLE_MAPS_API_KEY="your api key" and rebuild project.After in your manifest file you will see api key.

PS不要忘記權限

解決方案是在Google Api控制台中啟用Geocoding API,並將其限制為特定的應用程序!!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM