npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-amap-location-api

v0.0.5

Published

AMap location SDK for react native

Downloads

35

Readme

react-native-amap-location-api

Getting started

$ npm install react-native-amap-location-api --save

Mostly automatic installation

$ react-native link react-native-amap-location-api

iOS手动配置(link完毕之后)

1.手动删除react-native-amap-location-api库link到项目目录文件Libraries下到RNAmapLocation.xcodeproj

2.build setting -> search 'Header Search Path' 删除$(SRCROOT)/../node_modules/react-native-amap-location-api/ios

3.cd 项目目录

4.pod init(只能使用Pod安装)

5.拷贝如下代码

platform :ios, '9.0'

# The target name is most likely the name of your project.
target '你的项目名称' do

# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTNetwork',
'RCTWebSocket', # Needed for debugging
'RCTAnimation', # Needed for FlatList and animations running on native UI thread
# Add any other subspecs you want to use in your project
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

# Third party deps podspec link
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

pod 'react-native-amap-location-api', path: '../node_modules/react-native-amap-location-api/ios'

end

# 解决问题:[!] [Xcodeproj] Generated duplicate UUIDs
# 链接: https://github.com/CocoaPods/CocoaPods/issues/4370
install! 'cocoapods', :deterministic_uuids => false
  1. pod install

Usage

import AMapLocation from 'react-native-amap-location-api';

// TODO: What to do with the module?
AMapLocation;

example

API

init(key)

设置高德地图的key,key自行从官网注册,与app绑定

AMapLocation.init({
    ios: "your ios key",
    android: "your android key"
});

setOptions(options)

设置全局可配置参数

AMapLocation.setOptions({
    once: true,
    needAddress: true,
    interval: 2000
});
type options = {
    once?: boolean, // 是否是单次定位
    needAddress?: boolean, // 是否需要地址信息 
    interval?: number //多次定位时间间隔ms
}

startLocation(options)

开始定位,options不给时使用全局默认参数,有options参数时,会和全局配置参数合并,同名属性以本方法参数覆盖

stopLocation()

停止定位,连续定位时,需要自行调用来停止定位,单次定位会自行停止

destroyLocation()

销毁定位,可在不使用定位后调用,销毁定位的资源

addListener(listener)

增加监听器,获取定位结果信息

this.geoListener = AMapLocation.addListener(location => {
        this.locationListener(location);
    }
)
locationListener(location) {
    // todo something
}
// 注意不需要监听定位结果时移除listenner,否则定位销毁前,所有注册过的listener都会收到定位结果
this.geoListener.remove();