小编Lav*_*aju的帖子

使用react-native-maps在ReactNative中获取当前位置,纬度和经度

我正在开发一个地图位置.当我在某个特定的地方点击时,我得到纬度和经度,但不是当前的位置,纬度和经度.

我不知道如何找出答案.

我怎样才能得到它们?如何将标记放在那个位置?

这是我的代码:

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)

react-native react-native-android react-native-maps

21
推荐指数
2
解决办法
5万
查看次数

如何在react-native中的开关内显示文本(是/否)

我是反应原生的新手.在我的应用程序中,我正在使用开关并更改色调颜色以区分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)

请给我建议解决这个问题,任何帮助非常感谢.

react-native

12
推荐指数
1
解决办法
9815
查看次数

如何使用Spinner在FlatList中添加更多记录反应本机(意味着-10 - 10条记录)手动!不是从使用服务器端

嗨,我正在开发基于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

12
推荐指数
1
解决办法
8873
查看次数

无法解析配置“:classpath”的所有文件

我正在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)

android react-native

11
推荐指数
1
解决办法
3万
查看次数

React-native:如何在react-native-maps中单击标记显示工具提示

我正在使用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

6
推荐指数
1
解决办法
2941
查看次数

如何显示从当前位置到某个目的地(某个地址)的路线图?

在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)

实际上,在此代码中,我看到了一些标记列表,但我不需要所有标记路线图...我只希望将某些特定标记添加到当前位置。

在这里,我附加了我想要的图像:

在此处输入图片说明

android react-native react-native-maps

6
推荐指数
1
解决办法
1725
查看次数

adb服务器版本(39)与该客户端(40)不匹配;杀死... ADB服务器未确认

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 …

android react-native-android

6
推荐指数
1
解决办法
1万
查看次数

使用react-native router-flux时,BackHandler无法在react-native side-menu中工作

我正在研究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

6
推荐指数
1
解决办法
257
查看次数

Youtube 视频无法在 android 中播放(react-native)

我正在开发一个显示 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 上它显示的是一个空的黑屏,如下所示:

在此输入图像描述

请提出一些解决方案!提前致谢。

android android-youtube-api react-native

5
推荐指数
1
解决办法
3169
查看次数

npm 错误!代码 E401,密码不正确或丢失

当我尝试使用 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 错误!此运行的完整日志可以在以下位置找到:

node.js npm reactjs

5
推荐指数
1
解决办法
8714
查看次数