react-native-wmm-tencentmap
TypeScript icon, indicating that this package has built-in type declarations

0.13.0 • Public • Published

react-native-wmm-tencentmap

腾讯地图选点及定位

Installation

npm install react-native-wmm-tencentmap

Usage

import * as WMMTencentMap from "react-native-wmm-tencentmap";

// ...

// 初始化之前必须先设置隐私合规同意授权WMMTencentMap.setUserAgreePrivacy(true)。app隐私协议必须包含腾讯地图相关隐私协议.未授权会返回RESULT_CODES.PRIVACY_DENY
WMMTencentMap.setUserAgreePrivacy(true)

// 初始化 传入申请好的key值(android需单独配置,参考下面android配置)
WMMTencentMap.init("your_tencentMapSdk_key")

/**
 * 地图选点
 * @param option 反显数据载体,将选点接收到的数据原封传回  {id:"111",title:"xxx",address:"xxx",selectLatLng:{latitudeStr:"30.997859",longitudeStr: "121.004361",xxx:'xxx'}....}
 */
const option = {
  title: '上海市陶行知纪念馆',
  address: '上海市宝山区武威东路76号',
  selectLatLng: {
    latitudeStr: '31.276573',
    longitudeStr: '121.409535'
  },
  xxx1:"xxx1",
  xxx2:"xxx2........",
}
WMMTencentMap.selectAddress(option)

// 定位
WMMTencentMap.location()

// 跳转到权限设置
WMMTencentMap.goToAppDetail()

// 注册监听
WMMTencentMap.addListener(WMMTencentMap.EVENTS.onLocationSuccess,(res)=>{
    if (res){
        // res.code
        // res.result
        // res.message
    }
})
WMMTencentMap.addListener(WMMTencentMap.EVENTS.onLocationFailed,(res)=>{
  if (res){
    // res.code
    // res.result
    // res.message
  }
})

/**
 * RESULT_CODES
 */
export const RESULT_CODES = {
  PERMISSIONS_DENY: 600001, // 用户拒绝授权,需要提示跳转到系统设置页
  PRIVACY_DENY: 600002, // 隐私合规未同意授权
  SELECT_ADDRESS_SUCCESS: 600003, // 地图选择成功
  SELECT_ADDRESS_USER_CANCEL: 600004, // 地图选择用户取消
  LOCATION_SUCCESS: 600005, // 定位成功
  LOCATION_FAIL: 600006, // 定位失败
};

/**
 * 支持的监听事件
 */
export const EVENTS = {
  onLocationSuccess: 'onLocationSuccess',
  onLocationFailed: 'onLocationFailed',
  onSelectAddressSuccess: 'onSelectAddressSuccess',
  onSelectAddressFailed: 'onSelectAddressFailed',
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i react-native-wmm-tencentmap

Weekly Downloads

0

Version

0.13.0

License

MIT

Unpacked Size

53.9 MB

Total Files

101

Last publish

Collaborators

  • mlgs