Google Geolocation API is always returning the same location regardless of cellTower specified

你说的曾经没有我的故事 提交于 2020-04-30 11:22:28

问题


I'm using the Google Geolocation API to approximate location based on cell towers that are visible. However, I always get the same location as the result.

Using the following body:

{
    "considerIp": false,
    "radioType": "lte",
    "cellTowers": [{
        "signalStrength": -78,
        "cellId": 133978007,
        "mobileNetworkCode": 410,
        "mobileCountryCode": 310,
        "locationAreaCode": 27196
    }]
}

Produces the following result: {"location": {"lat": 31.968598800000002, "lng": -99.9018131}, "accuracy": 1457406}

The actual location of that tower/cell is approx (32.783062, 96.795769). In fact, the cell tower specified is take directly from OpenCellID's database (opencellid.org)

If I then select a tower somewhere else (e.g. Palo Alto)

{
    "considerIp": false,
    "radioType": "lte",
    "cellTowers": [{
        "signalStrength": -78,
        "cellId": 84785686,
        "mobileNetworkCode": 480,
        "mobileCountryCode": 311,
        "locationAreaCode": 7943
    }]
}

The response is: {"location": {"lat": 31.968598800000002, "lng": -99.9018131}, "accuracy": 1457406} which is exactly the same.

If I can my public IP (via changing VPN end-point location) the results DO change. Using the same Palo Alto query but changing from a Texas to Chicago end-node my result changes to: {"location": {"lat": 37.09024, "lng": -95.712891}, "accuracy": 1488703}

It looks like the considerIp=false argument is being ignored and that is only being used instead of the provided cell tower.

Any ideas how to fix this? Thanks!


回答1:


I figured it out. Apparently if the Content-Type is not being explicitly set to application/json then the body is silently ignored and only the local IP is considered.

I would like to request that Google updates the API response body to include something to that effect.



来源:https://stackoverflow.com/questions/60213787/google-geolocation-api-is-always-returning-the-same-location-regardless-of-cellt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!