Google Places API特定地区

时间:2014-03-01 20:19:04

标签: javascript php google-places

我是Google Places API世界的新手。 实质上,我想获得特定地区的所有银行(我在意大利)。

你能帮我完成这件事吗?

我想使用PHP或Javascript

来实现这一目标

我做到了:

var map;
var infowindow;

function initialize() {
  var  pyrmont= new google.maps.LatLng(41.892439,12.483470);

  map = new google.maps.Map(document.getElementById('map-canvas'), {
    center: pyrmont,
    zoom: 5
  });

  var request = {
    location: pyrmont,
    radius: 200000,
    types: ['bank']
  };
  infowindow = new google.maps.InfoWindow();
  var service = new google.maps.places.PlacesService(map);
  service.nearbySearch(request, callback);
}

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

function createMarker(place) {
  var placeLoc = place.geometry.location;
  var marker = new google.maps.Marker({
    map: map,
    position: place.geometry.location
  });

  google.maps.event.addListener(marker, 'click', function() {
    infowindow.setContent(place.name);
    infowindow.open(map, this);
  });
}

google.maps.event.addDomListener(window, 'load', initialize);
 <!DOCTYPE html>
 <html>
      <head>
        <title>Place searches</title>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
        <meta charset="utf-8">
        <style>
          html, body, #map-canvas {
            height: 2000px;
            margin: 0px;
            padding: 0px
          }
        </style>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&libraries=places"></script>
       
      </head>
      <body>
        <div id="map-canvas"></div>
      </body>
 </html>

我必须从罗马开始在拉齐奥地区(意大利)获得银行名单,但我不知道如何。有了这个代码,我在地图上有一部分靠近罗马的银行,但不是全部都在拉齐奥地区。

0 个答案:

没有答案