未安装GEarth插件时,使用带有GEarth插件的GMaps API v3

时间:2011-09-08 22:22:15

标签: javascript google-maps google-maps-api-3 google-api google-earth-plugin

我已经构建了一个在Google Maps API v3上运行的Web应用程序,并集成了Google Earth API /插件以在2D和3D中显示我的地图。由于Google Maps API v3没有对Google地球插件的内置支持,因此我使用的是this library

这个库工作得很好,除了当我初始化我的2D和3D地图时,如果没有安装Google Earth插件,我会在整个地图窗口中收到这样的消息,我甚至无法使用2D图:

Problem

有没有办法禁用此消息或将其隐藏在我的2D地图类型下?如果没有,是否有某种方法可以在加载和初始化3D之前检测是否已安装Google地球插件库中?

2 个答案:

答案 0 :(得分:2)

您可以使用以下内容检测地球javascript是否已加载,以及在代码初始化地球地图类型之前是否安装了地球插件:

 if (!google || !google.earth) {
    throw 'google.earth not loaded';
  }

  if (!google.earth.isSupported()) {
    throw 'Google Earth API is not supported on this system';
  }

  if (!google.earth.isInstalled()) {
    throw 'Google Earth API is not installed on this system';
  }

答案 1 :(得分:1)

已修复该库,以便在无法加载插件时不会卡在地球视图中。您将能够从“初始化”事件中获取插件加载状态。

相关问题