Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions src/Map.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React, { Component } from 'react';
import GoogleMapReact from 'google-map-react';
import GetLocation from './Geolocate.js';


const AnyReactComponent = ({ text }) => <div>{text}</div>;


class SimpleMap extends Component {

constructor(){
Expand All @@ -23,12 +20,10 @@ class SimpleMap extends Component {
location.getCurrentPosition((position) => {
lt = position.coords.latitude;
ln = position.coords.longitude;
console.log(lt);
console.log(ln);
self.setState ({
loaded: true,
latitude: 48.8566,
longitude: 2.3522,
latitude: lt,
longitude: ln,
center: {
lat: lt,
lng: ln
Expand All @@ -41,8 +36,28 @@ class SimpleMap extends Component {
});
})
}

this.findMiddleRestaurants = this.findMiddleRestaurants.bind(this);
}

findMiddleRestaurants() {
let count = 1;
let x = this.state.latitude;
let y = this.state.longitude;
for (let key in this.state.other_friends) {
let val = this.state.other_friends[key];
x += val[0];
y += val[1];
count += 1;
}
x = x / count;
y = y / count;
if (!isNaN(x) && !isNaN(y)) {
console.log(x);
console.log(y);
}
}

renderMarkers(map, maps) {
let marker = new maps.Marker({
position: this.state.center,
Expand All @@ -52,11 +67,9 @@ class SimpleMap extends Component {
});

var infowindow = new maps.InfoWindow({content: 'helloooo'});
console.log();
let count = 0;
for (let key in this.state.other_friends) {
let val = this.state.other_friends[key];
console.log(val);
marker = new maps.Marker({
position: new maps.LatLng(val[0], val[1]),
map: map,
Expand All @@ -69,7 +82,6 @@ class SimpleMap extends Component {
})(marker, count));
count += 1;
}

}

render() {
Expand All @@ -87,7 +99,7 @@ class SimpleMap extends Component {
</GoogleMapReact>:
null
}

{this.findMiddleRestaurants()}
</div>
);
}
Expand Down