I want to build a tool which allows me to search and locate my database (longitude and latitude users ), within a certain radius. i already have a googlemaps API key.
Is there a ready made tool or API ?. Any tips or suggestions?
here is my laravel code, so far i have fetched my db users as markers in map.
#map {
height: 50%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<div id="map"></div>
<script>
key=YOUR_API_KEY&libraries=places">
let users = ; console.log(users);
function initMap() { var myLatLng = {lat: 53.2193133, lng: 6.5669632};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
center: myLatLng
});
var markers = [];
for (let i of users) {
markers.push(
new google.maps.Marker({
position: {lat: parseFloat(i.latitude), lng: parseFloat(i.longitude)},
map: map,
title: i
//hier wil ik eigelijk nog de naam van de gebruiker die vertoont wordt als je op de marker klikt.
}));
}
// var marker = new google.maps.Marker({
// position: myLatLng,
// map: map,
// title: 'Hello World!'
// });
// var marker2 = new google.maps.Marker({
// position: {lat: 53.2183133, lng: 6.5669632},
// map: map,
// title: 'Hello World!'
// });
// var myLatlng = new google.maps.LatLng(53.2193133,6.5669632);
// var mapOptions = {
// zoom: 4,
// center: myLatlng
// }
// // var map = new google.maps.Map(document.getElementById("map"), mapOptions);
// // var marker = new google.maps.Marker({
// // position: myLatlng,
// // title:"Hello World!"
// });
}
// i was thinking to try something like this function to put in my controller
public function zoek(Request $request){
$lat=$request ->lat;
$lng=$request ->lng;
$users=User::whereBetween('lat', [lat-0.05, lat+0.05]) ??