Dear Jim, thank you very, very much.<br>It worked perfectly.<br><br>I assume it would be too much to ask why my code didn&#39;t work. :)<br><br>Bests<br><br>Vlado<br><br><div class="gmail_quote">On Mon, Dec 19, 2011 at 6:33 PM, Jim White <span dir="ltr">&lt;<a href="mailto:jbw2003@earthlink.net">jbw2003@earthlink.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <pre>Hi,

You need to call 

 map.zoomToExtent(new OpenLayers.Bounds(kml.getExtent()))

from the event handler. Something like this

deeds.events.on({       
               
        &#39;loadend&#39;: function (evt) {
            var deeds_extent = deeds.getDataExtent();
            map.zoomToExtent(deeds_extent);
        }
    });

Jim



 
Hi to all,

I am developing my app and every day I keep bumping in walls.

Today I spend 12 hours trying to figure how to zoom to the extent of the
queried features, but couldn&#39;t sort it out.
I use *zoomToExtent(vector_layer.getExtent())*,

 but it zooms somewhere in the middle atlantic <span title=":)"></span>.

In the firebug, when I call 

*getExtent()*
 
it returns it. If I say 

*new OpenLayers.Bounds(vector_layer.getExtent())*

 it returns just left boundary?!

If I try <b><span>*</span>vector_layer.calculateBounds<span>*</span></b> or <b><span>*</span>getBounds<span>*</span></b> it returns
&quot;undefined&quot;.

The strangest thing is when I call <b><span>*</span>vector_layer.geometryType<span>*</span></b>  it returns
Null, although map displays all polygons perfectly.

Can anybody help, I would be very grateful  - this just makes me out of
myself <span title=":)"></span>. 

Here is the code:

var map, osm, kml;
 
        upit=&quot;<i><span>/</span>kml<span>/</span></i>&quot;;
        {%if search_details%}

        upit=&quot;<i><span>/</span>kml<span>/</span></i>?q={{x}}&amp;r={{y}}&quot;;

        {%endif%}

function init(){


        var options = {maxExtent: new OpenLayers.Bounds(
            1813816.431496, 5245458.4167548, 2178341.4193136,
5664389.3081316),
        units: &#39;m&#39;,
        projection: new OpenLayers.Projection(&#39;EPSG:900913&#39;),
        displayProjection: new OpenLayers.Projection(&#39;EPSG:3908&#39;)

        }
            map = new OpenLayers.Map(&#39;map&#39;, options);

            map.addControl(new OpenLayers.Control.LayerSwitcher());
            map.addControl(new OpenLayers.Control.MousePosition());

            osm = new OpenLayers.Layer.OSM(
                &quot;OSM&quot;);

            kml = new OpenLayers.Layer.Vector(&quot;KML&quot;,
               {
            projection: new OpenLayers.Projection(&#39;EPSG:4326&#39;),
            protocol: new OpenLayers.Protocol.HTTP({
                url: upit,
                format: new OpenLayers.Format.KML({
                    extractAttributes: true,
                    extractstyles: true
                })
            }),
            strategies: [new OpenLayers.Strategy.Fixed()]}); 

            map.addLayers([osm, kml]);

        var google_satellite = new OpenLayers.Layer.Google(&#39;Google&#39;, {
        type: google.maps.MapTypeId.SATELLITE
    });
    map.addLayer(google_satellite);

/*map.zoomToExtent(
               new OpenLayers.Bounds(
                    1813816.431496, 5245458.4167548, 2178341.4193136,
5664389.3081316))*/

 map.zoomToExtent(new OpenLayers.Bounds(kml.getExtent()))
</pre>
  </div>

</blockquote></div><br><br clear="all"><br>-- <br>Vladimir Stupar<br>Katedra za Ekologiju šuma<br>Šumarski fakultet, Univerzitet u Banjaluci<br>S. Stepanovića 75a, 78000 Banjaluka<br>Bosna i Hercegovina<br>tel.:+38765692006<br>
fax.:+38751460550<br>e-mail: <a href="mailto:stuparvladimir@gmail.com">stuparvladimir@gmail.com</a><br>skype: vmstupar<br><br>Vladimir Stupar<br>Department for Forest ecology<br>Forestry faculty, University in Banjaluka<br>
S. Stepanovica 75a, 78000 Banjaluka<br>Bosnia &amp; Hercegovina<br>tel.:+38765692006<br>fax.:+38751460550<br>e-mail: <a href="mailto:stuparvladimir@gmail.com">stuparvladimir@gmail.com</a><br>skype: vmstupar<br><br><br>