LAT/Long read out

26 views
Skip to first unread message

Geospectrum

unread,
Sep 24, 2008, 5:50:40 PM9/24/08
to KML Developer Support - Google Earth Browser Plugin
Im looking for a way to get a dynamicly changing read out of the lat
long of the center point of the plug in screen and display this data
on screen. A bit like the readout on the status bar but I need to
position the information in a diffrent location to simulate a HUD.
(www.geospectrum.co.uk/ge/globe.html) is what I have so far. If you
switch on the HUD display you will see what I am getting at. I need
the lat long display to be positioned where it says 'Platform'.

I am not a developer but an happy to fiddle with code and make it work
the way I want if I can get some indication of the right approach.
Any ideas?

Also, how should I go about turning the 'Display HUD' button into a
toggle switch? here is the code:

----snip---

function showHUD() {
var screenOverlay = ge.createScreenOverlay('');
screenOverlay.setIcon(ge.createIcon(''));
screenOverlay.getIcon().
setHref("http://www.geospectrum.co.uk/ge/hudoverlay.png");

// Set the point inside the overlay that is used as the
positioning
// anchor point.
screenOverlay.getOverlayXY().setXUnits(ge.UNITS_FRACTION);
screenOverlay.getOverlayXY().setYUnits(ge.UNITS_FRACTION);
screenOverlay.getOverlayXY().setX(.5);
screenOverlay.getOverlayXY().setY(.5);

// Set screen position to center of screen
screenOverlay.getOverlayXY().setXUnits(ge.UNITS_FRACTION);
screenOverlay.getOverlayXY().setYUnits(ge.UNITS_FRACTION);
screenOverlay.getOverlayXY().setX(.5);
screenOverlay.getOverlayXY().setY(.5);

// Set object's size in pixels.
screenOverlay.getSize().setXUnits(ge.UNITS_PIXELS);
screenOverlay.getSize().setYUnits(ge.UNITS_PIXELS);
screenOverlay.getSize().setX(750);
screenOverlay.getSize().setY(450);

ge.getFeatures().appendChild(screenOverlay);

}

---snip---

Thanks for any suggestions

fraser

unread,
Sep 25, 2008, 5:34:50 AM9/25/08
to KML Developer Support - Google Earth Browser Plugin
Hi Geospectrum,

You can use a technique call "View-Based Refresh Queries" to track the
center point of the view.
This technique requires some CGI scripting to work (i.e. PHP, Python,
etc)

Go to this page: http://code.google.com/apis/kml/documentation/kml_tut.html#network_links
And look for "Tracking a Point Directly Under Your View"

You could easily adapt the code given to return a KML file that would
draw you HUD for you.
Also, If you adopted this technique then toggling the HUD would be as
simple as setting <visibility> in the KML overlay.

Hope that helps.

F.

Geospectrum

unread,
Sep 25, 2008, 7:09:53 AM9/25/08
to KML Developer Support - Google Earth Browser Plugin
Will this approach work with the GE Plugin or Google earth client?
> > Thanks for any suggestions- Hide quoted text -
>
> - Show quoted text -

fraser

unread,
Sep 25, 2008, 8:44:58 AM9/25/08
to KML Developer Support - Google Earth Browser Plugin
Hi Geospectrum,

The technique can be used with both the full aplication and the plug-
in.


F.
> > - Show quoted text -- Hide quoted text -

fraser

unread,
Sep 29, 2008, 2:33:03 PM9/29/08
to KML Developer Support - Google Earth Browser Plugin
Hi,

Just to note you could also achieve this in javascript by using the
copyAsLookAt method.
The following snippet would need to be called periodically or
triggered by an event...
-----------------------------------------------------------
var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
var lat = la.getLatitude();
var lng = la.getLongitude();
-----------------------------------------------------------
Which ever way you go with this you will need to work out a way to
update your HUD to show the coordinate data.
This is going to entail building the overlay locally using the
javascript API or remotely using a CGI language.

Regards,

Fraser.



On Sep 25, 12:09 pm, Geospectrum wrote:
> > - Show quoted text -- Hide quoted text -

Geospectrum

unread,
Sep 30, 2008, 3:23:34 PM9/30/08
to KML Developer Support - Google Earth Browser Plugin
So, Just for my clarification. I call the python script from the kml
which I parse using the GE API Right? (you can tell I am not a
developer!

fraser

unread,
Sep 30, 2008, 8:06:39 PM9/30/08
to KML Developer Support - Google Earth Browser Plugin
Sure, that is it exactly...

F.
Reply all
Reply to author
Forward
0 new messages