• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

twang2218/mobile-locator: Get Geolocation information based on Cell base station ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

twang2218/mobile-locator

开源软件地址(OpenSource Url):

https://github.com/twang2218/mobile-locator

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

Mobile Locator

NPM version MIT License Build Status Dependency Status Coverage Status NPM

Get geolocation from cell tower information.

Currently, the following APIs are implemented:

Library

api(name, options)

Create the location engine by given name and options.

Name Options
cellocation system(optional): Coordinate system: wgs84(Default), gcj02, bd09.
google key: Google API key
gpsspg key: GPSspg API key,
oid: GPSspg OID,
system(optional): Coordinate system: 0:wgs84_(Default)_; 1:gcj02; 2:bd09; 3:QQ Maps; 4:MapBar
haoservice key: HaoService API key,
system(optional): Coordinate system: 0: gcj02; 1:bd09; 2:wgs84_(Default)_
mozilla key: Mozilla API key
mylnikov data(optional): open: Use open source data.
opencellid key: OpenCellID API key
unwiredlabs token: UnwiredLabs Location API token
yandex key: Yandex API key

Besides the above engine-specific options, more general options are also available:

  • verbose: Print more debug information if verbose is true;
  • timeout: Set the timeout value in milliseconds. There is no timeout by default.

The returned value is a locate() function, which will be described in the next section.

locate(info)

info should contain cell information, including mnc, mcc, lac and cid.

The function will return a promise, which will return the location from given geolocation service.

location is an object contains following properties:

Property Description
longitude Longitude
latitude Latitude
accuracy The accuracy range of the given position
address(optional) For some API, this property contains the human readable address line.

Example

const api = require('mobile-locator');

const locate = api('google', { key: YOUR_GOOGLE_API_KEY });

locate({ mcc: 460, mnc: 0, lac: 4219, cid: 20925 })
  .then(location => console.log(JSON.stringify(location, null, 2)));

The output would be:

{
  longitude: 116.46679499999998,
  latitude: 39.9910226,
  accuracy: 606
}

Command-line Interface

Usage

$ mobile-locator -h

Usage: mobile-locator [options]

Locate geolocation information based on Cell base station data

Options:

  -h, --help                   output usage information
  -V, --version                output the version number
  -c, --cell <cell>            Cell tower base station information in format "MCC,MNC,LAC,CID". "-c 460,0,4219,20925"
  -e, --engine <engine>        Geolocation service engine. {cellocation, google, gpsspg, haoservice, mozilla, mylnikov, opencellid, unwiredlabs, yandex}. Default: google
  -a, --arguments <arguments>  Arguments for geolocation engine. e.g. "key:XXX,oid:123".
  -m, --map <map>              Map service. {google, bing, openstreetmap, google.cn, bing.cn, baidu}.
  -v, --verbose                Verbose output.

Examples:

  $ mobile-locator -a "key:XXX" -c 460,0,4219,20925
  $ mobile-locator -e cellocation -a "system:bd09" -m baidu -c 460,0,4219,20925

By default, the Google Geolocation engine will be used.

$ mobile-locator -a "key:GOOGLE_API_KEY" -c 460,0,4219,20925
{"longitude":116.46679499999998,"latitude":39.9910226,"accuracy":606}

With verbose option:

$ mobile-locator -a "key:AIzaSyAL2sfTLqUv9Rb3ercbtuu__PG2pS_4eDo" -c 460,0,4219,20925 -v
Geolocation engine: "google"
Cell: {"mcc":"460","mnc":"0","lac":"4219","cid":"20925"}
Location: {"longitude":116.46679499999998,"latitude":39.9910226,"accuracy":606}

More complex example:

  • Use cellocation engine;
  • Choose bd09 coordinate system;
  • Show Baidu map url for given coordinate;
  • Verbose output.
$ mobile-locator -e cellocation -a 'system:bd09' -m baidu -v -c 460,0,4219,20925
Geolocation engine: "cellocation"
Cell: {"mcc":"460","mnc":"0","lac":"4219","cid":"20925"}
Location: {"longitude":"116.479653","latitude":"39.997967","accuracy":"100","address":"北京市朝阳区望京街道望京园402号楼;广顺南大街与阜安西路路口东北109米"}
Map url: http://api.map.baidu.com/marker?location=39.997967,116.479653&title=_&content=北京市朝阳区望京街道望京园402号楼;广顺南大街与阜安西路路口东北109米&output=html&autoOpen=true



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
winktoolkit/wink: mobile javascript framework发布时间:2022-08-30
下一篇:
Thinkful-Ed/starter-mobile-first-development发布时间:2022-08-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap