AmandaMitchell707 / ScoutMySkate

Full-stack project - Map My Run clone
1 stars 0 forks source link

README

Setup

Dependencies

Functionality

setUsersPosition(map) {
  let pos;
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(position => {
      pos = {
        lat: position.coords.latitude,
        lng: position.coords.longitude,
      };
      map.setCenter(pos);
    });
  }
}

initMap() {
  let map = new google.maps.Map(this.refs.map, mapOptions);
  this.setUsersPosition(map);
  this.directionsDisplay.setMap(map);
  this.map = map;

  this.map.addListener('click', event => {
    this.addMarker({ lat: event.latLng.lat(), lng: event.latLng.lng() });
    this.calcAndDisplayRoute(this.directionsService, this.directionsDisplay);
  });
  this.addLocationAutocomplete();
}

Map Demo