使用 geoxml3 类和 ProjectedOverlay 类将 kml 文件传递到 Google 地球时出现问题
我正在尝试构建一个显示城市的谷歌地球视图,但我坚持使用kml解析器geoxml3。我有一个 JavaScript 构建一个谷歌地图,首先显示我想要的位置。这很好用。我从 php 脚本调用该函数,为其提供数据库中的地址和 kml 文件引用。该函数构建地图,当一切运行良好时将标志“map_finished”设置为控制标志,并调用构建谷歌地球视图函数。
// 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 );
}
geoxml 解析器使用 ProjectedOverlay 类。这两个库都加载到文档头中。当解析器启动时,它会请求一个 ProjectedOverlay 实例。此类
Error: **google.maps is undefined**
在 firebug 中针对以下语句引发错误
ProjectedOverlay.prototype = new google.maps.OverlayView();
在我的脚本文件中,我声明了 vars,包括
var gm //for google map
var ge //for google earth
gm 在构建谷歌地图的函数中设置。
我想知道如何解决这个问题。我尝试了在网络上找到的 getProjection() 方法,但
ProjectedOverlay.prototype = new google.maps.OverlayView().prototype;
没有成功。这个主题对我来说绝对是新的,我无法从 OverlayView 的文档或谷歌搜索中找出如何解决它。
我忘记了什么或做错了什么?
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 function 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对 geoXML3 构造函数的调用是错误的,您必须将 google.maps 对象作为参数传递(...因此出现“google.maps 未定义”错误)。
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).