Skip to content

txbb/txbb-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Txbb.Map

同学帮帮地图组件

Demo

选择:http://txbb.github.io/txbb-map/test/selectLocation.html

只读:http://txbb.github.io/txbb-map/test/?lat=32.060125&lng=118.792073&address=江苏省南京市雨花台区软件大道丰盛商汇6栋314室南京云智信息科技有限公司

依赖的服务

高德地图

依赖的编程类库

没有

包含功能

  1. 通过URL打开地址栏,显示位置
  2. 选择一个位置然后获取位置信息
  3. 获得用户当前的位置信息

调用

Global模式

// do something with Txbb.Map
Txbb.Map.selectLocation({});

RequreJS模式

requirejs.config({
    paths: {
        'Txbb/Map': '../txbb-map'
    }
});
require(['Txbb/Map'], function(TxbbMap) {
    // do somethin with TxbbMap
    TxbbMap.selectLocation({});
});

API

1. 通过URL地址栏访问之后显示地理位置

浏览器直接访问 /?lng=113.345678&lat=38.98765&name=测试位置

2. 在地图上选择地理位置获得选取的位置数据

Txbb.Map.selectLocation(options);

options

  • confirm: 获取数据的回调函数,接收一个object类型参数,包含位置信息
  • location: 默认显示的位置信息,可以包含经纬度数据(location.lng, location.lat),地点名称(location.address)
  • readonly: 代表地图是不是只读的

3. 获得当前的位置信息

Txbb.Map.getLocationInfo(options);

options

  • success: 成功的回调函数,接收一个object类型参数poi,包含位置信息
  • error: 失败的回调函数,接收一个string类型参数msg,代表错误信息

Todo

配置地图服务的 KEY

Todo,按需加载服务

Txbb.Map.config('AMapKey', '1234567890');