Friday, June 06, 2008

Thoughts on the Google earth plugin API

Good job Google earth/maps team.

While it feels like they rushed the introduction of the earth plugin a bit, leaving pretty spotty documentation of the API and only a Windows version, it is indeed a great first step. Putting javascript tendrils deep into the control structure of the plugin was inspired and will be transformative.

However, the programmer in me can't help but be a little offended by the size and verbosity of the interface. Am I to understand that the very first example of creating a placemark is what will be needed for such a simple task?

var placemark = ge.createPlacemark('');
placemark.setName("You are at Google");

// Create style map for placemark
var normal = ge.createIcon('');
var iconNormal = ge.createStyle('');
var highlight = ge.createIcon('');
var iconHighlight = ge.createStyle('');
var styleMap = ge.createStyleMap('');

// Create point
var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
var point = ge.createPoint('');

Admittedly it uses the super-annoying StyleMap which I feel should be abolished. Don't you think it is too much to ask to perform this kind of operation for every placemark? I suppose someone could create a wrapper library for this to simplify common tasks.

How about implementing this in your API instead:
name:'You are at Google',

Could the maps/earth team create the nicer interface wrapper?


Tristan said...

I'm really loving the new Earth API, but youre right, the documentation is spotty at best.

i really like your idea about simplifying the whole style/stylemap process!!
i messed around with it for a bit, but then decided it was a good time to change all my xml and loading crap to kml which has really cleaned things up a lot. doesnt do much for 'on demand' editing after the page loads tho, which i think is where your idea would be really handy.

Darrell said...

Agreed on the lack of documentation - I'm surprised that Google haven't shown the basic example of how to generate a DIV balloon (old style htmlinfowindow) on clicking a placemark. If anybody has the solution already then I'd appreciate an update - I'll have a look at it today and post back again if it comes together successfully.

Great plugin though for website integration - rushed to market maybe as you say.

Darrell said...

So I got it working after a few hours of head-banging. For those interested, you can take a look at my associated page link below and view source to see the code (I'm not claiming to be the most efficient coder in the world - any tips welcome):

For my Earth map I use an xml file to hold all of the world locations, coordinates etc. - similar to how it is done in the similar google maps code on the normal travel page. This works well with similar code.

One refinement still to work out is how to have the placemark labels {as achieved by "placemark.setName(title);"} but to suppress the associated popup window on click as it interferes with the workings of the htmldivballoon. Anybody got any ideas?

Darrell said...

I found the answer on another forum some time ago, but will include here also for those interested:

Within the function in, add the following line:

batty699 said...

3d videos becoming very popular right now. You know, the one you can turn over yourself to choose the spot from which you want to observe the whole picture, the whole scene, Soon the same thing might be added on the teen xxx zone. Just imagine, the sex where you can be everywhere!

Taylor Bell said...

his is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the excellent work.