簡體   English   中英

Google Maps Geolocation API僅返回我陣列中第一座塔的位置

[英]Google Maps Geolocation API only ever returning location of 1st tower in my array

我正在嘗試使用Google Maps Geolocation API。 我正在將包含單元格塔的JSON文件發布到https://www.googleapis.com/geolocation/v1/geolocate?key=MYKEY

示例JSON:

{
    "cellTowers":[
    {
        "cellId":65535,
        "locationAreaCode":5160,
        "mobileCountryCode":234,
        "mobileNetworkCode":10,
        "signalStrength":-53
    },
    {
        "cellId":34177,
        "locationAreaCode":5160,
        "mobileCountryCode":234,
        "mobileNetworkCode":10,
        "signalStrength":-55
    }
]}

這已經過驗證,正確的JSON。 然而,我遇到了從API獲取正常數據的問題。

我使用Apache HTTPClient和HTTPPost庫在Java中實現了POST。 我得到了有效的回復,但它始終是cellTowers數組中第一個單元塔的LAT,LNG。 好像API正在讀取第一個蜂窩塔,獲取位置然后忽略其余的。 當然,我已經通過對列表進行反轉和混洗來驗證這是行為,每次響應都會改變到第一個塔位置。 這是我的代碼:

HttpParams httpParams = new BasicHttpParams();
ConnRouteParams.setDefaultProxy(httpParams, new HttpHost(PROXY_HOST, PROXY_PORT));
HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);

HttpClient client = new DefaultHttpClient(httpParams);
HttpPost request = new HttpPost(GOOGLE_GEOLOCATION_API);
request.setHeader("Content-type", "application/json");

try {
    StringEntity se = new StringEntity(json);
    request.setEntity(se);

    HttpResponse response = client.execute(request);
    if(response!=null){
        String jsonResult = EntityUtils.toString(response.getEntity());
        GeolocationResponse geolocationResponse = gson.fromJson(jsonResult, GeolocationResponse.class);

        logger.info(jsonResult);
        logger.info("Est. Location: " + geolocationResponse.toString());
    }
} catch (Exception e) {
    e.printStackTrace();
}

Geolocation API一次只支持一個單元塔嗎? 我認為它比這更聰明,在所有塔上使用某種信號傳播和距離估計。

在最近與Google就我們的地圖API訂閱進行的溝通中,我詢問了有關Geo-location API的一些一般信息。 事實證明它不會對細胞塔信號進行任何復雜的三角測量。

他們只使用第一個被認為有效的。 參考: http//code.google.com/p/gmaps-api-issues/issues/detail?id = 6929

暫無
暫無

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

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