Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發實例 >> 免費的json基站定位接口

免費的json基站定位接口

編輯:Android開發實例

數據提供網站:http://www.minigps.net

接口使用和google以前的loc json一樣:

 

Request body

 

The request body must be formatted as JSON. The following fields are supported, and all fields are optional:

  • homeMobileCountryCode: The mobile country code (MCC) for the device's home network.
  • homeMobileNetworkCode: The mobile network code (MNC) for the device's home network.
  • radioType: The mobile radio type. Supported values are gsmcdma, and wcdma.
  • carrier: The carrier name.
  • cellTowers: An array of cell tower objects. See the Cell Tower Objects section below.
  • wifi_access_points: An array of WiFi access point objects. See the WiFi Access Point Objects section below.
  1. {  
  2.   "homeMobileCountryCode": 310,  
  3.   "homeMobileNetworkCode": 410,  
  4.   "radioType": "gsm",  
  5.   "carrier": "Vodafone",  
  6.   "cellTowers": [  
  7.     // See the Cell Tower Objects section below.  
  8.   ],  
  9.   "wifiAccessPoints": [  
  10.     // See the WiFi Access Point Objects section below.  
  11.   ]  

Cell tower objects

The request body's cellTowers array contains zero or more cell tower objects. All fields are optional.

  • cellId: Unique identifier of the cell. On GSM, this is the Cell ID (CID); CDMA networks use the Base Station ID (BID).
  • locationAreaCode: The Location Area Code (LAC) for GSM networks; CDMA networks use Network ID (NID).
  • mobileCountryCode: The cell tower's Mobile Country Code (MCC).
  • mobileNetworkCode: The cell tower's Mobile Network Code. This is the MNC for GSM, or the System ID (SID) for CDMA.
  • age: The number of milliseconds since this cell was primary. If age is 0, the cellId represents a current measurement.
  • signalStrength: Radio signal strength measured in dBm.
  • timingAdvance: The timing advance value.

An example cell tower object is below.

  1. {  
  2.   "cellId": 42,  
  3.   "locationAreaCode": 415,  
  4.   "mobileCountryCode": 310,  
  5.   "mobileNetworkCode": 410,  
  6.   "age": 0,  
  7.   "signalStrength": -60,  
  8.   "timingAdvance": 5555  

js示例代碼:請參考 http://www.minigps.net/map.html的源代碼

 

js示例代碼:請參考 http://www.minigps.net/map.html的源代碼
var mcc = $("#mcc").val().replace(/^\s\s*/, '' ).replace(/\s\s*$/, '' ); var mnc = $("#mnc").val().replace(/^\s\s*/, '' ).replace(/\s\s*$/, '' ); var lac = $("#lac").val().replace(/^\s\s*/, '' ).replace(/\s\s*$/, '' ); var cellid = $("#cellid").val().replace(/^\s\s*/, '' ).replace(/\s\s*$/, '' );     var celltower1 = { cell_id: cellid, location_area_code: lac, mobile_country_code: mcc, mobile_network_code: mnc, age: 0, signal_strength: -65 };     var celltowers =new Array(celltower1);   var thing = { version : "1.1.0", host : "maps.google.com", cell_towers: celltowers }; var encoded = $.toJSON(thing); // '{"plugin":"jquery-json","version":2.3}'     if (mcc != 460) { showMap = 2; map = mapFactory(); } else { showMap = 1; map = mapFactory(); }   $.ajax({ url : "/minigps/map/google/location", type : "POST", contentType: "application/json; charset=utf-8", dataType : 'json', data: encoded, success : function(response) { //if ( typeof response !== "string" || !response ) { // return null; // } // Make sure leading/trailing whitespace is removed (IE can't handle it) //response = eval('(' + data + ')');   //var decodedObject = eval('(' + response.responseText + ')'); //data = '{"location" :{"latitude" : 51.0,"longitude" : -0.1,"altitude" : 30.1,"accuracy" : 1200.4,"altitude_accuracy" : 10.6, "address" : { "street_number" : "100", "street" : "Amphibian Walkway","postal_code" : "94043","city" : "Mountain View","county" : "Mountain View County", "region" : "California","country" : "United States of America", "country_code" : "US", },}, "access_token" : "2:k7j3G6LaL6u_lafw:4iXOeOpTh1glSXe" }'; //var decodedObject = $.parseJSON(json); //alert(response.access_token); var location = response.location; var lat = location.latitude; var lon = location.longitude; var address = location.address.street_number + " " + location.address.street + " " +location.address.city + " " + location.address.county + " " + location.address.country;   mapPaneTo(map, lon, lat, address); }, error : function(er) { alert('基站信息不存在,請從手機上讀取正確的基站信息。'); } }); 
http接口示例源代碼:
request URL:http://www.minigps.net/minigps/map/google/location
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:zh-CN,zh;q=0.8
Connection:keep-alive
Content-Length:191
Content-Type:application/json; charset=UTF-8
Cookie:bdshare_firstime=1356366713546; JSESSIONID=68243935CD3355089CF07A3A22AAB372
Host:www.minigps.net
Origin:http://www.minigps.net
Referer:http://www.minigps.net/map.html
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
X-Requested-With:XMLHttpRequest
Request Payload
{"version":"1.1.0","host":"maps.google.com","cell_towers":[{"cell_id":"3721","location_area_code":"9779","mobile_country_code":"460","mobile_network_code":"0","age":0,"signal_strength":-65}]}
Response Headersview source
Content-Type:application/json
Date:Sat, 12 Jan 2013 06:03:15 GMT
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked

 

轉自:http://blog.csdn.net/echo3/article/details/8544087

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved