Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have some code heavily borrowed from Google's examples. All I'm using is the Google Places results part of this code, so I'd like to remove the map part out. So, when I do, it throws an error of Cannot read property 'innerHTML' of undefined, since I'm guessing it's needed for the var service function.

Any help removing this area of code?

var map;
var infowindow;

// Create Google Map with location at center

function initMap(latitude, longitude) {
  var location = {lat: latitude, lng: longitude};
  console.log(location);

  // REMOVE THIS SECTION
  map = new google.maps.Map(document.getElementById('map'), {
    center: location,
    zoom: 15
  });
  // ^^ REMOVE THIS SECTION

  var service = new google.maps.places.PlacesService(map);
  service.nearbySearch({
    location: location,
    radius: 3200,
    types: ['school']
  }, callback);
}

// List nearby places

function callback(results, status) {
  if (status === google.maps.places.PlacesServiceStatus.OK) {
    for (var i = 0; i < results.length; i++) {
      listPlaces(results[i]);
    }
  }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
226 views
Welcome To Ask or Share your Answers For Others

1 Answer

Well, it's called "Googgle Maps API" for a reason :-)

In addition, you can hide the map, but the terms of service are including a requirement to show the "powered by Google" logo somewhere on your page.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...