Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions loc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCmEwkAA_tx3Z4VjyvIeME6AYbOv_QSRxk"></script>
</head>
<body>
<div id="map"></div>
<script>
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var location = new google.maps.LatLng(lat, lng);
var map = new google.maps.Map(document.getElementById('map'), {
center: location,
zoom: 15
});
var request = {
location: location,
radius: 500,
types: ['restaurant']
};
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
});
} else {
alert('Geolocation is not supported by this browser.');
}

function callback(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
var place = results[i];
console.log(place.name);
}
}
}
</script>
</body>
</html>