Merge branch 'master' of https://github.com/NoNameGuy/geocomb
commit
4cbb773b47
|
@ -41,7 +41,12 @@ class LandingController extends BaseController
|
|||
{
|
||||
$districts = array();
|
||||
$districtsName = array();
|
||||
|
||||
$brands = array();
|
||||
$brandsName = array();
|
||||
|
||||
$coordinates = new \stdClass();
|
||||
|
||||
if(isset($request)){
|
||||
$coordinates->latitude = $request->latitude;
|
||||
$coordinates->longitude = $request->longitude;
|
||||
|
@ -51,49 +56,22 @@ class LandingController extends BaseController
|
|||
$coordinates->longitude = -8.1425;
|
||||
}
|
||||
|
||||
$districts = DB::table('district')->orderBy('name')->get();
|
||||
$districts = DB::table('district')->select('name')->distinct()->get();
|
||||
|
||||
for ($i=0; $i < $districts->count(); $i++) {
|
||||
array_push($districtsName, $districts[$i]->name);
|
||||
}
|
||||
|
||||
$brands = array();
|
||||
$brandsName = array();
|
||||
|
||||
$brands = DB::table('station')->select('brand')->distinct()->get();
|
||||
|
||||
for ($i=0; $i < $brands->count(); $i++) {
|
||||
array_push($brandsName, $brands[$i]->brand);
|
||||
}
|
||||
|
||||
/*$coordinatesArray = array();
|
||||
$ids = array();
|
||||
$coordinate = new \stdClass();
|
||||
$ids = DB::table('station')->select('location')->get();
|
||||
for ($i=0;$i<count($ids);$i++) {
|
||||
$coordinate->latitude = DB::table('location')->where('id', $ids[$i]->location)->select('latitude')->get();
|
||||
$coordinate->longitude = DB::table('location')->where('id', $ids[$i]->location)->select('longitude')->get();
|
||||
array_push($coordinatesArray,$coordinate);
|
||||
}
|
||||
|
||||
if (array_key_exists('location', $_POST)) {
|
||||
$this->fetchAllStations();
|
||||
$coordinates = array();
|
||||
$coordinates = $this->getCoordinatesByPlace(addslashes($_POST['location']));
|
||||
if ( array_key_exists('radius', $_POST)) {
|
||||
$this->searchStations($coordinates["latitude"], $coordinates["longitude"], $_POST['radius']);
|
||||
} else {
|
||||
$this->searchStations($coordinates["latitude"], $coordinates["longitude"]);
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
$stations = array();
|
||||
$stations = $this->getStations($request->district, $request->brand, $request->fuelType);
|
||||
|
||||
//$this->apiStations($stations);
|
||||
|
||||
return View('landing_page', ['districts' => $districts, 'districtsName' => $districtsName, 'brandsName' => $brandsName, 'centerMapCoordinates' => $coordinates, 'stations' => $stations]);
|
||||
return View('landing_page', ['district' => $districts, 'districtsName' => $districtsName, 'brandsName' => $brandsName, 'centerMapCoordinates' => $coordinates, 'stations' => $stations]);
|
||||
}
|
||||
|
||||
private function getStations($district, $brand, $fuelType)
|
||||
|
@ -406,23 +384,39 @@ $uniqueMatch1 = array();
|
|||
#print_r($matches);
|
||||
return $matches;
|
||||
}
|
||||
|
||||
//API
|
||||
public function apiDistricts() {
|
||||
try{
|
||||
$statusCode = 200;
|
||||
$response['districts'] = array();/*[
|
||||
'districts' => []
|
||||
];*/
|
||||
$response['districts'] = array();
|
||||
|
||||
$districts = District::all();
|
||||
//dd($districts);
|
||||
foreach($districts as $district){
|
||||
|
||||
array_push($response['districts'], /*[
|
||||
'id' => $district->id,*/
|
||||
//'name' =>
|
||||
array_push($response['districts'],
|
||||
|
||||
$district->name
|
||||
//]
|
||||
);
|
||||
}
|
||||
|
||||
}catch (Exception $e){
|
||||
$statusCode = 400;
|
||||
}finally{
|
||||
return Response::json($response, $statusCode);
|
||||
}
|
||||
}
|
||||
public function apiBrands() {
|
||||
try{
|
||||
$statusCode = 200;
|
||||
$response['brands'] = array();
|
||||
|
||||
$brands = Station::select('brand')->distinct()->get();
|
||||
foreach($brands as $brand){
|
||||
|
||||
array_push($response['brands'],
|
||||
|
||||
$brand->brand
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,23 +4,50 @@ var js = $(document).ready(function(){
|
|||
var waypts = [];
|
||||
getLocation();
|
||||
|
||||
$("#inputdistrict").autocomplete({
|
||||
var array;
|
||||
$("#district").autocomplete({
|
||||
source: function(request, response){
|
||||
if (array){
|
||||
response($.ui.autocomplete.filter(array, request.term));
|
||||
}else{
|
||||
$.ajax({
|
||||
url: "api/districts",
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
//delay: 50,
|
||||
data: request,
|
||||
data: request.term,
|
||||
|
||||
success: function (data) {
|
||||
response($.map(data["districts"] , function (key, value) {
|
||||
//console.log(data["districts"][value]);
|
||||
response(array = $.map(data["districts"] , function (key, value) {
|
||||
return data["districts"][value];
|
||||
}))}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var array2;
|
||||
$("#brand").autocomplete({
|
||||
source: function(request, response){
|
||||
if (array2){
|
||||
response($.ui.autocomplete.filter(array2, request.term));
|
||||
}else{
|
||||
$.ajax({
|
||||
url: "api/brands",
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
//delay: 50,
|
||||
data: request.term,
|
||||
|
||||
success: function (data) {
|
||||
response(array2 = $.map(data["brands"] , function (key, value) {
|
||||
return data["brands"][value];
|
||||
}))}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name='fuelType']").change(function(){
|
||||
|
@ -31,7 +58,7 @@ var js = $(document).ready(function(){
|
|||
|
||||
|
||||
$("#landingSearch").click(function(){
|
||||
localStorage.setItem("district", $("#inputdistrict").val());
|
||||
localStorage.setItem("district", $("#district").val());
|
||||
localStorage.setItem("brand", $("#brand").val());
|
||||
var fuel = [];
|
||||
$("#landingFuelType input:checked").each(function(){
|
||||
|
@ -42,7 +69,7 @@ var js = $(document).ready(function(){
|
|||
|
||||
function getStations(){
|
||||
if(localStorage.getItem("district")===null || localStorage.getItem("brand")===null || localStorage.getItem("fuelType")===null){
|
||||
/*localStorage.setItem("district", $("#inputdistrict").val());
|
||||
/*localStorage.setItem("district", $("#district").val());
|
||||
localStorage.setItem("brand", $("#brand").val());
|
||||
localStorage.setItem("fuelType", $("#landingFuelType>input[name='fuelType']").val());*/
|
||||
//alert("Please fill the data");
|
||||
|
@ -51,7 +78,7 @@ var js = $(document).ready(function(){
|
|||
var district=localStorage.getItem("district");
|
||||
var brand=localStorage.getItem("brand");
|
||||
fuelType.push(localStorage.getItem("fuelType"));
|
||||
/*var district=$("#inputdistrict").val();
|
||||
/*var district=$("#district").val();
|
||||
var fuelType=$("#landingFuelType>input[name='fuelType']").val();
|
||||
var brand=$("#brand").val();*/
|
||||
var stationsData;
|
||||
|
@ -159,17 +186,17 @@ var js = $(document).ready(function(){
|
|||
}
|
||||
|
||||
|
||||
$("#inputdistrict").keyup(function(){
|
||||
//alert($("#inputdistrict").val());
|
||||
$("#district").keyup(function(){
|
||||
//alert($("#district").val());
|
||||
delay( function(){
|
||||
var brand = $("#inputdistrict").val();
|
||||
var brand = $("#district").val();
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
geocodeAddress(geocoder, map);
|
||||
},1000);
|
||||
});
|
||||
|
||||
$("#landingBack").click(function(){
|
||||
$("#inputdistrict").val('');
|
||||
$("#district").val('');
|
||||
$("#brand").val('');
|
||||
$("#landingFuelType>input[name='fuelType']").prop('checked', false);
|
||||
$("#landingSearch").click();
|
||||
|
@ -184,7 +211,7 @@ var js = $(document).ready(function(){
|
|||
})();
|
||||
|
||||
function geocodeAddress(geocoder, resultsMap) {
|
||||
var address = $('#inputdistrict').val();
|
||||
var address = $('#district').val();
|
||||
var location = { 'latitude':null, 'longitude':null};
|
||||
geocoder.geocode({'address': address}, function(results, status) {
|
||||
if (status === 'OK') {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<hr>
|
||||
|
||||
<h2 class="center">Pesquisar Postos:</h2>
|
||||
<br><br><br>
|
||||
<div class="row">
|
||||
<!--Div esquerda-->
|
||||
<div class="col-sm-6">
|
||||
|
@ -29,50 +30,47 @@
|
|||
<form method="post" action="{{route('home')}}">
|
||||
{{csrf_field()}}
|
||||
<div class="form-group">
|
||||
<label for="inputdistrict">Distrito(s): </label>
|
||||
<input class="form-control" id="inputdistrict" name="district" type="text">
|
||||
<label for="district">Distrito(s): </label>
|
||||
<input class="form-control" id="district" name="district" type="text">
|
||||
</div>
|
||||
<br>
|
||||
<div class="checkbox" id="landingFuelType">
|
||||
<div class="form-group">
|
||||
<label style="font-weight:bold">Tipo de Combustível (Escolha 1): </label>
|
||||
</div>
|
||||
|
||||
<label><input type="radio" name="fuelType" value="diesel">Gasóleo</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_simple">Gasóleo Simples</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_colored">Gasóleo Colorido</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_special">Gasóleo Especial</label><br>
|
||||
<br><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_95">Gasolina 95</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_simple_95">Gasolina Simples 95</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_special_95">Gasolina Especial 95</label><br>
|
||||
<br><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_98">Gasolina 98</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_simple_98">Gasolina Simples 98</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_special_98">Gasolina Especial 98</label><br>
|
||||
<br><br>
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_compressed_kg">GNC KG</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_compressed_m3">GNC M3</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_liquified">GNL</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gpl">GPL</label><br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<label><input type="radio" name="fuelType" value="diesel">Gasóleo</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_simple">Gasóleo Simples</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_colored">Gasóleo Colorido</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_special">Gasóleo Especial</label><br>
|
||||
<br><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_95">Gasolina 95</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_simple_95">Gasolina Simples 95</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_special_95">Gasolina Especial 95</label><br>
|
||||
<br><br>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_compressed_kg">GNC KG</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_compressed_m3">GNC M3</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_liquified">GNL</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gpl">GPL</label><br>
|
||||
<br><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_98">Gasolina 98</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_simple_98">Gasolina Simples 98</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_special_98">Gasolina Especial 98</label><br>
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="brand">Marca (Opcional): </label>
|
||||
<input class="form-control" id="brand" name="brand" type="text">
|
||||
<button id="landingSearch" type="submit">Search...</button>
|
||||
<br>
|
||||
</div>
|
||||
<button id="landingSearch" type="submit">Search</button>
|
||||
|
||||
</form>
|
||||
<br>
|
||||
<script>
|
||||
$( function() {
|
||||
var brandsName = <?php echo json_encode($brandsName); ?>
|
||||
//var availableTags = districtsName;
|
||||
$( "#brand" ).autocomplete({
|
||||
source: brandsName
|
||||
});
|
||||
} );
|
||||
</script>
|
||||
|
||||
@else
|
||||
<form method="post" action="{{route('home')}}">
|
||||
|
@ -87,6 +85,8 @@
|
|||
<div class="well well-lg">
|
||||
<label for="nome">Nome: </label>
|
||||
{{$station->stationName}}<br>
|
||||
<label for="nome">Marca: </label>
|
||||
{{$station->stationBrand}}<br>
|
||||
<label for="nome">Preço: </label>
|
||||
{{$station->fuelPrice}}
|
||||
<button type="button" class="btn btn-link" style="float:right">Detalhes</button>
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divVeiculos">
|
||||
<div id="divVeiculos" style="display:none">
|
||||
<div class="col-sm-6">
|
||||
<div class="list-group" id="vehicleList">
|
||||
@if($vehicles)
|
||||
|
|
|
@ -55,6 +55,7 @@ Route::post('/showGpsCoordinates', 'LandingController@index');
|
|||
|
||||
//API
|
||||
Route::get('/api/districts', 'LandingController@apiDistricts')->name('apidistricts');
|
||||
Route::get('/api/brands', 'LandingController@apiBrands')->name('apibrands');
|
||||
Route::get('/api/stations/{district}/{brand}/{fuelType}', 'LandingController@apiStations')->name('apistations');
|
||||
Route::get('/api/stationsup/{origin}/{destination}/{autonomy}', 'UserPageController@apiStations')->name('apistationsup');
|
||||
|
||||
|
|
Loading…
Reference in New Issue