ultimatepos/Modules/Tms/Resources/views/shipments/_geocode_js.blade.php

18 lines
732 B
PHP

<script>
$(function(){
$('#tms_geocode_btn').on('click', function(){
var addr = $('textarea[name=destination_address]').val();
if(!addr){ toastr.warning(@json(__('tms::lang.enter_address_first'))); return; }
$.post(@json(action([\Modules\Tms\Http\Controllers\ShipmentController::class, 'geocodeAddress'])), {
_token: @json(csrf_token()), address: addr
}, function(res){
if(res.success){
$('#destination_latitude').val(res.data.lat);
$('#destination_longitude').val(res.data.lng);
toastr.success(@json(__('tms::lang.geocode_success')));
} else { toastr.error(res.msg); }
}, 'json');
});
});
</script>