开发者

Problem to pass a kml file to Google Earth using geoxml3 class and ProjectedOverlay class

i am trying to build a google earth view showing cities, but i stuck with the kml parser geoxml3. I have a javascript building a google map at first showing the locations i want. this works fine. I call the function from a php script providing it an address and kml file reference from database. The function builds the map, sets a flag 'map_finished' as a control flag when all ran fine and calls the build google earth view function.

// Get maps and earth from google
google.load( 'maps', '2.s', {'other_params': 'sensor=true'} );
google.load( 'earth', '1' );

//Google Earth Initializer
function initObjectEarth() {
  // Check if Google Earth plugin is installed   
  if( gm_loaded ) {
  this.ge_plugin_installed = google.earth.isInstalled();

  if( this.ge_plugin_installed ) {
    google.earth.createInstance( 'inmap', geSuccessCallback, geFailureCallback );
    ge_loaded = true;
  } else {
    alert( 'Your Browser has not yet installed the Google Earth plugin. 
            We recommend installing it to use all features!' );
    return false;
  }
 }
}

// Success handler
function geSuccessCallback( object ) {
  this.ge = object;
  this.ge.getWindow().setVisibility( true );
  this.kmlParser = new geoXML3.parser();
}

// Error handler
function geFailureCallback( object ) {
   alert( 'Error: ' + object );
}

The geoxml parser uses the ProjectedOverlay class. Both libraries are loaded into document head. When the parser is getting instatiated it requests a ProjectedOverlay instance. This class throws a

Error: **google.maps is undefined**

error in firebug for the following statement

ProjectedOverlay.prototype = new google.maps.OverlayView();

In my script file i have declared vars including

var gm //for google map
var ge //for google earth

gm is set in the functi开发者_开发知识库on that builds the google map.

I wonder how to fix this issue. I tried the getProjection() thing i found in web as well as

ProjectedOverlay.prototype = new google.maps.OverlayView().prototype;

with no success. This topic is absolutely new to me and i cannot figure out how to fix it neither from the documentation of OverlayView nor from google search.

What did i forget or do wrong?


The call to the geoXML3 constructor is wrong, you must pass the google.maps object as a parameter (...hence the "google.maps is undefined" error).

this.kmlParser = new geoXML3.parser({map: gm}); // gm for google map
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