Google将API库用于无映射javascript

Google将API库用于无映射javascript,javascript,google-maps,google-places-api,Javascript,Google Maps,Google Places Api,我需要从特定坐标中获取半径为100m的最近场所。 我找到了GooglePlacesAPI示例代码,但我在应用程序中没有使用映射,因为这些结果将呈现在列表中。 以下是API代码: var map; var infowindow; function initialize() { var pyrmont = new google.maps.LatLng(-33.8665433, 151.1956316); map = new google.maps.Map(document.getElem

我需要从特定坐标中获取半径为100m的最近场所。 我找到了GooglePlacesAPI示例代码,但我在应用程序中没有使用映射,因为这些结果将呈现在列表中。 以下是API代码:

var map;
var infowindow;

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

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

  var request = {
    location: pyrmont,
    radius: 500,
    types: ['store']
  };
  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]);
    }
  }
}

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);
从API库的深处。
我希望这些信息足以解决这个问题

$attrib
可能不是一个节点,我猜它是一个jQuery对象

使用

或者不使用jQuery:

service = new google.maps.places
          .PlacesService(document.getElementById('main')
                         .appendChild(document.createElement('div')));

导致问题的代码是什么样子的?请用一个例子来说明这个问题。莫莉,谢谢你,成功了!您能解释一下本例中的node是什么吗?node是一个HTML元素,在本例中是通过jQuery创建的
div#attributes
。但jQuery不返回HTML元素,它返回一个jQuery对象(包括一个包含HTML元素的数组)。要从该数组中获取单个HTML元素,请通过索引(从0开始)访问它。数组中只有一个元素,因此
$attrib[0]
将指向此元素。
TypeError: this.j[Wb] is not a function
service = new google.maps.places.PlacesService($attrib[0]);
service = new google.maps.places
          .PlacesService(document.getElementById('main')
                         .appendChild(document.createElement('div')));