Correction on markers
parent
f2bc0aa599
commit
3e872cdd95
|
@ -18,6 +18,7 @@ use Illuminate\Support\Facades\Response;
|
|||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use App\District;
|
||||
use App\Fuel;
|
||||
use App\Station;
|
||||
use File;
|
||||
use \RecursiveIteratorIterator;
|
||||
|
@ -71,7 +72,10 @@ class LandingController extends BaseController
|
|||
$stations = array();
|
||||
$stations = $this->getStations($request->district, $request->brand, $request->fuelType);
|
||||
|
||||
return View('landing_page', ['district' => $districts, 'districtsName' => $districtsName, 'brandsName' => $brandsName, 'centerMapCoordinates' => $coordinates, 'stations' => $stations]);
|
||||
$fuels = Fuel::select('name')
|
||||
->get();
|
||||
|
||||
return View('landing_page', ['district' => $districts, 'districtsName' => $districtsName, 'brandsName' => $brandsName, 'centerMapCoordinates' => $coordinates, 'stations' => $stations, 'fuels' => $fuels]);
|
||||
}
|
||||
|
||||
private function getStations($district, $brand, $fuelType)
|
||||
|
@ -240,7 +244,7 @@ var_dump($tempAllStations);*/
|
|||
|
||||
private function calculateDistance($latitudeOrigin, $longitudeOrigin, $latitudeDestination, $longitudeDestination)
|
||||
{
|
||||
$earthRadius = 6.371;//km
|
||||
$earthRadius = 6371;//km
|
||||
|
||||
$latitudeDifference = $latitudeOrigin-$latitudeDestination;
|
||||
$longitudeDifference = $longitudeOrigin-$longitudeDestination;
|
||||
|
|
|
@ -222,11 +222,11 @@ class UserPageController extends Controller
|
|||
$destinationDistrict = trim(str_replace('District', '', $destinationDistrict));
|
||||
|
||||
$query = Station::join('district', 'station.district', 'district.id')
|
||||
->join('location', 'station.district', 'location.id');
|
||||
->join('location', 'station.location', 'location.id');
|
||||
|
||||
if(strcmp($originDistrict,"Lisbon")==0 && strcmp($destinationDistrict,"Lisbon")!=0){
|
||||
$query->where('district.name', 'like', "%Lisboa%");
|
||||
$query->orWhere('district.name', 'like', "%$destinationDistrict%");
|
||||
$query->orWhere('district.name', 'like', "%$destinationDistrict%");
|
||||
}else{
|
||||
if (strcmp($originDistrict, "Lisbon")!=0 && strcmp($destinationDistrict, "Lisbon")==0) {
|
||||
$query->where('district.name', 'like', "%$originDistrict%");
|
||||
|
@ -246,7 +246,7 @@ class UserPageController extends Controller
|
|||
//echo "$key -> $value->latitude";
|
||||
$latitudeDestination = $value->latitude;
|
||||
$longitudeDestination = $value->longitude;
|
||||
$earthRadius = 6.371;//km
|
||||
$earthRadius = 6371;//km
|
||||
|
||||
$latitudeDifference = $latitudeOrigin-$latitudeDestination;
|
||||
$longitudeDifference = $longitudeOrigin-$longitudeDestination;
|
||||
|
|
|
@ -4,6 +4,8 @@ var js = $(document).ready(function(){
|
|||
var waypts = [];
|
||||
getLocation();
|
||||
|
||||
$("#district").val(localStorage.getItem("district"));
|
||||
|
||||
var array;
|
||||
$("#district").autocomplete({
|
||||
source: function(request, response){
|
||||
|
@ -50,12 +52,6 @@ var array2;
|
|||
}
|
||||
});
|
||||
|
||||
$("input[name='fuelType']").change(function(){
|
||||
//alert($(this).val());
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$("#landingSearch").click(function(){
|
||||
localStorage.setItem("district", $("#district").val());
|
||||
|
@ -178,11 +174,30 @@ var array2;
|
|||
$("#longitude").val(position.coords.longitude);
|
||||
localStorage.setItem("latitude", position.coords.latitude);
|
||||
localStorage.setItem("longitude", position.coords.longitude);
|
||||
|
||||
var link = "https://maps.googleapis.com/maps/api/geocode/json?latlng="+position.coords.latitude+","+position.coords.longitude;
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: link,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
localStorage.setItem("district", data["results"]["0"]["address_components"]["1"]["long_name"]);
|
||||
},
|
||||
|
||||
error: function (textStatus, errorThrown) {
|
||||
console.log("Error getting the station data")
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
submitForm();
|
||||
|
||||
}
|
||||
function submitForm(){
|
||||
$("#landingHiddenSubmit").click();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -272,7 +287,9 @@ var array2;
|
|||
var autonomykm = $("#upAutonomyKm").val();
|
||||
var autonomyl = $("#upAutonomyL").val();
|
||||
var consumption = $("#upConsumption").val();
|
||||
if((autonomykm==='' && autonomyl==='')||(autonomykm!=='' && autonomyl!=='' || consumption!=='') || (autonomyl!=='' && autonomykm!=='' && consumption==='') || (autonomyl!=='' && autonomyl==='' && consumption!=='')){
|
||||
//original logic
|
||||
//(autonomykm==='' && autonomyl==='')||(autonomykm!=='' && autonomyl!=='' || consumption!=='') || (autonomyl!=='' && autonomykm!=='' && consumption==='') || (autonomyl!=='' && autonomyl==='' && consumption!=='')
|
||||
if( (autonomykm==='' && autonomyl==='') || (autonomyl!=='' && consumption==='') || (autonomykm!=='' && autonomyl!=='') ){
|
||||
alert("Preencha apenas a autonomia em km ou a autonomia em litros e o consumo");
|
||||
}else{
|
||||
var coordinates = getCoordinates();
|
||||
|
@ -288,11 +305,36 @@ var array2;
|
|||
|
||||
calculateAndDisplayRoute(directionsService, directionsDisplay);
|
||||
markers.push(getStationsUP());
|
||||
|
||||
console.table(markers[0][1]);
|
||||
var myLatLng = {"lat": 39.7495, "lng":-8.8077};
|
||||
var labels = '12345';
|
||||
var labelIndex = 0;
|
||||
for(var j=0;j<markers[0].length;j++){
|
||||
|
||||
var marker = new google.maps.Marker({
|
||||
position: {"lat": parseFloat(markers[0][j].latitude), "lng": parseFloat(markers[0][j].longitude)},
|
||||
label: labels[labelIndex++ % labels.length],
|
||||
map: mapUP,
|
||||
title: markers[0][j].stationName
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
markers[0].addListener('dblclick', function() {
|
||||
alert("double click"+ marker.position);
|
||||
waypts.push({
|
||||
location:marker.position,
|
||||
stopover: true
|
||||
});
|
||||
calculateAndDisplayRoute(directionsService, directionsDisplay);
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
markers.forEach(function(marker){
|
||||
for (var i = 0; i < marker.length; i++) {
|
||||
//console.log(parseFloat(marker[i].latitude)+" lng"+ parseFloat(marker[i].longitude));
|
||||
|
@ -304,10 +346,10 @@ var array2;
|
|||
});
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
marker.addListener('dblclick', function() {
|
||||
/*
|
||||
markers[0].addListener('dblclick', function() {
|
||||
alert("double click"+ marker.position);
|
||||
waypts.push({
|
||||
location:marker.position,
|
||||
|
@ -315,7 +357,7 @@ var array2;
|
|||
});
|
||||
calculateAndDisplayRoute(directionsService, directionsDisplay);
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
{{csrf_field()}}
|
||||
<div class="form-group">
|
||||
<label for="district">Distrito(s): </label>
|
||||
<input class="form-control" id="district" name="district" type="text">
|
||||
<input class="form-control" id="district" name="district" type="text" @if(Auth::user() && isset($location)) value="$location" @endif>
|
||||
</div>
|
||||
<br>
|
||||
<div class="checkbox" id="landingFuelType">
|
||||
|
@ -39,6 +39,12 @@
|
|||
<label style="font-weight:bold">Tipo de Combustível (Escolha 1): </label>
|
||||
</div>
|
||||
|
||||
@if($fuels)
|
||||
@foreach($fuels as $fuel)
|
||||
<label><input type="checkbox" name="fuelType" value="{{$fuel->name}}">{{$fuel->name}}</label><br>
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
<div class="col-sm-4">
|
||||
<label><input type="checkbox" name="fuelType" value="diesel">Gasóleo</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="diesel_simple">Gasóleo Simples</label><br>
|
||||
|
|
Loading…
Reference in New Issue