You really don't need to rewrite everything in that example. The xml part is unnecessary, you can do json.
You need a table (markers) with fields lat, long and store names. Then use the sql query mentioned in the tutorial above
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
In Laravel you can just do a DB::raw(), then return as a json string. Then on the client side you need to write js to loop through the response and add each location on to the map.
Since you're using a lot of lat long related data consider using mongodb rather than mysql. In mongodb you can do the above query using this:
$km = 1; // 1 kilometer radius
$collection->find(['location'=> ['$nearSphere'=> [ $lng, $lat ], '$maxDistance'=> $km / 6371 ]])
https://docs.mongodb.org/v3.0/reference/operator/query/nearSphere/
I have now values for my lat and lng sir that I will be using in the query..I just want to ask how to output the data since it uses XML codes..how can i convert it to laravel
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community