【问题标题】:How do I modify my javascript code to alert this?如何修改我的 javascript 代码以提醒这一点?
【发布时间】:2011-01-12 01:09:29
【问题描述】:

http://geodit.com:8000/test

如果您访问我的网站,您会看到我安装了 Google Local Search API。 基本上,它通过 javascript 访问 Google 并执行搜索。

有人搜索某项内容并点击其中一个结果后,我如何提醒该地址? (现在,地图上会弹出一些门槛信息白框,我不要,我只想提醒地址)

【问题讨论】:

标签: javascript jquery css templates google-maps


【解决方案1】:

改变

LocalResult.prototype.select = function() {
  unselectMarkers();
  this.selected_ = true;
  this.highlight(true);
  gInfoWindow.setContent(this.html(true));
  gInfoWindow.open(gMap, this.marker());
};

LocalResult.prototype.select = function() {
      unselectMarkers();
      this.selected_ = true;
      this.highlight(true);
      var msg = 'Address\n\t';
      msg += this.result_.addressLines.join('\n\t');
      msg += '\nCity\n\t';
      msg += this.result_.city;
      msg += '\nCountry\n\t';
      msg += this.result_.country;
      alert(msg);
};

【讨论】:

  • 谢谢!这行得通。您是如何知道“addressLines”、“city”和“country”的?您使用什么 API 页面查看这些属性?
  • @Timex,当 this 对象引用 LocalResult 时,我使用了 firebug 来检查它。 (在上述函数中使用console.log(this)
猜你喜欢
  • 1970-01-01
  • 2014-03-26
  • 2022-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多