My favorites | Sign in
Project Home Wiki Issues Source
Search
for
GeolocationAPI  
Provides the geolocation of a device running a Gears-enabled web browser.
Updated Aug 17, 2012 by d...@google.com

Since Google Gears has been shut down since March 2011, the time has come to also say goodbye to the Geolocation API that powered Google Gears. The Google Gears Geolocation API will stop responding to requests on November 17, 2012.

Note that the JSON protocol described here was originally published to allow developers to provide their own network location server for use through the Gears API. Since Google's network location server was only to be used through the Google Gears API, which is no longer available, no developers should be affected by this change.

Comment by redsmu...@gmail.com, Jun 30, 2008

The information seems complete except for:

What's the URL for the HTTP POST request?

Any example of how much (read: little) info I need to send if I have only cell info from one cell?

Any thoughts of using URL arguments as input and XML as output? Easier to use from other languages than Javascript.

My scenario doesn't involve Gears.

Cheers

Comment by codes...@gmail.com, Jul 2, 2008

aggree with redsmurph!

another question, the source looks like a Symbian code other than web or windows application, maybe a background introduction is better?

Regards Peng

Comment by misterst...@gmail.com, Aug 27, 2008

What is the highest accuracy attainable for: 1. Fixed broadband locations? 2. Mobile devices?

Accuracy improvement suggestion: Have you considered averaging locations of individual cell sites in data sets where they are the only cell site detected by mobile devices?

i.e. where movement is - on average unrestricted and evenly distributed - clusters of mobile devices around a single point should return locations as a cluster averaged on the true position.

Comment by FumeroLeonardo, Sep 5, 2008

Does anyboy know the url to post?

Comment by 17hado....@gmail.com, Sep 16, 2008

is this API need API Key; for, i always got 404 Error

Comment by MrPa...@gmail.com, Sep 16, 2008

The URL works for me, but any request i get this message:

Bad Request Version not supported.

Comment by MrPa...@gmail.com, Sep 16, 2008

Found: use "version":"1.0"

Are API and service subject to agreement? (as all Google services are) if Yes where ?

Comment by MrPa...@gmail.com, Sep 17, 2008

I noticed that you can add as many cell_towers you want, but longitude and latitude remains unchanged. Like only first CellID is taken in consideration.

More cellIDs input shouldn't give more precise position?

Comment by apsbi...@hotmail.com, Sep 17, 2008

Randy P. SMith 4601 S Crysler Independence, mo 64055 - 35833 358-2638

Comment by forevern...@googlemail.com, Sep 19, 2008

Is it according to GOOG's terms and conditions to use the server side facilities of Google Gears location API by "hand rolled" HTTP POST request?

Comment by forevern...@googlemail.com, Sep 19, 2008

Although this blog seems not to be moderated, here some obscurities, probably someone notes that:

1) According to the doc, the cell_id element is of string type. According to the sample it is of int. Both is accepted, so please fix the doc.

2) mcc and mnc are Int32 outside the cell_id struct (inside int16). Should be unified.

3) Shouldn't the cell_towers struct contain the carrier element too?

4) At least for german locations I tested the returned address object (if reverse geocoding is requested) does not contain street and house number information, although this information is given in "ordinary" geocding mode. Is this "by design"?

Regards

Comment by forevern...@googlemail.com, Sep 19, 2008

... the latter "although this information is given" is meant: If provided street and street number a valid geocode (which may be resolved on a map) is returned using Google Maps geocoding functions. Reverse geocoding of the same geocode using Gears location api does miss the street/street number info. Sorry for being not specific enough.

Comment by bob3...@hotmail.com, Sep 30, 2008

Sorry to echo MrPatrol? and Neil Young on this; is there a proper method to establish a contact with google for business/commercial licensing? I would like to make a proposal; however, it is important to me to make sure that it profitable enough for google so that it is worth their time. Steve Block, or anyone at google, I can be reached at nine seven two 659 1626 extension 150. Thanks and my appologies for the unstructured inquiry and contact request. Ray B

