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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…