REACT get latitude and longitude react/javascript - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution

How to get latitude and longitude using react/javascript ?


 603

REACT


5

<!DOCTYPE html>
<html>
<head>
<script src="https://fb.me/react-0.14.3.min.js"></script>
<script src="https://fb.me/react-dom-0.14.3.min.js"></script>
</head>
<body>

<script type="text/javascript">

function YourPosition(myposition)

{
var lat1 = myposition.coords.latitude;
var lng1 = myposition.coords.longitude;

alert ("latitude " + lat1 + ",longitude " + lng1);

}

var Hello = React.createClass({
myClick: function () {
if(navigator.geolocation)
navigator.geolocation.getCurrentPosition(YourPosition);
else
alert("something was wrong");
},
render: function () {
return React.createElement("button",{onClick: this.myClick}, "click");
}
});

ReactDOM.render(React.createElement(Hello), document.getElementsByTagName('body')[0]);

</script>

</script>

</body>
</html>


By     Created   
The power of the user (%)
66%

REACT


1

// this works nice using jquery ajax
<!DOCTYPE html>
<html>
<head>
</head>
<body>

<div id="country-div"></div>

<script src="https://fb.me/react-0.14.3.min.js "></script>
<script src="https://fb.me/react-dom-0.14.3.min.js "></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/babel">

var MyCountry = React.createClass({
render: function() {
return (
<p>{this.props.a}</p>
);
}
});


// using jquery ajax
$.get("https://geoip-db.com/json/geoip.php?jsonp=?", function(response) {
var a;
var b = "lat: " + response.latitude + " long: " + response.longitude;

ReactDOM.render(
<MyCountry a={b}/>,
document.getElementById('country-div')
);

}, "json");

</script>

</body>
</html>


By     Created   
The power of the user (%)
4%



The most helpful REACT solutions

How to get client ip address using react ?How to get client ip address using react ?REACT

Click to see more ...

  4.4K     419

how to get the type of a device using react ?how to get the type of a device using react ?REACT

Click to see more ...

  1.4K     203

country dropdown using reactcountry dropdown using reactREACT

Click to see more ...

  813     127

How to get latitude and longitude using react/javascript ?How to get latitude and longitude using react/javascript ?REACT

Click to see more ...

  603     104

get ip address reactget ip address reactREACT

Click to see more ...

  364     80

time ago reacttime ago reactREACT

Click to see more ...

  281     73

detect mobile device reactdetect mobile device reactREACT

Click to see more ...

  251     58

get client country reactget client country reactREACT

Click to see more ...

  247     53

how to detect a mobile device not tablet using react ?how to detect a mobile device not tablet using react ?REACT

Click to see more ...

  227     51

detect browser reactdetect browser reactREACT

Click to see more ...

  257     36