Comment by bob3...@hotmail.com, Sep 30, 2008

"the location API also has the ability to send various signals that the devices has access to (nearby cell sites, wifi nodes, etc) to a third-party location service provider, who can resolve the signals into a location estimate.

The protocol between the device and the location service provider is HTTP POST."

Who is the third party location service provider? Is this currently Google or ? How can I send money to Google for this service?

Comment by project member stevebl...@google.com, Oct 8, 2008

Thanks for the comments. A few answers ...

> 1) According to the doc, the cell_id element is of string type. According to > the sample it is of int. Both is accepted, so please fix the doc. The server will accept an integer because we use a JSON format, so JavaScript? type conversion rules apply. I've updated the sample to use a string to avoid confusion.

> 2) mcc and mnc are Int32 outside the cell_id struct (inside int16). Should be > unified. This document was used for development work. The JSON format in use by Gears makes no distinction between int16 and int32. A definitive user-facing document for the JSON format will be posted soon.

> 3) Shouldn't the cell_towers struct contain the carrier element too? No, A device can be in contact with multiple cell towers, it can only use one carrier at a given point in time.

> Who is the third party location service provider? Is this currently Google? The Geolocation API allows the user to specify the network location provider, but the default is the Google provider. See the Geolocation API documentation for details.

In general, it's best to post questions to one of the Gears mailing lists, rather than here.

Steve

Comment by godsimag...@gmail.com, Oct 13, 2008

I extracted the necessary values from my Sony Ericsson K810 which has no GPS or wifi using: String cellid=System.getProperty("com.sonyericsson.net.cellid"); String mcc = System.getProperty("com.sonyericsson.net.cmcc"); String mnc = System.getProperty("com.sonyericsson.net.cmnc"); String lac = System.getProperty("com.sonyericsson.net.lac");

I then hand rolled a python script to call the given URL with the specified json object, using these values. First of all, I got a JSON Bad Parse error because the service didn't like the lac and cellid which appeared to be in hex and I sent as strings. I tried again using the decimal conversions of these values and got a 200 OK status, but an empty Json object. I tried once more with some random cellid and lac values and in some cases retrieved the expected result with lat and lng values etc.

When I use the Google Maps j2me app, it is able to resolve my location at the same position. Does it use any different technology to resolve location? What are any possible reasons that my hand rolled request is not getting resolved? And finally, am I violating the terms of use by calling the service directly and not using the gears framework?

Thanks for your time, Harry.

Comment by forgetmi...@gmail.com, Oct 14, 2008

It seems that the Geolocation API is able to automatic retrieve cell-id information,and the Geolocation API can use the cell-id information to get user's location. All above what I say is right or not ? I am confused if the API can automatic get location ,how it determine via cell-id or GPS (If my device have all) Can I specify the Geolocation API to get location via cell-id?

Comment by mogrif...@gmail.com, Oct 20, 2008

There are some curious little parsing problems with json responses. Latitude and longitude CANNOT be integers, but can be '20.' or '20.1'. horizontal_accuracy MUST be an integer, since if a float, you get a malformed response error. I suspect there are other problems like this in how the parser handles json responses. So if pulling your hair out over malformed response errors, look at integer vs. float values.

Comment by mogrif...@gmail.com, Oct 22, 2008

Steve- given that wimax networks now exist (XOHM), can we talk about updating this API to support wimax? Not to mention that Google is an investor...

Comment by Balm...@gmail.com, Oct 23, 2008

Hi, I love it ;)

What are the terms of usage of anything on the www.google.com/loc/json portal?

Specifically, it says in the TOS that you can't use google services other than through provided APIs .. is connecting to the www.google.com/log/json with a web request and providing the JSON request above as part of the request breaking this or is it part of how it's intended to be used?

Comment by forevern...@googlemail.com, Oct 23, 2008

