Open Dsantacruz opened 6 years ago
You can simply use navigator object to do this, no need to use react-google-maps. Here is the code: navigator.geolocation.getCurrentPosition(callBackMethodName);
function callBackMethodName(location) console.log(location)
dig deeper: https://www.w3schools.com/html/html5_geolocation.asp
@shethmanan Hi mate, I have tried to get current location that use
if (navigator && navigator.geolocation) { navigator.geolocation.getCurrentPosition(pos => { console.log(443322, pos) const coords = pos.coords; this.setState({ currentLocation: { lat: coords.latitude, lng: coords.longitude } }); }); }
but it cannot get current location. I'm using macos with chrome
Getting Help
Before doing this, did you:
You can get someone's help in three ways:
Please, be noted, no one, I mean, no one, is obligated to help you in ANY means. Your time is valuable, so does our contributors. Don't waste our time posting questions like “how do I do X with React-Google-Maps” and “my code doesn't work”. This is not the primary purpose of the issue tracker. Don't abuse.