我正在开发一个地图位置.当我在某个特定的地方点击时,我得到纬度和经度,但不是当前的位置,纬度和经度.
我不知道如何找出答案.
我怎样才能得到它们?如何将标记放在那个位置?
这是我的代码:
class Maps extends React.Component {
constructor(props) {
super(props);
this.state = {
region: {
latitude: LATITUDE,
longitude: LONGITUDE,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA,
},
marker: {
latlng:{
latitude: null,
longitude: null,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
}
}
}
}
componentDidMount() {
navigator.geolocation.getCurrentPosition (
(position) => { alert("value:" + position) },
(error) => { console.log(error) },
{
enableHighAccuracy: true,
timeout: 20000,
maximumAge: 10000
}
)
}
onMapPress(e) {
alert("coordinates:" + JSON.stringify(e.nativeEvent.coordinate))
this.setState({
marker: [{ coordinate: e.nativeEvent.coordinate }]
})
} …Run Code Online (Sandbox Code Playgroud) 我是反应原生的新手.在我的应用程序中,我正在使用开关并更改色调颜色以区分ON和OFF,但我的实际要求是在开关内显示"YES"或"NO"文本,如下所示.
这是我的代码:
<Switch
onValueChange={this.change.bind(this)}
style={{marginBottom:10,width:90,marginRight:6,marginLeft:6}}
value={true}
thumbTintColor="#0000ff"
tintColor="#ff0000"
/>
Run Code Online (Sandbox Code Playgroud)
请给我建议解决这个问题,任何帮助非常感谢.
嗨,我正在开发基于FlatList的示例应用程序,这是我的代码.实际上我显示了整个记录,比如我有50条记录到我的账户.但现在我显示了整整50条记录.Bur我需要在添加10条记录后显示10.但我不知道添加到FlatList.
这是我的代码:
<FlatList
data={this.state.profiles}
renderItem={({ item, index }) => this.renderCard(item, index)}
keyExtractor={item => item.id}
ItemSeparatorComponent={() => <Divider style={{ marginTop: 5, marginLeft: width * 0.2 + 20 }} parentStyle={{ backgroundColor: globalStyles.BG_COLOR, alignItems: 'baseline' }} />}
/>
renderCard (profile, index) {
console.log('rendercard', profile);
//
return (
<View key={profile.id}>
<ProfileCard
profile={profile}
style={styles.card}
onPress={() => this.props.screenProps.rootNavigation.navigate('Profile', { profile: this.state.profile, id: profile.id })}
// onPress={() => alert('PROFILE')}
onAddClick={() => this.setState({ connectionPageVisible: true, cardProfile: profile })}
connectedIds={(this.props.screenProps && this.props.screenProps.connectedIds) || this.props.connectedIds}
/>
</View>
);
}
Run Code Online (Sandbox Code Playgroud)
请告诉我使用活动指标加载更多记录.提前致谢
react-native react-native-android react-native-ios react-native-flatlist
我正在react-native中开发示例应用程序,当我运行android模拟器时我遇到了这个问题,我的sdk工具版本是25,但我不知道它是如何出现这个问题的,请让我提出建议。
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.1.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.1.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom'.
> org.apache.http.ssl.SSLInitializationException: \Library\Java\Home\jre\lib\security\cacerts (The system cannot find the path specified)
> Could not resolve com.android.tools.build:gradle:3.1.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom'.
> org.apache.http.ssl.SSLInitializationException: \Library\Java\Home\jre\lib\security\cacerts (The system cannot find the path specified)
> Could not resolve com.google.gms:google-services:3.2.0.
Required by:
project :
> Could not resolve com.google.gms:google-services:3.2.0.
> Could not get resource …Run Code Online (Sandbox Code Playgroud) 我正在使用react-native-maps模块.我给出了lat和long值,我使用MapView.Marker在单击标记时显示标记和工具提示.
但是,现在我想显示工具提示,而不是在最初加载地图时点击标记.
这是我的代码:
<View style={styles.page}>
<MapView
ref="map"
style={styles.map}
region={this.state.region}
provider = {PROVIDER_DEFAULT}
zoomEnabled={true}
onRegionChange={this.onRegionChange.bind(this)}
pitchEnabled={true}
showsCompass={true}
liteMode={false}
showsBuildings={true}
showsTraffic={true}
showsIndoors={true}
>
<MapView.Marker
coordinate={this.state.marker.latlng}
title={this.state.marker.title}
description={this.state.marker.description}
image={require('./assets/pin.png')}
/>
</MapView>
</View>
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助解决这个问题......
在React Native中,我正在使用react-native-maps开发一个示例应用程序。它工作正常,但我没有发现:如何显示从当前位置到另一个地址或位置的RouteMap?
这是我的代码:
<MapView
ref='map'
style={styles.map}
region={this.state.mapRegion}
showsUserLocation={true}
followUserLocation={true}
zoomEnabled={true}
pitchEnabled={true}
showsCompass={true}
showsBuildings={true}
showsTraffic={true}
showsIndoors={true}
onRegionChange={this.onRegionChange.bind(this)}
onPress={this.onMapPress.bind(this)}
>
{this.state.markers.map(marker => (
<MapView.Marker
coordinate={{
latitude: marker.Latitude || this.state.lastLat || region.latitude,
longitude: marker.Longitude || this.state.lastLong || region.longitude
}}
image = {
marker.EmergencyService == true ?(
require('./Imgs/emergencyService.png')):
(require('./Imgs/regularService.png'))
}
onCalloutPress={() => this.bookDoctorsAppointment(marker)}
>
<MyCustomMarkerView marker={marker} navigator={this.props.navigator}/>
</MapView.Marker>
))}
</MapView>
Run Code Online (Sandbox Code Playgroud)
实际上,在此代码中,我看到了一些标记列表,但我不需要所有标记路线图...我只希望将某些特定标记添加到当前位置。
在这里,我附加了我想要的图像:
I am developing sample application and installation procedure followed
as followed react-native document and installed this application but
ios wokring fine and coming to android getting this issue.
Run Code Online (Sandbox Code Playgroud)
adb服务器版本(39)与该客户端(40)不匹配;正在杀死... ADB服务器未确认完整的服务器启动日志:/var/folders/df/3drfx_117t1g7d97fxd86j_w0000gn/T//adb.501.log服务器具有pid:14441 --- adb启动(pid 14441)--- adb I 10-30 20:55:55 14441 194054 main.cpp:56] Android Debug Bridge版本1.0.40 adb I 10-30 20:55:55 14441 194054 main.cpp:56]版本4986621 adb I 10-30 20 :55:55 14441 194054 main.cpp:56]安装为/ usr / local / bin / adb adb I 10-30 20:55:55 14441 194054 main.cpp:56] --- adb启动(pid 14443)- -adb I 10-30 20:55:55 14443 …
我正在研究react-native来开发一个示例应用程序.在我使用backHandlerreact-native side-menu组件时,我遇到了一个问题.
实际上,侧边菜单包含更多页面!但是当单击侧面菜单页面中的Android后退按钮时,只有后退处理程序工作.在这里,我使用react-native router-flux.
这里的后退按钮动作只调用一次!
这是我的代码:
componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
}
handleBackPress = () => {
let {isGoback} = this.props.isGoback
//alert("Hi " + isGoback)
if(isGoback === "Contact Us"){
//alert("Hi: " + isGoback)
Actions.BasicSideMenuMain({selectedItem:'Home'});
//Actions.replace('BasicSideMenuMain')
}
}
Run Code Online (Sandbox Code Playgroud) react-native react-native-android react-native-router-flux react-native-navigation
我正在开发一个显示 Youtube 视频的示例应用程序。它在 iOS 上运行完美,但在 Android 上,它不显示播放按钮,而是显示带有旋转图标的黑屏。
我正在使用react-native-youtubeGitHub 项目添加 YouTube 组件。
<YouTube
apiKey={'xxxxxxxxxxxx'}
videoId={xxxxxxxxx}
play={true}
fullscreen={false}
loop={false}
onReady={e => this.setState({ isReady: true })}
onChangeState={e => this.setState({ status: e.state })}
onChangeQuality={e => this.setState({ quality: e.quality })}
onError={e => this.setState({ error: e.error })}
style={[styles.articleImage, allTabFilterSelected ? {}
styles.articleImageFilterTab]}
/>
Run Code Online (Sandbox Code Playgroud)
在 iOS 上,我的应用程序运行良好,播放按钮有效。但在 Android 上它显示的是一个空的黑屏,如下所示:
请提出一些解决方案!提前致谢。
当我尝试使用 npm install 安装节点模块时遇到问题。我删除了 package.lock.json 文件,但仍然面临问题
npm 错误!代码E401
npm 错误!密码不正确或丢失。
npm 错误!如果您尝试登录,请更改密码,创建 npm ERR!身份验证令牌或启用双因素身份验证,然后 npm ERR!这意味着您输入的密码可能不正确。
npm 错误!请重试,或通过以下地址恢复您的密码:
npm 错误! https://www.npmjs.com/forgot npm 错误!npm 错误!如果您正在执行其他操作,那么您保存的凭据是 npm ERR!可能已经过时了。要更正此问题,请尝试使用以下命令重新登录:npm ERR!登录
npm 错误!此运行的完整日志可以在以下位置找到: