Collaborating in geospatial context since 2000!

Monday, June 30, 2008

Google Earth it!

Using GeoJavascript, you can very easily collect a pair of coordinates and launch Google Earth to view the location. This is in addition to the functionality that is already in place called, "Google Map it!". Here's what you do...

1. Create a folder-level .js file in your ACROBAT_INSTALL/JavaScripts folder and copy the following code in to it. Download the file from here.

2. Open up your GeoPDF file and select the GeoTool, then right-click and select the TerraGo context menu.
3. Choose the newly created Google Earth it! option.

If the stars are aligned properly, Google Earth should open and it should zoom to the location you had selected with the GeoTool.

** Please note, if Google Earth is not your default 'KML' viewer on your Windows system, it will open the app that is associated with 'KML' files.

Please refer to this earlier article with more information on how to do this and thanks again to JB Freels for putting all this together. There is a LOT of cool stuff we can do with GeoJavascript. More to come!

Labels: , ,


Anonymous Anonymous said...


I never used Javascript before, so would appreciate novice speak.

Stars didnt align for me on adding the GE Map It option to the GeoTool.

What do I name the new .js file?

Which of these directories do I save it to on my machine:

C:\Documents and Settings\userid\Application Data\Adobe\Acrobat\8.0\JavaScripts

C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Javascripts

C:\Program Files\Adobe\Reader 8.0\Reader\Javascripts

Any troubleshooting suggestions?


12:30 PM EDT

Blogger Adam Estrada said...

I just tested it again and you're right, the script I put on the web server was modified to be viewed on the web. The Javascript engine that is used with Adobe does not interpret line breaks all that well so...please download the file again.

Once you do this, create a new file in C:\Program Files\Adobe\Acrobat x.x\Acrobat\Javascripts
and call it whatever you want. I called mine GoogleEarth.js.

Please give it a try and let me know if you have any more problems. Note that the PDF you open has to be geomark enabled because this script actually embeds the KML directly in the PDF!


1:57 PM EDT

Anonymous Anonymous said...

Thanks for the response, but the stars still did not GE Map It option is added when right-clicking a GeoMark Enabled GeoPDF using the GeoTool.

I created a GoogleEarth.js with your script.

And I placed this .js file here: C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Javascripts

I tried a variety of GeoMark Enabled GeoPDFs. I tried them both in Acrobat and Reader. Don't know what else to try or check?


4:18 PM EDT

Blogger Adam Estrada said...

Ahhh...You first have to select the GeoTool Icon. Next, you must select a point by left clicking on your map and once the point is selected you can right click to get the Google Earth it! text to actually do something. There are a couple ways to debug this too!

When you open in GeoPDF file in Acrobat, browse to Advanced --> Document Processing --> Document Javascripts and edit the script for Map2PDF. Copy the following code in to that page at the very bottom...after all the brackets are closed. This manually adds the content window option.

TGO.GeoToolAddItemToMenu(null, "Google Earth(tm) it!", "ge();");

Once you have added the code, make sure the same bit of code it commented out the same bit of code in GoogleEarth.js. Do this or just cut and paste it in to a text editor for later use.

Now, save the PDF and those changes will remain embedded in the that document. I hope this helps...

4:36 PM EDT

Anonymous Anonymous said...

First, you said:

"Ahhh...You first have to select the GeoTool Icon. Next, you must select a point by left clicking on your map and once the point is selected you can right click to get the Google Earth it! text to actually do something."

This I have tried and there is no "Google Earth it!" option at all".

Are you suggesting I modify the Map2PDF script for every single GeoPDF I want to use the Google Map it option with???

I'm calling it a day. Thanks for trying.

5:11 PM EDT

Blogger Adam Estrada said...

OK, it is not necessary to modify that script at all! It is just useful for trying to debug a downloaded script though!

This brings us to script debugging in Acrobat! Once you have opened your GeoPDF and you KNOW that GoogleEarth.js is in the proper location, which is appears to be in your case, click ctrl and j to launch the script debugger. Any errors in your script will show up here! Its pretty verbose and should tell you what its having problems executing! Also, make sure that you downloaded and replaced the script data from the original blog post! Best of luck!


5:41 PM EDT

Anonymous Anonymous said...

Adam, thanks, no bug shows up in the debugger.

Could this Google Earth It function be added to the next GeoPDF Toolbar update?

Meanwhile, if anybody other than Adam or TerraGo employees can get this working, please let me know how you did it?


11:50 AM EDT

Anonymous Anonymous said...

I am getting a TGO is not defined error

1:08 PM EDT

Anonymous JB Freels said...

Hey anonymous,

I am the software engineer that developed GeoJavaScript. I would like to personally help you sort this issue out.

The "TGO is not defined" error leads me to believe that JavaScript is not properly enabled on your installation of Acrobat.

To make sure JavaScript is enabled in Acrobat, open Acrobat and click Edit -> Preferences -> General and then select the JavaScript options. "Enable Acrobat JavaScript" should be checked AND "Enable menu items JavaScript execution privileges" should be checked.

Also keep in mind, the file must be GeoMark Enabled if you are not a registered user of Map2PDF for Acrobat.

email me if you need further help: I am happy to help.



1:41 PM EDT

Anonymous Anonymous said...

"When you enable usage rights in Adobe Reader you can't edit JavaScript." Adam, is this true?

To GeoMark Enable, you have to "enable usage rights in Adobe Reader", correct?

So I am confused how to edit a javascript in a GeoPDF, where's its function only works on a Reader and GeoMark Enabled document? Could you let me know if there is something I could try to get this working? Any security settings I may check? Thanks

1:45 PM EDT

Blogger Adam Estrada said...

Note: Any GeoPDF that is created using any TerraGo software released in Q3 of this year will be GeoMark enabled by default.


1:46 PM EDT

Anonymous jb freels said...

You do not have to "Enable Usage Rights" to GeoMark enable. If you want to add comments in Reader, you do. GeoMark enable also enables GeoJavaScript. So if your end-user has Acrobat, but does not have a license for Map2PDF for Acrobat, you'll have to GeoMark enable the file so they can use GeoJavaScript.


2:31 PM EDT

Anonymous Anonymous said...

Thanks for your suggestions. The script still does not work though. One question before I go any further with this:

Will this Google Earth It function on the GeoTool tool only be accessible via a GeoMark Enabled GeoPDF in Adobe Acrobat, not Reader also? If it's only available in Acrobat, then I'll stop attempting to get it to work right now because only I have acrobat where everybody else in the organization has reader only...which also leads me to the ? of whether this will be added to the GeoPDF Toolbar in its next update?

Also, I respect your responses, but both of you give very conflicting suggestions. For example, you can't edit javascripts with a Reader Enabled GeoPDF (Adam's suggested trying this, but it can't be done with a Reader Enabled doc, but you need a Reader Enabled doc to have a GeoMark Enabled doc, at least that is how I've operated for a long time), and JB, if your response is you don't need to Reader Enable to GeoMark, then I've wasted a lot of time and TerraGo needs to change their knowledge base because it says (see #2):

How do I GeoMark Enable a GeoPDF file (v4.0)?

GeoMark Enabling allows the recipient of a GeoPDF file, whether using Adobe Acrobat or Adobe Reader with only the free GeoPDF Toolbar, to 'mark up' a GeoPDF file with points, lines, polygons, notes that can then be exported to the shapefile format. In order to GeoMark Enable a GeoPDF file, please follow the steps below:

1. Open a GeoPDF file into Adobe Acrobat Professional.

2. Select the Comments menu > Enabling for Commenting and Analysis in Adobe Reader option.

3. Type a name to save the new Reader Enabled file in the 'File name' field OR browse for the file in the File list and click on it (this will overwrite the existing file).

4. Click the Save button.

*** NOTE - If a file is selected from the list, a warning will pop up asking about replacing the current file. Select Yes if this is the intent, Select No to return to step 3.

5. Click on the GeoMark Enable button on the Map2PDF Toolbar.

*** NOTE - A message stating the GeoPDF file has been extended for GeoMarks appears.

6. Click the OK button.

7. Select the File menu > Save option.

JS, I followed your enabling JavaScript suggestions and tried all kinds of different GeoPDFs (GeoMark Enabled, non GeoMark Enabled, Reader and non Reader Enabled) to no avail..the GoogleEarth It option is not there and no bugs pop-up.

Could you explain you exact process for creating your .js file? Do I need to have the Acrobat SDK installed? Just trying to think of how to get it working.


6:44 PM EDT

Anonymous Aarthi Rajasekaran said...


I have Acrobat 9 Pro installed in my machine.
Can you tell me where I can get sample geospatially enbled PDf maps.
Any suggestions?
Since everyone has been going gaga over this geospatial functionaliy in Acrobat, I would Love to try it.

8:13 AM EDT

Blogger Adam Estrada said...

Please refer to this post...

TerraGo will be providing more examples in the near future!


10:29 AM EDT

Blogger Adam Estrada said...

We will include this as core functionality in the Toolbar. This was a quick example that apparently does not work for everyone...this is a good thing to know because we are now going to beef up the documentation so that anyone can implement their own scripts or scripts that they find on the internet. As always, if you would like more information please feel free to email me directly at


4:49 PM EDT

Anonymous Anonymous said...

Thank you very much!! Great response! I'm sure you'll keep us updated once this documentation is released! Can't wait to try it all out and get something working!

6:49 PM EDT


Post a Comment

<< Home