Is there a method for Disabling navigation controls?

111 views
Skip to first unread message

Jonathan_me

unread,
Jun 18, 2009, 11:57:46 AM6/18/09
to KML Developer Support - Google Earth Plug-in
Hi,
I'm trying to create a GE plugin application part of which requires
the user to be able to draw a bounding box / rectangle in Google Earth
over their area of interest (i.e. something like:
http://www.erh.noaa.gov/ctp/wxradio/images/TPCbcast_map.gif ). I'd
then get the co-ordinates of the box's vertices and use them in my
application.

This is creating several problems, but they all centre around the fact
that it doesn't seem to be possible to disable the mouse-navigation
controls. I.e. clicking and dragging with the mouse always pans the
map - I'm fine with the navigation bar thing (that's controlable after
all).

So my question boils down to two things:
a) Is it possible to disable the mouse-navigation controls and if so
how?

b) Given the above likely limitation what's the least-ugly way to get
a user-selected area?
I'm currently looking at using something similar to:
http://earth-api-samples.googlecode.com/svn/trunk/demos/draw/index.html

or:
http://www.barnabu.co.uk/geapi/polyplot/
But again, both are ugly cludges for my purposes.

Thanks,
Jonathan

Markw65

unread,
Jun 18, 2009, 12:32:22 PM6/18/09
to KML Developer Support - Google Earth Plug-in
Look at: http://code.google.com/apis/earth/documentation/demogallery.html?searchquery=iframe&topic=
in the demo gallery.

When you click the top-left "+" sign, you get a modal dialog, and all
earth navigation is disabled.

It actually does a lot more than you want. You'll find the code in the
fixup.js script, and the relevant part is:

var null_handler = function(event) {
event.preventDefault();
event.stopPropagation();
};

google.earth.addEventListener(ge.getWindow(),"click",
null_handler, true);
google.earth.addEventListener(ge.getWindow(),"dblclick",
null_handler, true);
google.earth.addEventListener(ge.getWindow(),"mouseover",
null_handler, true);
google.earth.addEventListener(ge.getWindow(),"mousedown",
null_handler, true);
google.earth.addEventListener(ge.getWindow(),"mouseup",
null_handler, true);
google.earth.addEventListener(ge.getWindow(),"mouseout",
null_handler, true);
google.earth.addEventListener(ge.getWindow(),"mousemove",
null_handler, true);

Of course, you'll want to have *real* handlers for at least some of
those events. Just remember to call event.preventDefault() and
event.stopPropagation() from those too.

Mark

On Jun 18, 8:57 am, Jonathan_me wrote:
> Hi,
> I'm trying to create a GE plugin application part of which requires
> the user to be able to draw a bounding box / rectangle in Google Earth
> over their area of interest (i.e. something like:http://www.erh.noaa.gov/ctp/wxradio/images/TPCbcast_map.gif). I'd

fraser (Earth API Guru)

unread,
Jun 18, 2009, 8:35:27 PM6/18/09
to KML Developer Support - Google Earth Plug-in
Hi,

Sure there is, just use;

ge.getOptions()..setMouseNavigationEnabled(false);

Passing 'true' in the same method re-enables the controls.

See http://code.google.com/apis/earth/documentation/reference/interface_g_e_options.html#9680ad8f82014a453f0c217b2c2ff8c5

F.

On Jun 18, 5:32 pm, Markw65 wrote:
> Look at:http://code.google.com/apis/earth/documentation/demogallery.html?sear...

Markw65

unread,
Jun 18, 2009, 9:16:08 PM6/18/09
to KML Developer Support - Google Earth Plug-in
You learn something every day :-)

Its not even marked as a "new" feature... which is my usual excuse...

Mark

On Jun 18, 5:35 pm, fraser (Earth API Guru) wrote:
> Hi,
>
> Sure there is, just use;
>
> ge.getOptions()..setMouseNavigationEnabled(false);
>
> Passing 'true' in the same method re-enables the controls.
>
> Seehttp://code.google.com/apis/earth/documentation/reference/interface_g...

Jonathan_me

unread,
Jun 19, 2009, 6:09:53 AM6/19/09
to KML Developer Support - Google Earth Plug-in
Thanks both.
I went through the entire list of plugin demos looking for things that
may be of use to me and somehow I still managed to miss that one -
typical. :-)

setMouseNavigationEnabled(false); - does indeed seem to be what I'm
looking for, though it seems strange I never came across it when
searching - maybe Google need to improve their search engine. Even
stranger, I've not seen it used in any of the demos I've looked at
despite it being well-suited to some of them (i.e. the polygon drawing
one I mentioned in my first post).


That having answered the mouse navigation part, any suggestions for
how to go about creating a bounding box? There are examples of how to
get lat/lon for a placemark around from which I can nab stuff, but how
should I go about creating the box in the first place? There doesn't
seem to be a handler on that list for "holding-down-a-click" - and nor
have I seen one in my travels - which is how dragging a bounding box
typically occurs. I could probably make it so the user clicks the top
left and bottom right corners and extrapolate the other two vertices,
but is there a better way anyone can think of (JavaScript is not a
preferred language for me so my knowledge of what I can do with it is
limited)?

Thanks again,
Jonathan

fraser (Earth API Guru)

unread,
Jun 19, 2009, 6:53:46 AM6/19/09
to KML Developer Support - Google Earth Plug-in
Hi guys,

To be fair it is in one of the first examples given.
http://earth-api-samples.googlecode.com/svn/trunk/demos/options/index.html
Also, the method has been available in the plugin since day one!
Oh well, happens to use all :)

@Jonathan re "holding-down-a-click"
Sure you can, just use a variable to hold state for you.
If you take a look at the 'Draggable Placemark' sample.
http://earth-api-samples.googlecode.com/svn/trunk/examples/placemark-dragdrop.html
See how the variable 'dragInfo' is used to implement 'holding-down-a-
click' behaviour.

F.
Reply all
Reply to author
Forward
0 new messages