TRAVEL SEARCH SKYSCANNER

Location-based Price Calculator and Order Instructions

by George Obregon

HTML

<meta charset="utf-8">

<body onload="geoFindMe()">

  <body onload="geocodeLatLng()">

    <!-- Demo is where sheets db is called. -->
      <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://www.gstatic.com/firebasejs/4.13.0/firebase.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/css/bootstrap-select.min.css">

        <!-- Latest compiled and minified JavaScript -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/js/bootstrap-select.min.js"></script>

        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
      </head>
   <body>

    <div id="floating-panel">
      <input id="latlng" type="text" value="Coordinates">
      <input id="submit" type="button" value="Reverse Geocode">
      <div id="test"></div>
    </div>
    <div id="title"></div>
    <div id="map"></div>

      <!-- <span class='r3'><h3>CALCULADOR DE ENVIOS<h3></span> -->
<!--       <div id="this"></div>
      <input type="text" name="locationstate" id="locationstate" value=""> -->
      <form name="PriceCalc" id="PriceCalc" action="">
        <div class="searchbox" width="auto" max-width="879px" border="0">
          <div class="t3">ARTICULO: <br>

            <select title="30x30x30" class="selectpicker" data-live-search="true" data-width="150px" single id="articuloId" name='articulo'>
			<optgroup label="CAJAS">
				<option value="30X30X30">30X30X30</option>
				<option value="24X24X24">24X24X24</option>
				<option...

CSS

/* Always set the map height explicitly to define the size of the div
 * element that contains the map. */

.phone {
  font-family: 'Roboto', 'sans-serif';
  line-height: 20px;
  font-weight: bold;
  font-size: large;
  text-align: center;
  margin: 10px;
  border: 0px solid black;
  outline: 4px solid red;
  outline-offset: 5px;
}

#demo {
  font-family: 'Roboto', 'sans-serif';
  line-height: 30px;
  padding-left: 10px;
}

#map {
  min-height: 50%;
  min-width: 50%;
}

/* Optional: Makes the sample page fill the window. */

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

#floating-panel {
  position: absolute;
  top: 10px;
  left: 25%;
  z-index: 5;
  background-color: #fff;
  padding: 5px;
  border: 1px solid #999;
  text-align: center;
  font-family: 'Roboto', 'sans-serif';
  line-height: 30px;
  padding-left: 10px;
}

#floating-panel {
  position: absolute;
  top: 5px;
  left: 50%;
  margin-left: -180px;
  width: 350px;
  z-index: 5;
  background-color: #fff;
  padding: 5px;
  opacity: 0.5;
  border: 1px solid #999;
}

#latlng {
  width: 225px;
}

/* FROM PRICE CALC*/

body {
  background-color: #f7f7f7;
  text-align: center;
}

@font-face {
  font-family: 'Gotham-Bold';
  src: url('https://mtomtours.com/fonts/Gotham-Bold.eot');
  src: url('https://mtomtours.com/fonts/fonts/Gotham-Bold.eot?#iefix') format('embedded-opentype'), url('https://mtomtours.com/fonts/fonts/Gotham-Bold.woff') format('woff'), url('https://mtomtours.com/fonts/fonts/Gotham-Bold.ttf') format('truetype'), url('https://mtomtours.com/fonts/fonts/Gotham-Bold.svg#Gotham-Bold') format('svg');
  font-weight: normal;
  font-style: normal;
}

.box {
  font-family: Gotham-Bold;
  color: #2181b7;
  font-size: large;
  font-weight: bold;
  outline-style: solid;
  max-width: 100%;
  min-width: 179px;
  display: block;
  height: auto;
}

.t2 {
  font-family: Gotham-Bold;
  font-size: medium;
  color: #003366;
}

.r3 {
  font-family: Gotham-Bold;
  font-size: medium;
  color: #0B0B0B;
 ...

JavaScript

// This function gets your current locations latitude and longitude 
function geoFindMe() {
  var output = document.getElementById("test");
  document.getElementById("floating-panel").style.display = 'none';

  if (!navigator.geolocation) {
    output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
    return;
  }

  function success(position) {
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var lattlngg = latitude + ', ' + longitude;
    window.lattlngg1 = lattlngg;

    // Set latlng input field to current coordinates
    document.getElementById("latlng").value = latitude + ', ' + longitude;

    output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>';
  }

  function error() {
    output.innerHTML = "Unable to retrieve your location";
  }
  output.innerHTML = "<p>Locating…</p>";
  navigator.geolocation.getCurrentPosition(success, error);
}

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 6,
    center: {
      lat: 12.137497,
      lng: -86.281859
    }
  });
  var geocoder = new google.maps.Geocoder;
  var infowindow = new google.maps.InfoWindow;



  // document.getElementById("latlng").value = latitude;
  document.getElementById('submit').addEventListener('click', function() {
    geocodeLatLng(geocoder, map, infowindow);
  });

  setTimeout(function() {
    geocodeLatLng(geocoder, map, infowindow);
  }, 5000);

}

// This converts coordinates from input field into address
function geocodeLatLng(geocoder, map, infowindow, countryl) {
  var input = document.getElementById('latlng').value;
  //  var input = lattlngg1;
  var latlngStr = input.split(',', 2);
  var outlat = parseFloat(latlngStr[0]);
  var outlat2 = outlat + .3028;
  var outlng = parseFloat(latlngStr[1]);
  var latlng = {
    lat: outlat,
    lng: outlng
  };
  var forcursorlatlng = {
    lat: outlat2,
    lng: outlng
  };
  geocoder.geocode({
...