I’m trying to create a simple app that looks up a Place, but I’m getting a ReferenceError when I try to run it. My current code is taken straight from a Google tutorial, so I’m not sure what I’m missing.
function myFunction()
{
var map;
var service;
var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316);
map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: pyrmont,
zoom: 15
});
var request = {
location: pyrmont,
radius: '500',
types: ['store']
};
service = new google.maps.places.PlacesService(map);
service.search(request, callback);
}
The error I get is “ReferenceError: “google” is not defined.” on this line
var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316);
I assume its something simple like some sort of include, but I’m at a loss.
Google Apps Script is not the same as Javascript.
The code you are writing here is for the JavaScript API of Google Maps. To use Maps in Apps Script, use the classes defined in the Apps Script documentation – https://developers.google.com/apps-script/service_maps