<div class="form-group">
<label for="nama_lokasi">Nama</label>
<input type="text" class="form-control" placeholder="Nama..." name="nama_lokasi" id="nama_lokasi" value="{{ old('nama_lokasi',@$data->nama_lokasi) }}" required>
@error('nama_lokasi')
<div class="invalid-feedback show" role="alert">
{{ $message }}
</div>
@enderror
</div>
<div class="form-group">
<label for="alamat_lokasi">Alamat Lokasi</label>
<textarea name="alamat_lokasi" id="alamat_lokasi" class="form-control" cols="30" rows="10" placeholder="Alamat Lokasi">{{ old('alamat_lokasi',@$data->alamat_lokasi) }}</textarea>
@error('alamat_lokasi')
<div class="invalid-feedback show" role="alert">
{{ $message }}
</div>
@enderror
</div>
<div class="form-group">
<input type="text" name="latitude" id="latitude" value="{{ @$data->latitude }}" class="form-control" placeholder="Latitude" required>
@error('latitude')
<div class="invalid-feedback show" role="alert">
{{ $message }}
</div>
@enderror
<input type="text" name="longitude" id="longitude" value="{{ @$data->longitude }}" class="form-control" placeholder="Longitude" required>
@error('longitude')
<div class="invalid-feedback show" role="alert">
{{ $message }}
</div>
@enderror
<label for="map">Koordinat Lokasi</label>
<div id="map"></div>
</div>
<div class="form-group">
<label for="radius">Radius (Meter)</label>
<input type="number" class="form-control" placeholder="Radius..." name="radius" id="radius" value="{{ old('radius',@$data->radius ?? 50) }}" required>
@error('radius')
<div class="invalid-feedback show" role="alert">
{{ $message }}
</div>
@enderror
</div>
@push('styles')
<link href="https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.css" rel="stylesheet">
<link rel="stylesheet" href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.css" type="text/css">
<style>
#map {
width: 100%;
height: 500px;
}
</style>
@endpush
@push('scripts')
<script src="https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.js"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js"></script>
<script src='https://unpkg.com/@turf/turf@6/turf.min.js'></script>
<script>
let coordinate = [117.13849920377697,-0.49960603702142237];
var radius = $('#radius').val();
var options = {steps: 50, units: 'meters'};
var circle = null;
mapboxgl.accessToken = 'pk.eyJ1IjoiYmFndXNpbmRyYXlhbmEiLCJhIjoiY2p0dHMxN2ZhMWV5bjRlbnNwdGY4MHFuNSJ9.0j5UAU7dprNjZrouWnoJyg';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
center: coordinate,
zoom: 13
});
// Add the control to the map.
map.addControl(
new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl
})
);
let marker = null;
map.on('click',(e) => {
coordinate = [e.lngLat.lng, e.lngLat.lat];
if(marker){
marker.setLngLat(e.lngLat);
} else {
marker = new mapboxgl.Marker();
marker.setLngLat(e.lngLat).addTo(map);
}
$("#latitude").val(e.lngLat.lat);
$("#longitude").val(e.lngLat.lng);
if(circle){
circle = turf.circle(coordinate, radius, options);
map.getSource('radiusData').setData(circle);
} else {
circle = turf.circle(coordinate, radius, options);
map.addSource("radiusData", {
type: "geojson",
data: circle,
});
map.addLayer({
id: "circle-fill",
type: "fill",
source: "radiusData",
paint: {
"fill-color": "blue",
"fill-opacity": 0.2,
},
});
}
});
$(document).on('change','#radius',(e) => {
radius = e.target.value;
if(circle){
circle = turf.circle(coordinate, radius, options);
map.getSource('radiusData').setData(circle);
}
});
$(document).ready(function(){
cekWaktuAbsen();
$(document).on('change','#waktu-absen',function(){
cekWaktuAbsen();
});
function cekWaktuAbsen(){
if($('#waktu-absen').is(':checked')){
$('.waktu-absen').removeAttr('disabled');
}else{
$('.waktu-absen').attr('disabled',true);
}
}
});
</script>
@php
$latitude = old('latitude',@$data->latitude);
$longitude = old('longitude',@$data->longitude);
@endphp
@if ($latitude != null && $longitude != null && $latitude != "" && $longitude != "")
<script>
coordinate = [{{ $longitude }},{{ $latitude }}];
var radius = {{ @$data->radius }};
map.on('load', function(){
map.setZoom(15);
map.setCenter(coordinate);
marker = new mapboxgl.Marker();
marker.setLngLat(coordinate).addTo(map);
circle = turf.circle(coordinate,radius ?? $("#radius").val(), options);
map.addSource("radiusData", {
type: "geojson",
data: circle,
});
map.addLayer({
id: "circle-fill",
type: "fill",
source: "radiusData",
paint: {
"fill-color": "blue",
"fill-opacity": 0.2,
},
});
});
</script>
@endif
@endpush
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]