zoukankan      html  css  js  c++  java
  • Google AJAX API 入门笔记(一)

    1.首先,从Google网站注册一个相关Google AJAX API密钥;

    2.使用 Google 地球 API 要在网页中载入 Google 地球插件,您需要进行以下操作:

      I.载入 Google 地球 API[用相关密钥来替换以下内容中的ABCDEFG部分]。

    <script src="http://www.google.com/jsapi?key=ABCDEF"></script>

      II.创建 DIV 元素来包含该插件。

    <div id="map" style=" 800px; height: 600px;" />

      III.创建初始化插件的函数。

    代码
      var ge;
      google.load("earth", "1");
      function init() {
         google.earth.createInstance("map", initCallback, initFailure);
      }
      function initCallback(instance) {
         ge = instance;
         ge.getWindow().setVisibility(true);
      }
      function initFailure(errorCode) {
      }
     
     IV.网页载入后,调用该初始化函数。
    google.setOnLoadCallback(init);

      V.完整代码:

     
    代码
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        
    <title>Google Earth</title>
        
    <meta content="text/html; charset=utf-8" http-equiv="content-type" />
        
    <script src="http://www.google.com/jsapi?key=ABCDEFG"></script>
        
    <script language="javascript" type="text/javascript">
        
    // <![CDATA[

            var ge;
            google.load(
    "earth""1");

            function init() {
                google.earth.createInstance(
    "map", initCallback, initFailure);
            }

            function initCallback(instance) {
                ge 
    = instance;
                ge.getWindow().setVisibility(
    true);
            }

            function initFailure(errorCode) {
            }

            google.setOnLoadCallback(init);

        
    // ]]>
        </script>
    </head>
    <body>
        
    <div id="map" style=" 800px; height: 600px;">
        
    </div>
    </body>
    </html>
  • 相关阅读:
    Vue学习笔记(一)
    Visual Studio Code (vscode)自定义用户代码段快速打出for循环等
    2019.5.5 JS相关
    项目搭建 相关
    2019.4.26 响应式布局
    android The content of the adapter has changed but ListView did not receive a notification 错误的解决方案
    ListView 加载数据时 触摸报错
    android 代码中使用textAppearance
    c/c++ 指针函数 和 函数指针
    c/c++ 指针数组 和 数组指针
  • 原文地址:https://www.cnblogs.com/gaotang/p/1771582.html
Copyright © 2011-2022 走看看