Steve thanks for your answers above. I didn't know about the multi-provider-single-carrier issue, but this sounds logical, if thought twice :)

Currently I'm trying to make the get_location run with just a WiFi? BSSID, but it always returns a position, based upon my IP (far, far away). I'm doing this using BSSIDs, which are resolvable using SkyHookWireless?' API. Q: Does Gears support WiFi? - only based positioning currently? GSM cell based positioning works fine.

Regards

Comment by ver...@gmail.com, Oct 24, 2008

Is there a way to connect the GeolocationAPI to '''GPS''' devices API (satellite positioning is becoming now very widespread in many mobile devices, including now some mobile phones not just GPS navigation devices, whose prices have dramatically dropped)?

Also the retreived geolocation should be able to list '''several locations''', if present in the client device, each one tagged with the source provider (generic IP geolocation, WiFi? provider, GSM carrier, GPS..), allowing users to view which one is most aaccurate and use one of them (the position.accuracy field is not always consistant)

For IP geolocation, there are several databases on the web, more or less accurate or up to date. But for many Internet providers, this just gives the location of the ISP office (as registered in the WHOIS database for the assigned IP address block), because IP addresses are assigned randomly by the ISP at each connection (only the ISP knows the exact routing to the connected client). In addition, once they are assigned, these IP blocks are not always maintained if their use by the ISP change over time (for example when an ISP deploys new BAS equipement for ADSL: the IP does not necessarily indicates the physical DSLAM, but most often only a BAS which may be located anywhere in the country, and even sometimes in another country). For ISP customers connected by modem through POT lines, this IP location may even be completely non significant. all that can be said from this IP is that it belongs to the network of some ISP.

One the opposite, some IP locations may be very accurate, such as the IP addresses provided by FON wifi hotspot (if the hotspot is fully parametered by its maintainer). Connection through cable TV or fibre providers may also provide much better positioning (but this often requires some acces to some database, not just reverse-ip DNS and WHOIS data).

Note: not all devices require authorization, the IP address notably is public.

Comment by mogrif...@gmail.com, Oct 24, 2008

Please update the response information to match what google gears currently does. 'accuracy' is a new property and it is required. horizontal_accuracy and vertical_accuracy are gone. Using them instead of accuracy causes a malformed response error. Thanks.

Comment by project member stevebl...@google.com, Dec 2, 2008

Thanks for all the comments. A few responses ...

- Answers to many of the questions about use of the API can be found in the Geolocation API documentation at http://code.google.com/apis/gears/api_geolocation.html. This Wiki page is intended to document work in progress for those developing Gears, not to serve as definitive documentation of the API.

- Regarding the JSON protocol, I've updated this document to reflect the current behaviour in Gears. Note that official documentation of the protocol will soon be added to the Geolocation API documentation.

