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 !!
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