首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌地图,cellid to location

谷歌地图,cellid to location
EN

Stack Overflow用户
提问于 2009-10-21 12:18:22
回答 5查看 68.1K关注 0票数 15

根据此示例:

http://www.codeproject.com/KB/mobile/DeepCast.aspx

在发送单元It信息(MCC、MNC、towerid等)时,可以请求包含范围的gps坐标(经度和纬度)

有人能告诉我请求/post到这个地址的实际参数是什么吗?

http://www.google.com/glm/mmap

可能是这样的

代码语言:javascript
复制
http://www.google.com/glm/mmap?mcc=xxx&mnc=xxx&towerid=xxx

我想知道我们会得到什么回应。

我观察了OpenCellid网站,他们提供了一些很好的应用程序接口开始,但我也想知道在谷歌地图(因为他们有更完整的数据库)。

OpenCellID API

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2010-07-29 04:00:29

以下是使用的示例

代码语言:javascript
复制
#!/usr/bin/python

country = 'fr'
#device = 'Sony_Ericsson-K750'
device = "Nokia N95 8Gb"
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
mmap_url = 'http://www.google.com/glm/mmap'
geo_url = 'http://maps.google.com/maps/geo'

from struct import pack, unpack
from httplib import HTTP
import urllib2

def fetch_latlong_http(query):
    http = HTTP('www.google.com', 80)
    http.putrequest('POST', '/glm/mmap')
    http.putheader('Content-Type', 'application/binary')
    http.putheader('Content-Length', str(len(query)))
    http.endheaders()
    http.send(query)
    code, msg, headers = http.getreply()
    result = http.file.read()
    return result

def fetch_latlong_urllib(query):
    headers = { 'User-Agent' : user_agent }
    req = urllib2.Request(mmap_url, query, headers)
    resp = urllib2.urlopen(req)
    response = resp.read()
    return response

fetch_latlong = fetch_latlong_http

def get_location_by_cell(cid, lac, mnc=0, mcc=0, country='fr'):
    b_string = pack('>hqh2sh13sh5sh3sBiiihiiiiii',
                    21, 0,
                    len(country), country,
                    len(device), device,
                    len('1.3.1'), "1.3.1",
                    len('Web'), "Web",
                    27, 0, 0,
                    3, 0, cid, lac,
                    0, 0, 0, 0)

    bytes = fetch_latlong(b_string)
    (a, b,errorCode, latitude, longitude, c, d, e) = unpack(">hBiiiiih",bytes)
    latitude = latitude / 1000000.0
    longitude = longitude / 1000000.0

    return latitude, longitude

def get_location_by_geo(latitude, longitude):
    url = '%s?q=%s,%s&output=json&oe=utf8' % (geo_url, str(latitude), str(longitude))
    return urllib2.urlopen(url).read()

if __name__ == '__main__':
    print get_location_by_cell(20465, 495, 3, 262)
    print get_location_by_cell(20442, 6015)
    print get_location_by_cell(1085, 24040)
    print get_location_by_geo(40.714224, -73.961452)
    print get_location_by_geo(13.749113, 100.565327)
票数 8
EN

Stack Overflow用户

发布于 2010-03-20 23:57:20

你可以使用火狐使用的Google Location API (示例见http://www.mozilla.com/en-US/firefox/geolocation/ ),其url为www.google.com/loc/json/。实际上,这是基于JSON的Perl服务,最小的Perl示例如下所示:

代码语言:javascript
复制
use LWP;

my $ua = LWP::UserAgent->new;
$ua->agent("TestApp/0.1 ");
$ua->env_proxy();

my $req = HTTP::Request->new(POST => 'https://www.google.com/loc/json');

$req->content_type('application/jsonrequest');
$req->content('{"cell_towers": [{"location_area_code": "8721", "mobile_network_code": "01", "cell_id": "7703", "mobile_country_code": "262"}], "version": "1.1.0", "request_address": "true"}');

# Pass request to the user agent and get a response back
my $res = $ua->request($req);

# Check the outcome of the response
if ($res->is_success) {
    print $res->content;
} else {
    print $res->status_line, "\n";
    return undef;
}

请记住,谷歌还没有正式开放此API用于其他用途...

票数 8
EN

Stack Overflow用户

发布于 2015-09-30 22:09:19

Google location API的新位置如下:https://developers.google.com/maps/documentation/geolocation/intro

使用此API,您可以从Cell信息(cellid、mcc、mnc和lac)中检索位置

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1598696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档