<commit_before>var map;
var geocoder;

function codeLatLng(input) {
  geocoder.geocode({'latLng': input}, function(results) {
    console.log("You've marked: " + results[0].formatted_address);
  });
}

function initialize() {
  geocoder = new google.maps.Geocoder();
  var mapCanvas = document.getElementById('map-canvas');
  var mapOptions = {
    center: new google.maps.LatLng(41.889797, -87.637756),
    zoom: 18,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    tilt: 0
  }
  map = new google.maps.Map(mapCanvas,mapOptions);

  // added the below for geolocation
   if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = new google.maps.LatLng(position.coords.latitude,
                                       position.coords.longitude);

      var infowindow = new google.maps.InfoWindow({
        map: map,
        position: pos,
        content: 'Location found using HTML5.'
      });

      map.setCenter(pos);
    }, function() {
      handleNoGeolocation(true);
    });
  } else {
    // Browser doesn't support Geolocation
    handleNoGeolocation(false);
  }
  // added the above for geo-location

  $('<div/>').addClass('centerMarker').appendTo(map.getDiv());
}

function handleNoGeolocation(errorFlag) {
  if (errorFlag) {
    var content = 'Error: The Geolocation service failed.';
  } else {
    var content = 'Error: Your browser doesn\'t support geolocation.';
  }

  var options = {
    map: map,
    position: new google.maps.LatLng(41.889797, -87.637756),
    content: content
  };

  var infowindow = new google.maps.InfoWindow(options);
  map.setCenter(options.position);
}


$(document).ready(function(){
  initialize();
  $('#submit-button').submit(function(event){
    // debugger;
    // event.preventDefault();
    center = map.getCenter();
    codeLatLng(center);
  });
});<commit_msg>changed map js<commit_after>var map;
var geocoder;

function codeLatLng(input) {
  geocoder.geocode({'latLng': input}, function(results) {
    console.log("You've marked: " + results[0].formatted_address);
    var formatted = results[0].formatted_address
    var lat = results[0].geometry.location.A
    var lng = results[0].geometry.location.F
    // $.ajax({
    //   url: "/request/map",
    //   method: "post",
    //   data: {lat: null,
    //         lng: null,
    //         formatted: results[0].formatted_address}
    // });
  });
  console.log("returned result: " + results[0].formatted_address);
}

function initialize() {
  geocoder = new google.maps.Geocoder();
  var mapCanvas = document.getElementById('map-canvas');
  var mapOptions = {
    center: new google.maps.LatLng(41.889797, -87.637756),
    zoom: 18,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    tilt: 0
  }
  map = new google.maps.Map(mapCanvas,mapOptions);

  // added the below for geolocation
   if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = new google.maps.LatLng(position.coords.latitude,
                                       position.coords.longitude);

      var infowindow = new google.maps.InfoWindow({
        map: map,
        position: pos,
        content: 'Location found using HTML5.'
      });

      map.setCenter(pos);
    }, function() {
      handleNoGeolocation(true);
    });
  } else {
    // Browser doesn't support Geolocation
    handleNoGeolocation(false);
  }
  // added the above for geo-location

  $('<div/>').addClass('centerMarker').appendTo(map.getDiv());
}

function handleNoGeolocation(errorFlag) {
  if (errorFlag) {
    var content = 'Error: The Geolocation service failed.';
  } else {
    var content = 'Error: Your browser doesn\'t support geolocation.';
  }

  var options = {
    map: map,
    position: new google.maps.LatLng(41.889797, -87.637756),
    content: content
  };

  var infowindow = new google.maps.InfoWindow(options);
  map.setCenter(options.position);
}


$(document).ready(function(){
  initialize();
  $('#submit-button').submit(function(event){
    // debugger;
    event.preventDefault();
    center = map.getCenter();
    codeLatLng(center);
  });
});
{'fraction_non_alphanumeric': 0.14437726723095526, 'fraction_numerical': 0.019105199516324063, 'mean_word_length': 3.015533980582524, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7632764', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1322, 'n_words': 262}