The Google Earth API provides a rich toolset for developers to create custom content and interfaces within Google Earth’s rich 3D world. For existing Google Maps developers, many of the Earth API’s methods are similar and previous Google Maps mashups can be ported – but not all.
While working on an upcoming project, we discovered that the current Earth API lacks the nice ‘moveend’ event listener found in Google Maps. With some pointers from the Google Earth team (thanks Mano!), we developed our own simple ‘moveend’ listener based on the ‘frameend’ event which is supported.
What is ‘frameend’?
frameend is an Earth API event which fires anytime the map image frame is re-rendered (ie when the map view changes). Unlike the Google Maps ‘moveend’ event, the frameend event fires continuously during a move. This is great for some applications as it gives a nearly continuous event stream, but doesn’t work so well for functions that you might want to rate limit (like creating custom data based on the view center).
Since we needed to extend frameend in any case, we went ahead and added a few extra parameters that can be adjusted to fine-tune the refresh parameters. In our new function, you can configure the following:
- Minimum movement requirements in Latitude or Longitude
- Minimum zoom change independent of a Lat/Lon change
- Minimum time since last update to rate limit calls to our follow-on function
Try It Out and Get the Sample Code:
Try it out with our Interactive Google Earth API MoveEnd Event Listener Demo . You can adjust the default movement thresholds to get a feel for how various settings change the event behavior. View the page source for a look at the sample code implementation.
Have your own example? Please drop us a line at email@example.com so we can feature it also.