1.1.1 • Published 10 months ago

carefree-search-amap-react-native v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

carefree-search-amap-react-native

React Native 高德地图搜索模块,支持 Android/iOS。进行地址和经纬度互转

Install

npm install carefree-search-amap-react-native

API

initSDK

设置高德key

import CarefreeSearchAmap from 'carefree-search-amap-react-native';
import { Platform } from "react-native"

const setApiKey =async ()=>{
  try{
    const result = await CarefreeSearchAmap.initSDK(Platform.select({
      ios:'7847002b4f7fa42578df07d8cf9b0e41',
      android: '07976cdaf75c89e7a455f8dd3f3ec56e', 
    }))
    if(result){
      console.log("设置apiKey成功")
    }
  }catch(err){
    console.log(err)
  }
}

getAddress

经纬度===>地址

import CarefreeSearchAmap from 'carefree-search-amap-react-native';

const getAddress =async ()=>{
  try{
    const result = await CarefreeSearchAmap.getAddress({latitude:11.123456,longitude:3.123456})
    if(result&&result.errCode===1000){
      console.log("打印参数--->",result)
    }else{
      console.log(result.errInfo)
    }
  }catch(err){
    console.log(err)
  }
}

getLatLong

地址===>经纬度

import CarefreeSearchAmap from 'carefree-search-amap-react-native';

const getLatLong =async ()=>{
  try{
    const result = await CarefreeSearchAmap.getLatLong("北京天安门广场")
    if(result&&result.errCode===1000){
      console.log("打印参数--->",result)
    }else{
      console.log(result.errInfo)
    }
  }catch(err){
    console.log(err)
  }
}

返回参数说明

字段类型说明
errCodenumber错误码
rCode(android)numbersdk错误码
errInfostring错误信息
latitudenumber纬度
longitudenumber经度
countrystring国家名称
postcodestring国家简码
provincestring省名称、直辖市的名称
citystring城市名称
cityCodestring城市编码
districtstring区(县)名称
adCodestring区域编码
addressstring详细地址
buildingstring建筑物名称
neighborhoodstring社区名称
townshipstring乡镇名称
towncodestring乡镇街道编码
streetNumberstring门牌号码
streetstring门牌信息中的街道名称
sdkMessage(android){rCode:number,errInfo:string}rCode对应的信息

错误码(errCode)

错误码说明
-1没有搜索到相关数据
-2搜索失败
-3查询返回结果进行转换数据的报错信息
-4未设置apiKey
1000查询成功
1.1.1

10 months ago

1.1.0

12 months ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago