json基站定位接口 免费使用

数据提供网站: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.
{
  "homeMobileCountryCode": 310,
  "homeMobileNetworkCode": 410,
  "radioType": "gsm",
  "carrier": "Vodafone",
  "cellTowers": [
    // See the Cell Tower Objects section below.
  ],
  "wifiAccessPoints": [
    // See the WiFi Access Point Objects section below.
  ]
}

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.

{
  "cellId": 42,
  "locationAreaCode": 415,
  "mobileCountryCode": 310,
  "mobileNetworkCode": 410,
  "age": 0,
  "signalStrength": -60,
  "timingAdvance": 5555
}
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
欢迎大家加人lbs技术讨论组:QQ群   号: 275114383

你可能感兴趣的:(基站)