- The Gears Terms of Service prohibits direct use of the Google location server (http://www.google.com/loc/json) via HTTP requests. This service may only be accessed through the Geolocation API.

Comment by blakiki...@gmail.com, Feb 17, 2009

Hi,

I was in Fance few weeks ago and was suprised by some of the results i got back: (data as: MCC, MNC, LAC, CELL_ID)

First result was great for data : 208 10 28602 7473 (45.823502, 6.724991)

Second result was not so great for data : 208 10 6 6961 (55.952674, -3.189814) The second result is in Scotland, Edinburgh

MCC and MNC are the same for both datas....should you do reverse geo coding to make sure the location match the MCC? (i think it will be better to return no result when the MCC doesnot match the lat, lon)

Thanks

Comment by neetha...@gmail.com, Mar 9, 2009

Hi,

Could any of you help me with sending a JSON object via a http POST request in Symbian C++ or just C++ code?

Thanks

Comment by sascha.h...@googlemail.com, Mar 11, 2009

Hi,

it would be great if You could integrate a form field in the Gears Location settings for defining a certain location manually (as a fallback position or if You want information for a different place than where You are). It would even better, if users could create several "location profiles" (for example: actual location, at home, my favorite place in Paris, ...)

Comment by titus.mo...@gmail.com, Mar 11, 2009

i was wondering if its possible to get teh SSIDS and Cell information from google gears too

Comment by ABloomfield, Mar 13, 2009

Will Google ever release a public API for use outside Gears?

Comment by sudhakri...@gmail.com, Jun 30, 2009

Plz can anyone give one sample request using IP

Comment by luna....@gmail.com, Aug 10, 2009

Hello,

I am using Gears API for CDMA device on Verizon network, but I could not get any valid return,

I am wondering if any of you had any luck? please shed some light on this.

My codes like below

int bid = CDMAInfo.getCellInfo().getBID();

scellid = Integer.toString(bid);
int nid = CDMAInfo.getCellInfo().getNID(); slac= Integer.toString(nid); int mcc= CountryFromIMSI.getCountryCodeForCurrentSubscriber(); smcc = Integer.toHexString(mcc); int sid = CDMAInfo.getCellInfo().getSID(); smnc = Integer.toString(sid);
ssignalleve = Integer.toString(RadioInfo?.getSignalLevel());

API returned the location somewhere is in LV.

Regards!

Comment by rishi.s....@gmail.com, Aug 17, 2009

Hi If I am not mistaken ,in order to use this API we need to provide the "MCC, MNC, LAC, CELL_ID" ? Is there anyway this API can be used just with cellid information ?

Even I am working with a CMDA device and can not get the correct value when I use this API. btw my LAC (nid = CDMAInfo.getCellInfo().getNID();) kept on coming out to be zero.

Comment by AllenBig...@gmail.com, Nov 2, 2009

Randy SMith 4601 S Crysler Independence, mo 64055 - 35833 358-2638

Comment by ct2...@gmail.com, Nov 19, 2009

Wow! Absolutely impressive!

This API rocks!

Comment by AllenBig...@gmail.com, Feb 5, 2010

Randy SMith 4601 S Crysler Independence, mo 64055 358-2638

Comment by AllenBig...@gmail.com, Feb 5, 2010

Randy SMith 4601 S Crysler Independence, mo 64055 358-2638

Comment by cgl...@gmail.com, Feb 17, 2010

It's great to see these capabilities being adopted in state of the art browsers like Safari, Firefox, and the Android browser. Did you know it's also possible to use geolocation across even legacy browsers on feature phones? Contact me at Useful Networks for more info. www.useful-networks.com

Comment by AllenBig...@gmail.com, Mar 10, 2010

Randy SMith 64055 S Crysler Independence, mo 64055 35833 358-2638

Comment by AllenBig...@gmail.com, Mar 10, 2010

Randy SMith 64055 S Crysler Independence, mo 64055 35833 358-2638

Comment by zg911...@gmail.com, Apr 4, 2010

now, google geoolcation api can not support Mobile.Only it support Wifi...Oh, My god... wo want app it at www.ipkaka.com sorry. i am a chineseman. Enlish is poor

Comment by andrey...@gmail.com, Apr 13, 2010

I am totally confused, is there a way to send the request directly using HTTP POST or not?

If yes, can someone please post an example? Thank you.

Comment by toga...@gmail.com, Apr 19, 2010

I want to know if it is possible to get location via HTTP POST, too.

I need to get location of external modem, then I want to send gsm cell info from modem to other pc and see the position in the pc. How can I do that???

Thanks in advance...

Comment by wendyloudubyah, Jun 23, 2010

info was too overwhelming for me.

Comment by xiang200...@126.com, Jul 19, 2010

Hi! zg911.cn! Are you sure the google geoolcation api can not support Mobile now? Indeed I also found that the google geoolcation api is unstable.But I can not confirm that the wrong if of google geoolcation api or my code! This problem has troubled me for days , I hope you can help confirm. Thank you.

Comment by Golden...@gmail.com, Jul 25, 2010

Can anyone give an example using HTTP POST with PHP? Thanks!

Comment by rajeshma...@gmail.com, Aug 6, 2010

Can anyone give an script of geoolcation for mobile? Thanks!

Comment by AllenBig...@gmail.com, Aug 8, 2010

Randy Smith 4601 S Crysler Independence, mo 64055 35833 358-2638

Comment by gadb...@gmail.com, Aug 10, 2010

I just successfully tested this on a mobile device - a Vodafone HTC V1615 running Windows Mobile 6 Professional. I used the following to test:

http://code.google.com/apis/gears/samples/hello_world_geolocation.html

Comment by SEOga...@gmail.com, Sep 29, 2010

Does this require that the mobile device or computer have gears installed on it to work?

Comment by paneva.m...@gmail.com, Dec 25, 2010

6+

Comment by iceba...@gmail.com, Mar 15, 2011

Thank you!It is so amazing which really helps my work.

Comment by trinityj...@gmail.com, Mar 16, 2011

thanks quite interesting .

Comment by escutace...@gmail.com, Apr 26, 2011

I code PHP version that works perfect with googleapi. It needs only 2 infos, cellid and location area code to work worldwide. For sale. Interested customers please contact me.

Comment by whe...@gmail.com, Sep 15, 2011

google: what's the limit reqs/sec for this?

Comment by werec...@gmail.com, Sep 28, 2011

Same problem!

It works fine before on my Blackberry, but now returns 400 error both on emulators and on real device

Comment by greensea...@gmail.com, Oct 28, 2011

I'm sorry, I meant GSM parameter (MCC, MNC, LAC, CID), not GPS. That was my mistake.

Comment by muhammad...@gmail.com, Oct 27, 2012

Can someone teach me how to download a tracker on my pc please

Comment by t...@servitecsondagem.com.br, Nov 21, 2012

hello, my project depends on the answers from google, and now how do I do?

help please Helppppppp

Comment by alberto....@gmail.com, Nov 21, 2012

the API can be accessed here: https://developers.google.com/maps/documentation/business/geolocation/ you need an api-key and the limit per day are very low...

Comment by Zhongz...@gmail.com, Nov 21, 2012

hello,I always fail to use The Google Maps Geolocation API. I follow the Geolocation requests,for example:"https://www.googleapis.com/maps/api/geolocation/v1/geolocate?key=API_key", and always get 404 for respond

Comment by Zhongz...@gmail.com, Nov 21, 2012

who can tell me why?

Comment by zwq4166...@163.com, Nov 22, 2012

I tried the same return 404

Comment by crazyja...@gmail.com, Nov 22, 2012

Oh ! God .. Can someone tell me other location api ?

Comment by a...@unn.ru, Nov 23, 2012

Hi! I need to use the Google Maps Geolocation API. https://developers.google.com/maps/documentation/business/geolocation/

I send to the server (www.googleapis.com):


POST geolocation/v1/geolocate?key=MyKey? HTTP/1.0 Content-Type: application/json Content-Length: 370

{"homeMobileCountryCode": 310,"homeMobileNetworkCode": 260,"radioType": "gsm","carrier": "T-Mobile","cellTowers": [{"cellId": 39627456,"locationAreaCode": 40495,"mobileCountryCode": 310,"mobileNetworkCode": 260,"age": 0,"signalStrength": -95}],"wifiAccessPoints": [{"macAddress": "01:23:45:67:89:AB","signalStrength": 8,"age": 0,"signalToNoiseRatio": -65,"channel": 8}]}

I receive from the server:


HTTP/1.0 503 Service Unavailable Content-Type: text/html; charset=UTF-8 Content-Length: 949 Date: Fri, 23 Nov 2012 12:59:48 GMT Server: GFE/2.0

<!DOCTYPE html> <html lang=en> .....
<p>The service you requested is not available at this time.<p>Service error -27.
.....

How use this service? I tried many different variants unsuccessfully... Thanks!

Comment by t...@servitecsondagem.com.br, Nov 29, 2012

I spoke with a representative from google to see how this works api, and surprise, this api is only used for mobile ... but now and as we do with desktop applications? ... good then I just thought Skyhook ... so far no one gave me a solution that works the same as google gears for desktop.

I await ideas ...

Comment by kassf...@gmail.com, Dec 1, 2012

Guys, the correct URL should be "https://www.googleapis.com/api/geolocation/v1/geolocate?key=API_key", I spent a whole day to figure this out...

Comment by kassf...@gmail.com, Dec 1, 2012

Anybody knowing the pricing of this API for 10000 requests/day? 100requests/day is too limited.

Comment by mrnikhil...@gmail.com, Dec 4, 2012

Any geek got any solution why http://www.google.com/loc/json stopped working

Comment by levian...@gmail.com, Dec 14, 2012
http://www.google.com/loc/json has been shut down,but what's the new one replacement ?can you give me a web site to tell me how to use the new?
Comment by yanljrab...@163.com, Dec 16, 2012

is anybody has new method about this! help!

Comment by zenghuaming@gmail.com, Jan 6, 2013
Comment by arima.nj...@gmail.com, Jun 8, 2013

Dear all,

I post cell information (CID,LAC,MCC,MNC...) to https://www.googleapis.com/geolocation/v1/geolocate?key=my_key,but it always return error 400,can you help me ? Thanks~

1)return error information as follows: {

"error": {
"errors": [
{
"domain": "global", "reason": "parseError", "message": "Parse Error"
}
], "code": 400, "message": "Parse Error"
}
} 2)I implement as follows: public class SCell{
public int MCC; public int MNC; public int LAC; public int CID;
}
private SItude getItude(SCell cell) throws Exception {
SItude itude = new SItude();
/ Using HttpClient? of android by default/ HttpClient? client = new DefaultHttpClient?(); / using post'method / HttpPost? post = new HttpPost?("https://www.googleapis.com/geolocation/v1/geolocate?key=XXXXXXXXXXXXXXXXXX"); try {
/ POST JSON data structure / JSONObject holder = new JSONObject(); holder.put("homeMobileCountryCode", cell.MCC); holder.put("homeMobileNetworkCode", cell.MNC); holder.put("radioType", "gsm"); holder.put("carrier", "cmcc");

JSONObject tower = new JSONObject(); tower.put("cellId", cell.CID); tower.put("locationAreaCode", cell.LAC); tower.put("mobileCountryCode", cell.MCC); tower.put("mobileNetworkCode", cell.MNC); tower.put("age", 0); tower.put("signalStrength", -60); tower.put("timingAdvance", 15);
JSONArray towerarray = new JSONArray(); towerarray.put(tower); holder.put("cellTowers", towerarray);
StringEntity? query = new StringEntity?(holder.toString()); post.setEntity(query);

/ send out JSON data,and return data / HttpResponse? response = client.execute(post); HttpEntity? entity = response.getEntity(); BufferedReader? buffReader = new BufferedReader?(new InputStreamReader?(entity.getContent())); StringBuffer? strBuff = new StringBuffer?(); String result = null; while ((result = buffReader.readLine()) != null) {
strBuff.append(result);
}
/ parse JSON data to get longitude and latitude / JSONObject json = new JSONObject(strBuff.toString()); JSONObject subjosn = new JSONObject(json.getString("location"));
itude.latitude = subjosn.getString("latitude"); itude.longitude = subjosn.getString("longitude");
Log.i("Itude", itude.latitude + itude.longitude);
} catch (Exception e) {
Log.e(e.getMessage(), e.toString()); throw new Exception("error info :"+e.getMessage());
} finally{
post.abort(); client = null;
}
return itude;
}

Comment by sersanmesrul, Feb 2, 2014

test cara meningkatkan penjualan online

you can delete it

Comment by woody...@gmail.com, May 6, 2014

Sign in to add a comment
Powered by Google Project Hosting