开发者

Using GMaps API v3 with GEarth Plugin when GEarth Plugin isn't installed

开发者 https://www.devze.com 2023-04-03 10:53 出处:网络
I\'ve built a web application that runs on Google Maps API v3 and integrates the Google Earth API/Plugin to show my map in both 2D and 3D. As Google Maps API v3 doesn\'t have built-in support for the

I've built a web application that runs on Google Maps API v3 and integrates the Google Earth API/Plugin to show my map in both 2D and 3D. As Google Maps API v3 doesn't have built-in support for the Google Earth Plugin, I'm using this library.

That library is working great, except that when I initialize my 2D and 3D maps, if the Google Earth plugin is not installed, I get a message like this across my entire map window, and I can't even use the 2D map:

Using GMaps API v3 with GEarth Plugin when GEarth Plugin isn't installed

Is there a way to disable this message or to hide it underneath my 2D map type? If not, is there some way to detect whether the Google Earth plugin is installed before loading and initializing the 3D librar开发者_如何学Cy?


You can use the following to detect if the Earth javascript is loaded and if the Earth plugin is installed before your code initializes the Earth map type:

 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';
  }


The library has been fixed to not get stuck in the earth view when the plugin can't be loaded. You will be able to get the plugin load state from the "initialized" event.

0

精彩评论

暂无评论...
验证码 换一张
取 消