如何将 Google Earth 功能集成到 Flex 中?
我已经使用 ExternalInterface.call("javascriptMethodName")
方法成功地将 Google Earth 与 Flex 集成,并在嵌入 swf 文件的 html 文件中编写了 javascript 内容。它成功运行并加载了 Google Earth。
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js" type="text/javascript"> </script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=I_Put_my_Key_Here"></script>
<script type="text/javascript">
google.load("earth", "1");
google.load("maps", "2.xx");
var ge = null;
var geocoder;
var _position = [0,0,0,0];
function init() {
geocoder = new GClientGeocoder();
google.earth.createInstance('map3d', initCB, failureCB);
}
这是该 html 文件的一个片段,但是当我向 html 文件中添加类似内容时:
var directionsService = new google.maps.DirectionsService();
地球无法加载。任何人都可以建议如何克服这个问题。
谢谢 !!
i have successfully integrated Google earth with Flex using ExternalInterface.call("javascriptMethodName")
method and writing the javascript stuff in the html file which embeds the swf file. it ran and loaded Google earth successfully.
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js" type="text/javascript"> </script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=I_Put_my_Key_Here"></script>
<script type="text/javascript">
google.load("earth", "1");
google.load("maps", "2.xx");
var ge = null;
var geocoder;
var _position = [0,0,0,0];
function init() {
geocoder = new GClientGeocoder();
google.earth.createInstance('map3d', initCB, failureCB);
}
this is a snippet of that html file but when i add something like to the html file:
var directionsService = new google.maps.DirectionsService();
the Earth doesn't load. can anybody suggest how to overcome this problem.
Thanks !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只能在加载地图 api 后对其进行调用,因此这取决于您调用的位置。
此外,DirectionsService 是 V3 api 的一部分,您正在加载版本 2。
此外,
google.maps.DirectionsService()
是异步的,因为 Google Maps API 需要调用外部服务器。因此,您需要传递一个回调方法以在请求完成时执行。此回调方法应该处理结果。请注意,路线服务可能会以一组单独的路线 [] 的形式返回多个可能的行程。要在 V3 中使用方向,请创建一个 DirectionsService 类型的对象,并调用 DirectionsService.route() 来发起对 Directions 服务的请求,向其传递一个包含输入项的 DirectionsRequest 对象文字和一个在收到响应时执行的回调方法。
有关详细信息,请参阅文档:http://code.google。 com/apis/maps/documentation/javascript/services.html#Directions
You can only make calls to the maps api once it has loaded so it would depend where you put the call.
Further to that, DirectionsService are part of the V3 api and you are loading version 2.
Also,
google.maps.DirectionsService()
is asynchronous, since the Google Maps API needs to make a call to an external server. For that reason, you need to pass a callback method to execute upon completion of the request. This callback method should process the result(s). Note that the Directions service may return more than one possible itinerary as an array of separate routes[].To use directions in V3, create an object of type DirectionsService and call DirectionsService.route() to initiate a request to the Directions service, passing it a DirectionsRequest object literal containing the input terms and a callback method to execute upon receipt of the response.
See the documentation for more information: http://code.google.com/apis/maps/documentation/javascript/services.html#Directions