Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
react-native-michael-amap
Advanced tools
react-native 高德地图组件,使用最新 3D SDK,支持 Android + iOS,受 react-native-maps 启发,提供功能丰富且易用的接口。
相关项目推荐:
npm i react-native-michael-amap
react-native link react-native-michael-amap
你需要使用 CocoaPods,在 ios
目录下新建文件 Podfile
:
platform :ios, '9.0'
# The target name is most likely the name of your project.
target 'Your 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
# 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-michael-amap', path: '../node_modules/react-native-michael-amap/lib/ios'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "React"
target.remove_from_project
end
end
end
注意:不同的 RN 版本,Podfile
可能需要稍作调整,具体参考 https://facebook.github.io/react-native/docs/integration-with-existing-apps#configuring-cocoapods-dependencies 。
然后运行:
pod install
编辑 Android 项目的 AndroidManifest.xml
(一般在 android\app\src\main\AndroidManifest.xml
),添加如下代码:
<application>
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="你的高德 Key" />
</application>
在 AppDelegate.m
里引入 SDK 头文件 #import <AMapFoundationKit/AMapFoundationKit.h>
,
并设置高德 Key [AMapServices sharedServices].apiKey = @"你的高德 Key";
。
import { MapView } from 'react-native-michael-amap'
<MapView
coordinate={{
latitude: 39.91095,
longitude: 116.37296,
}}
/>
<MapView
locationEnabled
onLocation={({ nativeEvent }) =>
console.log(`${nativeEvent.latitude}, ${nativeEvent.longitude}`)}
/>
<MapView>
<MapView.Marker
draggable
title='这是一个可拖拽的标记'
onDragEnd={({ nativeEvent }) =>
console.log(`${nativeEvent.latitude}, ${nativeEvent.longitude}`)}
coordinate={{
latitude: 39.91095,
longitude: 116.37296,
}}
/>
</MapView>
const coordinate = {
latitude: 39.706901,
longitude: 116.397972,
}
<MapView.Marker image='flag' coordinate={coordinate}>
<View style={styles.customInfoWindow}>
<Text>自定义信息窗体</Text>
</View>
</MapView.Marker>
参考 examples,或直接下载安装 example.apk。
yarn run-android
cd ios && pod install && cd ..
yarn run-ios
请参考注释文档:
FAQs
react-native 高德地图组件,支持 Android + iOS
The npm package react-native-michael-amap receives a total of 2 weekly downloads. As such, react-native-michael-amap popularity was classified as not popular.
We found that react-native-michael-amap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.