I'm trying to make a crawler using arduino, a gps module and a gsm.
I can receive the latitude, longitude and send to the cell phone as SMS, but in the mobile I am trying to build an application with react-native
, in which I am learning, that shows the location.
Running tests, I got this code to monitor incoming messages:
import React, { Component } from 'react';
import {
AppRegistry,
Text,
View,
Button
} from 'react-native';
import SmsListener from 'react-native-android-sms-listener';
export default class App extends Component {
//constructor include last message
constructor(props) {
super(props);
this.state = { lastMessage: 1 };
}
sms(){
SmsListener.addListener(message => {
this.setState({ lastMessage: message.body });
});
}
render() {
return (
<View>
<Text> Scheduled jobs: {this.state.lastMessage} </Text>
<Button
title="Buscar"
color="#115E54"
onPress={() => this.sms() }
/>
</View>
);
}
}
And this code to display the map:
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
import MapView from 'react-native-maps';
export default class App extends Component {
render() {
const { region } = this.props;
console.log(region);
return (
<View style ={styles.container}>
<MapView
style={styles.map}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.015,
longitudeDelta: 0.0121,
}}
>
</MapView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
height: 400,
width: 400,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
...StyleSheet.absoluteFillObject,
},
});
Both work within their functions.
The problem is that I get the data in SMS in 37.78825,-122.4324
format and I need to break this data in two to be able to assign in latitude
and longitude
How do I do this?