-1

Recently I was asked to migrate a simple application using google api v2 to v3. I didn't made that application nor was part of it and to be honest, I never used google api. I was able to migrate most of it until I reach this one instruction where an instance of google earth is created from an instance of map.

var map;
var ge;

// map is initialized

map.getEarthInstance(function(pluginInstance)
{
  ge = pluginInstance;
  // other stuff not relevant
});

For what I understand, the point is to have a google earth object linked to a map object and if I try to have two separate objects, the application doesn't work.

My question is, how to implement that code in v3?

From all my searches the one I though it could help was this link, but I get an exception "GoogleEarth is undefined".

I'm using the following scripts:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
<script type="text/javascript" src="https://www.google.com/jsapi?sensor=false"></script>

Anyone can help me out?

Thank you all for taking the time to read my post.

Cheers

Nuno Carvalho
  • 53
  • 1
  • 7
  • possible duplicate of [Google Earth integrated with Google Maps API v3?](http://stackoverflow.com/questions/3039250/google-earth-integrated-with-google-maps-api-v3) – Fraser Jan 17 '14 at 15:27
  • Also, you only need to load the jsapi once. i.e. `` then you can simply call `google.load('maps', '3.x', { other_params: 'sensor=false'}); google.load('earth', '1.x');` see https://developers.google.com/loader/ - loading the api twice like you have there can cause strange errors. – Fraser Jan 17 '14 at 15:34
  • I don't think so. That post is about integration of google earth with google maps, that can be done with "mapTypeId: google.maps.MapTypeId.SATELLITE" when setting your map properties. I need to create an instance of google earth from an instance of google maps. Please take a look at the link I posted. Anyway thak you for you're reply. – Nuno Carvalho Jan 17 '14 at 15:36
  • On your 2nd reply: Thank you, I didn't realized that :) – Nuno Carvalho Jan 17 '14 at 15:38
  • Ah [This example](http://google-maps-utility-library-v3.googlecode.com/svn/trunk/googleearth/examples/earth.html) does what you need, i.e. `googleEarth = new GoogleEarth(map);` - it is linked to in Josh's answer to the duplicate question. . – Fraser Jan 17 '14 at 19:50
  • That's the example I've putted in the link on my post. That gives me a "GoogleEarth is undefined" exception even thou I copied everything like in the example :( – Nuno Carvalho Jan 20 '14 at 13:57
  • You should really link to an example of what you have tried. Clearly have not "copied everything like in the example" - or it would work. – Fraser Jan 20 '14 at 14:17

1 Answers1

0

You are getting GoogleEarth is undefined presumably because you are not loading the file that defines it.

You say you are loading the javascript api and the v3 maps api ... but you also need to load the google-maps-utility-library-v3 - e.g.

<script type="text/javascript" src="../googleearth-compiled.js"></script>

The googleearth-compiled.js file can be found here

The GoogleEarth object that works with the google.maps.map object is defined in that file.

Fraser
  • 15,275
  • 8
  • 53
  • 104
  • :) I just tested that and was about to post it but you beat me :) I used the following line to include that file: "" Thanks for your help :) – Nuno Carvalho Jan 20 '14 at 14:18
  • No worries, just to say if you had linked to an actual example it would have made the problem clear immediately. If you are asking for help with code then always try to include or link to a [Short, Self Contained, Compilable, Example](http://sscce.org/). You can use something like jsfiddle, for example here is a [simple template](http://jsfiddle.net/fraser/7U7FC/) – Fraser Jan 20 '14 at 14:30