Zooming to the extent of objects

34 views
Skip to first unread message

HugoDrx

unread,
Sep 3, 2008, 12:37:54 PM9/3/08
to KML Developer Support - Google Earth Browser Plugin
Hi all,

I am trying to figure out the best way to make GE zoom in to display
all points and polygons. I have done some work with the
setAbstractView but it's nowhere near as efficient as the GM
getBoundsZoomLevel
method.

Does anyone know how I can do something like I did with Maps -

bounds = GLatLngBounds(ne,sw);
map.setZoom(map.getBoundsZoomLevel(bounds));


Even better, would anyone have an example?

Thanks

HugoDrx

unread,
Sep 3, 2008, 1:11:34 PM9/3/08
to KML Developer Support - Google Earth Browser Plugin
Hi All,

Never mind, I found another post with a similar issue as mine (I just
put in the wrong keywords in my search) and I see that there is
currently not a simple way to do this yet.

Thanks anyway...

TinyGrasshopper

unread,
Sep 4, 2008, 1:31:47 AM9/4/08
to KML Developer Support - Google Earth Browser Plugin
Since i had to do it for my own site, I've put together some code to
zoom to the extents of a feature. Have a look at the source code of
this sample page:

http://www.tinyg.com/googlearthtest7.html

Basically you do:

zoomToFeature(plugin, feature);

where "plugin" is your plugin instance and feature is the feature to
zoom to.


The components of that function may also be useful:


extent = getFeatureExtent(plugin, feature);

This will return a LatLonAltBox with the extents of a feature
(including any sub features).


camera = createCameraFromRectangle(plugin, north, east, south, west);

This will return a camera that will show the extents between north,
south, east and west.


camera = createCameraFromLatLonAltBox(plugin, box);

This will return a camera that will show the extents within the given
LatLonAltBox.


Hope this is helpful,

Cheers,
Chris
Reply all
Reply to author
Forward
0 new messages