MuzammilRafay
6 months ago
687
2
Laravel

I want to response true or false if latitude & longitude is available inside my radius

Posted 6 months ago by MuzammilRafay

hi, I am using this way for creating google maps. https://www.itsolutionstuff.com/post/laravel-5-multiple-markers-in-google-map-using-gmapsjsexample.html

http://jsfiddle.net/phpdeveloperrahul/rMy2B/

<div id="app">
  @{{ location_find }}
</div>
<script>
var locations = {!!json_encode($locations) !!};
var latitude_serverside = {!!json_encode($latitude) !!};
var longitude_serverside = {!!json_encode($longitude) !!};

new Vue({
    el: '#app',
    data(){ 
        return{
            location_find:false,
        }
    },
    mounted() {
        // alert('working');
        var edit_values = {!!json_encode($locations) !!};
        var location_find_variable = false;
        $(document).ready(function() {
            let latitude_edit = -12.043333;
            let longitude_edit = -77.028333;
            let radius_edit = 250;
            if (edit_values) {
                latitude_edit = edit_values.latitude;
                longitude_edit = edit_values.longitude;
                radius_edit = parseInt(edit_values.radius);
            }
            var map = new GMaps({
                div: '#mymap',
                lat: latitude_edit,
                lng: longitude_edit,
            });
            map.setCenter(latitude_edit, longitude_edit);
            var circle_work = map.drawCircle({
                lat: latitude_edit,
                lng: longitude_edit,
                radius: radius_edit,
                fillColor: '#FF6600',
                fillOpacity: 0.3,
                strokeColor: "#FFF",
                strokeWeight: 0,
                editable: true
            });
            var get_center_ltd_lng = circle_work.getCenter();
            var bounds_server = circle_work.getBounds();
            var latLngA_serside = new google.maps.LatLng(latitude_serverside, longitude_serverside);
            var bound_check_serverside = bounds_server.contains(latLngA_serside);
            this.locaion_find = bound_check_serverside;
            console.log(bound_check_serverside,"location find successfully!");
            location_find_variable = bound_check_serverside;
        });


        this.location_find = location_find_variable
        setTimeout(()=>{
            this.location_find = location_find_variable
        },100)





    }
})
    </script>

there is code.its working and I can check if my latitude & longitude inside radius location its return true or false but the problem is that I need json response from the controller for creating api.but it is all done in javascript. is there any way for response json from controller.

Please sign in or create an account to participate in this conversation.