Google没有定义 [英] Google Is Not Defined

查看:115
本文介绍了Google没有定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个查找Place的简单应用程序,但是当我尝试运行它时,我得到一个ReferenceError。我现在的代码是直接从Google教程中获取的,所以我不确定我缺少什么。

  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 = {
位置:pyrmont,
半径:'500',
类型:['store']
};

service = new google.maps.places.PlacesService(map);
service.search(request,callback);
}

我得到的错误是ReferenceError:google未定义。在这一行上

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

我假设它像某种包含类似的简单东西,但我不知所措。

解决方案

Google Apps脚本与Javascript不同。
您在此处撰写的代码适用于Google地图的JavaScript API。要在Apps Script中使用地图,请使用Apps Script文档中定义的类 - https://开发人员。 google.com/apps-script/service_maps

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

这篇关于Google没有定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