Skip to content

Commit

Permalink
Merge pull request #161 from sarapis/feedback-changes
Browse files Browse the repository at this point in the history
update distance radius changes
  • Loading branch information
d9it committed Apr 5, 2024
2 parents eb040b9 + f758c3e commit d46c4c5
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/backend/MapController.php
Expand Up @@ -118,6 +118,7 @@ public function store(Request $request)
$map->geocode_map_key = $request->geocode_map_key;
$map->javascript_map_key = $request->javascript_map_key;
$map->distance_unit = $request->distance_unit;
$map->distance_radius = $request->get('distance_radius', 50);
$map->state = $request->state;
$map->lat = $request->lat;
$map->long = $request->long;
Expand Down Expand Up @@ -179,6 +180,7 @@ public function update($id, Request $request)
$map->geocode_map_key = $request->input('geocode_map_key');
$map->javascript_map_key = $request->input('javascript_map_key');
$map->distance_unit = $request->input('distance_unit');
$map->distance_radius = $request->get('distance_radius', 50);
$map->state = $request->input('state');
$map->lat = $request->input('lat');
$map->long = $request->input('long');
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/frontEnd/ExploreController.php
Expand Up @@ -75,7 +75,7 @@ public function geolocation(Request $request)
// $lng = -77.0373987;

$locations = Location::with('services', 'organization', 'address')->select(DB::raw('*, ( 3959 * acos( cos( radians('.$lat.') ) * cos( radians( location_latitude ) ) * cos( radians( location_longitude ) - radians('.$lng.') ) + sin( radians('.$lat.') ) * sin( radians( location_latitude ) ) ) ) AS distance'))
->having('distance', '<', 2)
->having('distance', '<', $this->map->distance_radius)
->orderBy('distance');

$locationids = $locations->pluck('location_recordid')->toArray();
Expand Down Expand Up @@ -220,7 +220,7 @@ public function geocode(Request $request)
}

$locations = Location::with('services', 'organization')->select(DB::raw('*, ( '.$radius.' * acos( cos( radians('.$lat.') ) * cos( radians( location_latitude ) ) * cos( radians( location_longitude ) - radians('.$lng.') ) + sin( radians('.$lat.') ) * sin( radians( location_latitude ) ) ) ) AS distance'))
->having('distance', '<', 2)
->having('distance', '<', $this->map->distance_radius)
->orderBy('distance');

$location_locationids = $locations->pluck('location_recordid')->toArray();
Expand Down Expand Up @@ -406,7 +406,7 @@ public function filter(Request $request)
)
// ->select(DB::raw('* , (((acos(sin((' . $lat . ' * pi()/180)) * sin((location_latitude*pi()/180))+cos((' . $lat . ' * pi()/180)) * cos((location_latitude*pi()/180)) * cos(((' . $lng . '- location_longitude)* pi()/180))))*180/pi())*60*1.1515*5280) AS distance'))
// ->select(DB::raw('*, ( 3959 * acos( cos( radians(' . $lat . ') ) * cos( radians( location_latitude ) ) * cos( radians( location_longitude ) - radians(' . $lng . ') ) + sin( radians(' . $lat . ') ) * sin( radians( location_latitude ) ) ) ) AS distance'))
->having('distance', '<', 50)
->having('distance', '<', $this->map->distance_radius)
->orderBy('distance');

$location_locationids = $locations->pluck('location_recordid');
Expand Down
2 changes: 1 addition & 1 deletion app/Model/Map.php
Expand Up @@ -7,6 +7,6 @@
class Map extends Model
{
protected $fillable = [
'name', 'sku', 'geocode_map_key', 'state', 'lat', 'long', 'active', 'zoom', 'zoom_profile', 'javascript_map_key',
'name', 'sku', 'geocode_map_key', 'state', 'lat', 'long', 'active', 'zoom', 'zoom_profile', 'javascript_map_key', 'distance_radius',
];
}
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('maps', function (Blueprint $table) {
$table->double('distance_radius')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('maps', function (Blueprint $table) {
$table->dropColumn('distance_radius');
});
}
};
8 changes: 8 additions & 0 deletions resources/views/backEnd/pages/map.blade.php
Expand Up @@ -79,6 +79,14 @@
</div>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="zoom">Distance radius
</label>
<div class="col-md-4 col-sm-4 col-xs-12">
<input type="text" name="distance_radius" class="form-control col-md-7 col-xs-12"
value="{{$map->distance_radius}}">
</div>
</div>

<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="occupation">Map Center
Expand Down
4 changes: 2 additions & 2 deletions resources/views/frontEnd/services/services.blade.php
Expand Up @@ -411,10 +411,10 @@
} else {
avglat = 40.730981;
avglng = -73.998107;
zoom = 14;
zoom = 12;
}
if(chip_address != '0' && chip_address != ''){
zoom = 15
zoom = 13
if(avarageLatitude != '0'){
avglat = avarageLatitude
}
Expand Down

0 comments on commit d46c4c5

Please sign in to comment.