Markers
parent
0c1c8846d1
commit
727e2dd1b8
|
@ -96,11 +96,12 @@ class LandingController extends BaseController
|
|||
if($district!=null && $brand!=null && $fuelType!=null){
|
||||
$stations = Station::join('district', 'station.district', 'district.id')
|
||||
->join('fuel_price', 'station.fuel_price', 'fuel_price.id')
|
||||
->join('location', 'station.location', 'location.id')
|
||||
->where('district.name','like', "%$district%")
|
||||
->where('station.brand','like', "%$brand%")
|
||||
->where("fuel_price.$fuelType",'!=', null)
|
||||
->orderBy("fuel_price.$fuelType", "asc")
|
||||
->select('station.name as stationName', "fuel_price.$fuelType as fuelPrice")
|
||||
->select('station.name as stationName', "station.brand as stationBrand", "district.name as districtName", "fuel_price.$fuelType as fuelPrice", "latitude", "longitude")
|
||||
->take(5)
|
||||
->get();
|
||||
}
|
||||
|
@ -421,27 +422,28 @@ $uniqueMatch1 = array();
|
|||
/*[
|
||||
'districts' => []
|
||||
];*/
|
||||
$stations = Station::join('district', 'station.district', 'district.id')
|
||||
$stations = $this->getStations($district, $brand, $fuelType);
|
||||
/*$stations = Station::join('district', 'station.district', 'district.id')
|
||||
->join('fuel_price', 'station.fuel_price', 'fuel_price.id')
|
||||
->join('location', 'station.location', 'location.id')
|
||||
->where('district.name','like', "%$district%")
|
||||
->where('station.brand','like', "%$brand%")
|
||||
->where("fuel_price.$fuelType",'!=', null)
|
||||
->select('station.name as stationName', 'station.brand as stationBrand', 'district.name as districtName', 'location.latitude as latitude', 'location.longitude as longitude')
|
||||
->get();
|
||||
->get();*/
|
||||
//dd($stations);
|
||||
foreach($stations as $station){
|
||||
|
||||
array_push($response["stations"], /*[
|
||||
//echo "$station";
|
||||
$data =["stationName" => $station->stationName,
|
||||
"stationBrand" => $station->stationBrand,
|
||||
"districtName" => $station->districtName,
|
||||
"latitude" => $station->latitude,
|
||||
"longitude" => $station->longitude
|
||||
];
|
||||
array_push($response["stations"], $data /*[
|
||||
'id' => $district->id,*/
|
||||
//'name' =>
|
||||
//]
|
||||
json_encode(["stationName" => $station->stationName,
|
||||
"stationBrand" => $station->stationBrand,
|
||||
"districtName" => $station->districtName,
|
||||
"latitude" => $station->latitude,
|
||||
"longitude" => $station->longitude
|
||||
])
|
||||
);
|
||||
}
|
||||
//dd($response);
|
||||
|
|
|
@ -21,9 +21,9 @@ class UserPageController extends Controller
|
|||
->where('users.email', $user->email)
|
||||
->get();
|
||||
|
||||
$planRoute = true;
|
||||
|
||||
|
||||
return view('user_page', ['name'=>$user->name, 'vehicles' => $vehicles]);
|
||||
return view('user_page', ['name'=>$user->name, 'vehicles' => $vehicles, 'planRoute' => $planRoute]);
|
||||
}
|
||||
|
||||
public function add(Request $request)
|
||||
|
|
|
@ -26,72 +26,97 @@ var js = $(document).ready(function(){
|
|||
alert($(this).val());
|
||||
});
|
||||
|
||||
function initMap(location) {
|
||||
var coordinates = {"latitude": null, "longitude": null};
|
||||
if(location!=null){
|
||||
coordinates = {"latitude": location.latitude, "longitude": location.longitude};
|
||||
}else{
|
||||
if($("#latitude").val()!='' && $("#longitude").val()!=''){
|
||||
coordinates = {"latitude": $("#latitude").val(), "longitude": $("#longitude").val()};
|
||||
}else{
|
||||
coordinates = {"latitude": 39.676944, "longitude": -8.1425};
|
||||
}
|
||||
}
|
||||
|
||||
var pt = {lat: parseFloat(coordinates.latitude), lng: parseFloat(coordinates.longitude)};
|
||||
var map = new google.maps.Map(document.getElementById('map'), {
|
||||
zoom: 10,
|
||||
center: pt
|
||||
|
||||
|
||||
$("#landingSearch").click(function(){
|
||||
localStorage.setItem("district", $("#inputdistrict").val());
|
||||
localStorage.setItem("brand", $("#brand").val());
|
||||
var fuel = [];
|
||||
$("#landingFuelType input:checked").each(function(){
|
||||
fuel.push($(this).val());
|
||||
});
|
||||
|
||||
var stations = getStations();
|
||||
placeMarker(map);
|
||||
|
||||
}
|
||||
|
||||
function placeMarker(map) {
|
||||
var myLatLng = {"lat": 39.7495, "lng":-8.8077};
|
||||
var marker = new google.maps.Marker({
|
||||
position: myLatLng,
|
||||
map: map,
|
||||
title: 'Fuel Station'
|
||||
});
|
||||
}
|
||||
localStorage.setItem("fuelType", fuel);
|
||||
});
|
||||
|
||||
function getStations(){
|
||||
var district=$("#inputdistrict").val();
|
||||
if(localStorage.getItem("district")===null || localStorage.getItem("brand")===null || localStorage.getItem("fuelType")===null){
|
||||
/*localStorage.setItem("district", $("#inputdistrict").val());
|
||||
localStorage.setItem("brand", $("#brand").val());
|
||||
localStorage.setItem("fuelType", $("#landingFuelType>input[name='fuelType']").val());*/
|
||||
alert("Please fill the data");
|
||||
}else {
|
||||
var fuelType=new Array();
|
||||
var district=localStorage.getItem("district");
|
||||
var brand=localStorage.getItem("brand");
|
||||
fuelType.push(localStorage.getItem("fuelType"));
|
||||
/*var district=$("#inputdistrict").val();
|
||||
var fuelType=$("#landingFuelType>input[name='fuelType']").val();
|
||||
var brand=$("#brand").val();
|
||||
console.log("antes do ajax");
|
||||
var brand=$("#brand").val();*/
|
||||
var stationsData;
|
||||
|
||||
$.ajax({
|
||||
url: "api/stations/"+district+"/"+brand+"/"+fuelType,
|
||||
async: false,
|
||||
url: "api/stations/"+district+"/"+brand+"/"+fuelType[0],
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
//delay: 50,
|
||||
//data: data,
|
||||
success: function (data) {
|
||||
stationsData = data["stations"];
|
||||
console.table(stationsData);
|
||||
},
|
||||
|
||||
success: function(data) {
|
||||
console.log("success: "+data["stations"]);
|
||||
|
||||
// return results;
|
||||
},
|
||||
/* success: function (data) {
|
||||
console.table(data["stations"]);
|
||||
$.map(data["stations"] , function (key, value) {
|
||||
//console.log(data["districts"][value]);
|
||||
console.log(" key "+key+" value: "+value);
|
||||
//return data["stations"][value];
|
||||
//}
|
||||
})},*/
|
||||
error: function (textStatus, errorThrown) {
|
||||
console.log("Error getting the station data")
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
console.log(stationsData);
|
||||
return stationsData;
|
||||
|
||||
}
|
||||
|
||||
function initMap(location) {
|
||||
var coordinates = {"latitude": null, "longitude": null};
|
||||
if(location!=null){
|
||||
coordinates = {"latitude": location.latitude, "longitude": location.longitude};
|
||||
}else{
|
||||
if($("#latitude").val()!='' && $("#longitude").val()!=''){
|
||||
coordinates = {"latitude": $("#latitude").val(), "longitude": $("#longitude").val()};
|
||||
}else{
|
||||
coordinates = {"latitude": 39.676944, "longitude": -8.1425};
|
||||
}
|
||||
}
|
||||
|
||||
var pt = {lat: parseFloat(coordinates.latitude), lng: parseFloat(coordinates.longitude)};
|
||||
var map = new google.maps.Map(document.getElementById('map'), {
|
||||
zoom: 10,
|
||||
center: pt
|
||||
});
|
||||
|
||||
var markers=new Array();
|
||||
markers.push(getStations());
|
||||
//console.log(markers);
|
||||
placeMarker(map, markers);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function placeMarker(map, markers) {
|
||||
var myLatLng = {"lat": 39.7495, "lng":-8.8077};
|
||||
markers.forEach(function(marker){
|
||||
for (var i = 0; i < marker.length; i++) {
|
||||
console.log(parseFloat(marker[i].latitude)+" lng"+ parseFloat(marker[i].longitude));
|
||||
new google.maps.Marker({
|
||||
position: {"lat": parseFloat(marker[i].latitude), "lng": parseFloat(marker[i].longitude)},
|
||||
map: map,
|
||||
title: 'Fuel Station'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getLocation() {
|
||||
|
||||
if (($('#latitude').val()==='' || $('#longitude').val()==='') && localStorage.getItem("latitude")!==null && localStorage.getItem("longitude")!==null) {
|
||||
|
|
|
@ -8,4 +8,5 @@
|
|||
</footer>
|
||||
|
||||
</body>
|
||||
<script src="{{asset('js/javascript.js')}}"></script>
|
||||
</html>
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="{{asset('css/style.css') }}">
|
||||
<script src="{{asset('js/bootstrap3-typeahead.js')}}"></script>
|
||||
<script src="{{asset('js/javascript.js')}}"></script>
|
||||
<script async defer
|
||||
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDsZDCiU1k6mSuywRRL88xxXY-81RMEU7s&callback=initMap" >
|
||||
</script>
|
||||
|
@ -75,7 +74,8 @@
|
|||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -89,7 +89,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -99,4 +98,4 @@
|
|||
<div class="row content">
|
||||
<div class="col-sm-2 sidenav">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
<h2 class="center">Pesquisar Postos:</h2>
|
||||
<div class="row">
|
||||
<!--Div esquerda-->
|
||||
<div class="col-sm-6">
|
||||
<div id="map"></div>
|
||||
</div>
|
||||
@include('map')
|
||||
<!--Div direita-->
|
||||
<div class="col-sm-6">
|
||||
@if(!isset($stations))
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<div class="col-sm-6">
|
||||
<div id="map"></div>
|
||||
</div>
|
|
@ -34,6 +34,9 @@
|
|||
</script>
|
||||
|
||||
<br><br><br>
|
||||
@if($planRoute)
|
||||
@include('map')
|
||||
@endif
|
||||
<!--
|
||||
<div id="divPercurso">
|
||||
<div id="map" class="col-sm-6"></div>
|
||||
|
|
Loading…
Reference in New Issue