【问题标题】:Google Places API - Getting Phone Number and WebsiteGoogle Places API - 获取电话号码和网站
【发布时间】:2015-01-12 17:30:28
【问题描述】:

我认为我需要进行跟进电话以获得我正在寻找的结果。但是,我无法获取我提取的任何结果的电话号码和 www url。

我是一个新手,需要一些帮助来解释在这段代码中我可以得到正确结果的地方。请在此处查看演示站点:

http://news.yeselectric.com/gmaps-excel-master/

这是我的 JS 代码:

    var store = (function () {

  var searchBox,
  infowindow,
  markers = [],
  myLatlng = new google.maps.LatLng(50.0019, 10.1419),
  myOptions = { zoom: 6, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, streetViewControl:false },
  customIcons = { iconblue: './icons/blue.png' };

  var init = function() {

    map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
    input = (document.getElementById('pac-input'));
    map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
    searchBox = new google.maps.places.SearchBox((input));
    store.listener();

  }, 

  listener = function() {

    google.maps.event.addListener(searchBox, 'places_changed', function() {

        //search for places
        var places = searchBox.getPlaces(); 
        for (var i = 0, marker; marker = markers[i]; i++) {
          marker.setMap(null);
        }

        //set markers zero 
        markers = [];
        $('.addaddress').empty();

        //get new bounds
        var bounds = new google.maps.LatLngBounds();

        for (var i = 0, place; place = places[i]; i++) {
          store.create_marker(place);

          //append to the table
          $('.addaddress').append('<tr><td>'+ place.name +'</td><td>'+ place.formatted_address +'</td><td>'+ place.formatted_phone_number +'</td><td>'+ place.website +'</td></tr>');
          bounds.extend(place.geometry.location);
        }

        //set the map
        map.fitBounds(bounds);

    });
  }, 

  create_marker = function(info) {

    //create a marker for each place
    var marker = new google.maps.Marker({ map: map, icon: customIcons.iconblue, title: info.name, position: info.geometry.location });

    //infowindow setup
    google.maps.event.addListener(marker, "click", function() {    

      if (infowindow) {
        infowindow.close();
      }

      infowindow = new google.maps.InfoWindow({content: info.name});
      infowindow.open(map, marker);

    });

    //push the marker
    markers.push(marker);

  }

  return {
   init: init, 
   listener: listener, 
   create_marker: create_marker
 };

})();

google.maps.event.addDomListener(window, 'load', store.init);

【问题讨论】:

    标签: api google-places-api phone-call


    【解决方案1】:

    Google 的 API 会根据您使用的调用返回不同的地点元数据。要获取更多地点详细信息,您需要获取该地点的 placeId 并使用该地址拨打 place.getDetails()

    这里有一个更彻底的答案:https://stackoverflow.com/a/9523345/2141296

    【讨论】:

      猜你喜欢
      • 2015-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多