
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
react-native-sxc-mapkit
Advanced tools
react-native mapkit geolocation background-location mapview baidumap
cnpm install react-native-sxc-mapkit --save
settings.gradle include ':react-native-sxc-mapkit' project(':react-native-sxc-mapkit').projectDir = new File(settingsDir, '../node_modules/react-native-sxc-mapkit/android')
build.gradle compile project(':react-native-sxc-mapkit')
MainApplicationnew MapKitPackage(getApplicationContext())
配置百度地图key AndroidMainifest.xml <meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="xx"/>
配置高德key AndroidMainifest.xml <meta-data android:name="com.amap.api.v2.apikey" android:value="your key" />
Project navigator->Libraries->Add Files to 选择 react-native-sxc-mapkit/ios/RCTMapKit.xcodeproj
Project navigator->Build Phases->Link Binary With Libraries 加入 libRCTMapKit.a
Project navigator->Build Settings->Search Paths, Framework search paths 添加 react-native-sxc-mapkit/ios/lib,Header search paths 添加 react-native-sxc-mapkit/ios/RCTMapKit
添加依赖, react-native-sxc-mapkit/ios/lib 下的全部 framwordk, CoreLocation.framework和QuartzCore.framework、OpenGLES.framework、SystemConfiguration.framework、CoreGraphics.framework、Security.framework、libsqlite3.0.tbd(xcode7以前为 libsqlite3.0.dylib)、CoreTelephony.framework 、libstdc++.6.0.9.tbd(xcode7以前为libstdc++.6.0.9.dylib)、CoreTelephony.framework
添加 BaiduMapAPI_Map.framework/Resources/mapapi.bundle
添加 UIBackgroundModes location 到 Info.plist
添加 NSLocationAlwaysUsageDescription 到Info.plist 并增加相应描述
其它一些注意事项可参考百度地图LBS文档
#import "RCTBaiduMapViewManager.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[RCTBaiduMapViewManager initSDK:@"api key"];
...
}
import { MapView, MapTypes, MapModule, Geolocation } from 'react-native-sxc-mapkit
Name | Type | Default | Extra |
---|---|---|---|
zoomControlsVisible | bool | true | Android only |
trafficEnabled | bool | false | |
baiduHeatMapEnabled | bool | false | |
mapType | number | 1 | |
zoom | number | 10 | |
center | object | null | {latitude: 0, longitude: 0} |
marker | object | null | {latitude: 0, longitude: 0, title: ''} |
markers | array | [] | [marker, maker] |
onMapStatusChangeStart | func | undefined | Android only |
onMapStatusChange | func | undefined | |
onMapStatusChangeFinish | func | undefined | Android only |
onMapLoaded | func | undefined | |
onMapClick | func | undefined | |
onMapDoubleClick | func | undefined | |
gesturesEnabled | bool | true | |
showMapScaleBar | bool | true | |
rotateEnabled | bool | true | |
zoomEnabledWithTap | bool | true | |
scrollEnabled | bool | true | |
zoomEnabled | bool | true | |
overlookEnabled | bool | true |
Method | Result |
---|---|
Promise reverseGeoCode(double lat, double lng) | {"address": "", "province": "", "city": "", "district": "", "streetName": "", "streetNumber": "", "nearbyPOI": []} |
Promise reverseGeoCodeGPS(double lat, double lng) | {"address": "", "province": "", "city": "", "district": "", "streetName": "", "streetNumber": ""} |
Promise geocode(String city, String addr) | {"latitude": 0.0, "longitude": 0.0} |
Promise getCurrentPosition() | IOS: {"latitude": 0.0, "longitude": 0.0} Android: {"latitude": 0.0, "longitude": 0.0, "direction": -1, "altitude": 0.0, "radius": 0.0, "address": "", "countryCode": "", "country": "", "province": "", "cityCode": "", "city": "", "district": "", "street": "", "streetNumber": "", "buildingId": "", "buildingName": ""} |
Promise geoCodeCityKeyWord(string keyword, int pageNum, int pageCapacity) | {"result": [{"address": "", "name": "", "street": "", "streetNumber": "", "latitude": "", "longitude": "", ···}]} |
后台定位服务
较多 待补充
import { BackgroundGeolocation } from '@sxc-test/react-native-sxc-background-geolocation'
const config = {
desiredAccuracy: 10,
stationaryRadius: 30,
distanceFilter: 30,
// Activity Recognition
stopTimeout: 1,
locationTimeout: 30,
// Application config
// life-cycle.
locationProvider: BackgroundGeolocation.provider.ANDROID_DISTANCE_FILTER_PROVIDER,
stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
startOnBoot: true, // <-- Auto start tracking when device is powered-up.
// HTTP / SQLite config
batchSync: false, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
autoSyncThreshold: 1,
maxDaysToPersist: 1, // <-- Maximum days to persist a location in plugin's SQLite database when HTTP fails
preventSuspend: true,
interval: 5 * 60 * 1000, // provider == TIMER_PROVIDE, timer or default
startForeground: true,
locationClient: BackgroundGeolocation.client.ANDROID_BAIDU_LOCATION, // 使用百度还是高德进行定位
url: 'http://aaa.jkjs.org/location',
debug: false,
locationAuthorizationAlert: {
titleWhenNotEnabled: '定位服务关闭',
titleWhenOff: '定位服务关闭',
instructions: '检测到您已经关闭定位服务,为了能更好地为您服务请点击确定,在"位置"选项中选择"始终"',
cancelButton: '取消',
settingsButton: '设置'
},
params: {
apiName: 'com.sxc.wp.user.addUserPosition',
apiVersion: '1.0',
bizName: 'wcGetUserInfoQueryDO',
host: 'http://sssss.org',
resourceType: Platform.OS === 'ios' ? '1' : '0',
...DeviceInfo.getBaseInfo(),
version: DeviceInfo.deviceInfo.version + ''
},
method: 'post'
}
BackgroundGeolocation.configure(config)
// 先停止先前的服务
BackgroundGeolocation.stop(() => {
console.log('====================================')
console.log('bg location stop')
console.log('====================================')
})
BackgroundGeolocation.start(() => {
console.log('====================================')
console.log('bg location start')
console.log('====================================')
})
FAQs
react-native mapkit geolocation background-location mapview baidumap
The npm package react-native-sxc-mapkit receives a total of 1 weekly downloads. As such, react-native-sxc-mapkit popularity was classified as not popular.
We found that react-native-sxc-mapkit 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.