0

如何找到社区,看看他们是否靠近市中心、公园或其他感兴趣的地方。对于给定的纬度和经度,我们如何获得附近的超市、五金店、餐馆和其他地方。

<!DOCTYPE html>
<html>
<head>
<title>Place searches</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet">

    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&libraries=places"></script>


<script type="text/javascript">
var map;
var service;
var infowindow;

function initialize() {
var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316);

map = new google.maps.Map(document.getElementById('map'), {
  mapTypeId: google.maps.MapTypeId.ROADMAP,
  center: pyrmont,
  zoom: 15
});

var request = { location: pyrmont, radius: '500', query: 'restaurant' };

service = new google.maps.places.PlacesService(map);
service.textSearch(request, callback);
}

function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
  var place = results[i];
  createMarker(results[i]);
  }
}
}

</script>

</head>
<body onload="initialize()">
<div id="map-canvas" style="width: 50%; float: left">
</div>
</body>
</html>
4

0 回答 0