Skip to content
Snippets Groups Projects
Commit f3d68eb0 authored by Joni Laukka's avatar Joni Laukka
Browse files

getCurrentPosition method added

parent 32254579
No related branches found
No related tags found
1 merge request!3Get own location
......@@ -2,6 +2,22 @@ import React, { Component } from 'react';
import { Map, TileLayer, Marker, Popup } from 'react-leaflet';
class UserMap extends Component {
getCurrentPosition(){
if(!navigator.geolocation){
console.log("Can't get geolocation :/");
return null;
}
else{
navigator.geolocation.getCurrentPosition((position)=>{
return ({
lat: position.coords.latitude,
lng: position.coords.longitude
});
});
}
}
render() {
return (
<Map className='map' center={this.props.position} zoom={this.props.zoom}>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment