远-方的博客

google.earth命名空间参考--google earth开发学习

Public Functions

bool  isSupported ()
bool  isInstalled ()
void  createInstance (object domNode, function initCallback, function failureCallback,[optional] object options)
void  addEventListener (object targetObject, string eventID, function listenerCallback,[optional] bool useCapture)
void  removeEventListener (object targetObject, string eventID, function listenerCallback,[optional] bool useCapture)
void  fetchKml (GEPlugin pluginInstance, string url, function completionCallback)
void  executeBatch (GEPlugin pluginInstance, function batchFunction)

 

Detailed Description

google.earth 命名空间包括了使用Earth API接口的一些全局函数. 例如:通过 google.earth.createInstance 方法,实例化Google Earth Browser Plug-in对象,并通过google.earth.addEventListener and google.earth.removeEventListener 方法来控制事件句柄.


 

Function Documentation

bool google.earth.isSupported (  ) 

Whether or not the Google Earth Browser Plug-in and API are supported on the current browser and operating system.

bool google.earth.isInstalled (  ) 

Whether or not the Google Earth Browser Plug-in is currently installed on the user's machine.

Note: if the plug-in is not installed, the user will be presented with a 'download' link upon calls to google.earth.createInstance().

void google.earth.createInstance ( object  domNode,
function  initCallback,
function  failureCallback,
[optional] object  options  
)

试图在给定的Web浏览器的HTML DOM结点内创建GE plugin的实例. 一旦成功,调用参数中的initCallback回调函数. 如果失败, 调用参数中的 failureCallback, 并在显示插件对象的位置上显示一个错误信息.

Note: The HTML DOM 必须在这个函数调用之前载入. 通常是在 <body>'s load 事件中调用这个函数, 或者使用 google.setOnLoadCallback.

Parameters:
domNode  Either the string ID of the HTML DOM element or the DOM element itself (usually a <div>) that will contain the plug-in instance or error message.
initCallback  A function that will be called with an instance of GEPlugin as the first parameter upon successful instantiation of the plugin.
failureCallback  A function that will be called upon failure to instantiate the plugin. The user will also be shown a graphical error description page in place of the plugin.
options  (optional) A JavaScript object literal (i.e, { option1: 'value1', option2: 'value2' }) containing extra initialization options. The following options are recognized:
database

The URL of an alternative Earth Enterprise database to connect to instead of the default database.

Note: Certain changes may be required to your Google Earth Server configuration before Google Earth Plugin instances will be able to connect to it using this method. Google Earth Server versions 3.2 and higher are already pre-configured for connectivity with the plugin. Contact Google Earth Enterprise support for more details.

Note: Keep in mind the Google Earth API Terms of Service while using this parameter.

void google.earth.addEventListener ( object  targetObject,
string  eventID,
function  listenerCallback,
[optional] bool  useCapture  
)

Attaches a listener to a given object for a specific event; when the event occurs on the object, the given callback is invoked.

Parameters:
targetObject  The object on which to listen to the event.
eventID  The event string (i.e. 'click', 'mouseover', 'frameend', etc.) identifying the event to listen for. See the individual class reference pages for available events.
listenerCallback  A function that will be called with an instance of KmlEvent when the event occurs on the object.
useCapture  (optional) Whether or not this listener should initiate capture. For more details on event capture and bubbling, see the relevant W3C DOM documentation.

void google.earth.removeEventListener ( object  targetObject,
string  eventID,
function  listenerCallback,
[optional] bool  useCapture  
)

Removes an event listener previously added using google.earth.addEventListener() from the event chain.

Note: You must pass in the exact same function object as was passed to addEventListener. If you are using an anonymous function callback, it will need to be refactored into its own variable.

Parameters:
targetObject  The object on which to stop listening to the event.
eventID  The event string (i.e. 'click', 'mouseover', 'frameend', etc.) identifying the event to stop listening for.
listenerCallback  The function, originally passed to google.earth.addEventListener(), that should no longer be called when the event occurs.
useCapture  (optional) Whether or not the originally added listener was set to initiate capture.

void google.earth.fetchKml ( GEPlugin  pluginInstance,
string  url,
function  completionCallback  
)

提取并解析 a KML or KMZ 文件,该文件由给出的URL指定并返回一个KmlFeature-derived class的实例,它代表解析后的 KML object model.

Note: 这个函数不会在Earth中显示 the feature. See below for more information.

Parameters:
pluginInstance  执行提取URL并解析的GEPlugin实例.
url  提交KML or KMZ内容的URL. This URL should serve either the KML or KMZ content type.
completionCallback  如果成功提取并解析了KML或者KMZ内容后,将调用此函数,并传递一个 KmlFeature-derived class 类的实例参数,作为该函数的第一个参数. 如果发生了错误,这个函数将会被传递一个null value.

Note: 在这个函数里,你可以在Earth中显示载入的 KML,通过调用 ge.getFeatures().appendChild(object), assuming 'ge' is the GEPlugin instance variable in the callback function's scope and 'object' is the name of the first parameter to your callback function.

void google.earth.executeBatch ( GEPlugin  pluginInstance,
function  batchFunction  
)

Efficiently executes an arbitrary, user-defined function (the batch function), minimizing the amount of overhead incurred during cross-process communication between the web browser and Google Earth Plugin. This method is useful for batching together a large set of calls to the Earth API, for example, a large number of consecutive calls to KmlCoordArray.pushLatLngAlt.

Note:
This method is guaranteed to run synchronously; that is, executeBatch blocks and does not return until the batch function has completed. In fact there should be no difference between calling executeBatch(fn) and fn() besides execution performance.
Parameters:
pluginInstance  The instance of GEPlugin that batched API calls will be executed on.
batchFunction  The function containing the code to be executed.

 

posted on 2009-12-03 10:41  远-方  阅读(679)  评论(0编辑  收藏  举报

导航