viewchangeend event fires on initial load but not after

105 views
Skip to first unread message

GregC

unread,
Nov 17, 2009, 5:28:19 PM11/17/09
to KML Developer Support - Google Earth Plug-in
Hi,

I'm using a viewchangeend event to store the current extent of the map
using getViewportGlobeBounds() into a cookie. The viewchangeend event
fires on initial load but not thereafter navigating/zooming around. Am
I doing something wrong?

Thanks

Greg


google.earth.addEventListener(ge.getView(), "viewchangeend", setTimeout
(viewChangeEndListener, 100));

...

//records the extent of the view to a cookie
viewChangeEndListener: function(kmlEvent) {

var latLonBox = ge.getView().getViewportGlobeBounds();
var extentCookie = latLonBox.getWest() + ',' + latLonBox.getSouth() +
',' + latLonBox.getEast() + ',' + latLonBox.getNorth();
Ext.util.Cookies.set({name: 'currentMapExtent', value:
extentCookie});
alert('viewChangeEnd: Extent = ' + extentCookie);
},

fraser (Earth API Guru)

unread,
Nov 20, 2009, 4:35:10 AM11/20/09
to KML Developer Support - Google Earth Plug-in
Hi Greg,

Try setting the time out in the callback method rather than the
listener declaration.
Also, on a side note, there is no kmlEvent object passed for the
viewchange events so
your viewChangeEndListener can be parameterless...
------------------------------------------------------------------------
google.earth.addEventListener(ge.getView(), "viewchangeend",
viewChangeEndListener);

function viewChangeEndListener() {
setTimeout(function() {
//your code here...
},100);
}
------------------------------------------------------------------------

Hope that helps.

F.
Reply all
Reply to author
Forward
0 new messages