Hi, <br>thanks. I don&#39;t know why, but i didn&#39;t even need the first 2 lines of your code. I think i had it allready correct but the ..getBounds and map.setCenter was at the wrong place in my code. Now everything is working, even the popup.destroy(). ;)<br>
<br>Thanks for your help, Ben<br><br>here is the working code:<br> <br>    var bounds;<br>    function createPopup(feature) {<br>        <br>        popup = new GeoExt.Popup({<br>            title: &#39;Kneipen Infos: &#39; +<a href="http://feature.attributes.name">feature.attributes.name</a>,<br>
            feature: feature,<br>            width:250,<br>            height:100,<br>            html:  &quot;&lt;h2&gt; Name: &quot; +<a href="http://feature.attributes.name">feature.attributes.name</a> + &quot;&lt;/h2&gt; &lt;p&gt;Stadtteil: &quot; + feature.attributes.stadtteil + &quot;&lt;/p&gt;&lt;p&gt;Preis kleiner Shoppen: &quot; +feature.attributes.preis +&quot;&lt;/p&gt;&quot;, //Definition der Attribute, hier eventuell Tabelle<br>
            maximizable: false,<br>            collapsible: true,<br>            listeners: {<br>               &quot;close&quot;: function() {<br>                selectCtrl.unselect(this.feature);<br>                            }<br>
                        }<br>            }<br>                    <br>            );<br>        // unselect feature when the popup is closed<br>        popup.on({<br>            close: function() {<br>                if(OpenLayers.Util.indexOf(layer.selectedFeatures,<br>
                                           this.feature) &gt; -1) {<br>                    selectCtrl.unselect(this.feature);<br>                      }<br>            }<br>        });<br>        feature.popup = popup;<br>
        popup.show();<br>       <b> bounds = feature.geometry.getBounds();<br>        map.setCenter(bounds.getCenterLonLat(),map.getZoomForExtent(bounds));</b><br>    }<br>    <br>//Popup erzeugen wenn Feature selektiert<br>
            layer.events.on({<br>                featureselected: function(e) {<br>                createPopup(e.feature)<br>                        },//Popup verbergen wenn ein anderes Feature selektiert wird<br><b>                featureunselected: function(e) {<br>
                popup.destroy(e.feature)<br>                        }</b><br>            });<br>                <br><br><div class="gmail_quote">2010/6/29 Sarah Schuessler <span dir="ltr">&lt;<a href="mailto:sarah_flip@yahoo.de">sarah_flip@yahoo.de</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Hi,<br>
<br>did you tried this for your zoom?:<br>var r = grid.getStore().getAt(rowIndex);<br>var feature = r.get(&#39;feature&#39;);<br>var bounds = feature.geometry.getBounds();<br>map.setCenter(bounds.getCenterLonLat(),map.getZoomForExtent(bounds));<br>
<br>HTH<br><br>best regards<br>Sarah<br><div><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">
<font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">Von:</span></b> Ben Leetz &lt;<a href="mailto:ben.leetz@googlemail.com" target="_blank">ben.leetz@googlemail.com</a>&gt;<br><b><span style="font-weight: bold;">An:</span></b> <a href="mailto:users@geoext.org" target="_blank">users@geoext.org</a><br>
<b><span style="font-weight: bold;">Gesendet:</span></b> Dienstag, den 29. Juni 2010, 9:25:07 Uhr<br><b><span style="font-weight: bold;">Betreff:</span></b> [Users] Need some help with GeoExt PopUps / Zoom to POI<br></font><div>
<div></div><div class="h5"><br>
<div style="font-family: -moz-fixed; font-size: 14px;" lang="x-western">
Hi all,
<br>
<br>i just started with GeoExt and OL, so its probably an easy (maybe 
stupid
<br><span title=";)"><span>;)</span></span> ) 
question. I already tried a lot of different code, but i don&#39;t get
<br>it working. Maybe someone can give me a hint.
<br>
<br>What i did is, i already got my application working with OSM as
<br>Baselayers and an GML with POI as an overlay. The GML is stored in 
an
<br>GridPanel, so i can select the POI over the map or the Panel. All 
fine,
<br>thanks to all the tutorials!
<br>Now i want OL to zoom to my POI when clicked. With the code below it
<br>zooms to the POI, but not in the middle. When i use map.setCenter, 
it
<br>zooms in the right direction but my POI are in the right or left 
corner
<br>of my map. When i use map.zoomToExtent(new OpenLayers.Bounds()) it 
zooms
<br>somewhere to the south-pole <span title=";)"><span>;)</span></span>. 
 As you can see i tried some different
<br>functions but it won&#39;t work.
<br>
<br>My second question is, how can i close (hide) the Popup, when a new 
POI
<br>is selected, at the moment you have to close them by your own. Some 
Code
<br>Snippets or advise would be perfect. If you need some more of my 
code
<br>just tell me.
<br>
<br>Thanks for any help!
<br>
<br>Ben
<br>
ps: sorry for possible double post, i don&#39;t know why my E-Mail from Saturday
 was not mailed to the list.<br>
<a rel="nofollow" href="http://www.geoext.org/pipermail/users/2010-June/000975.html" target="_blank">http://www.geoext.org/pipermail/users/2010-June/000975.html</a><br>
<br>
<br>--------Part of my Code---------------
<br>//Load GML
<br>                 layer = new 
OpenLayers.Layer.GML(&#39;GML&#39;,&#39;./daten/ows.gml&#39;, {
<br>                 projection: new OpenLayers.Projection(&quot;EPSG:4326&quot;),
<br>                 styleMap: ebbMap
<br>                 });
<br>
<br>
<br>//POPUP
<br>// create select feature control
<br>      var selectCtrl = new OpenLayers.Control.SelectFeature(layer);
<br>     var lonlat;
<br>     function createPopup(feature) {
<br>         popup = new GeoExt.Popup({
<br>             title: &#39;Kneipen Infos&#39;,
<br>             feature: feature,
<br>             width:250,
<br>             height:100,
<br>             html:  &quot;&lt;h2&gt;  Name: &quot; +<a rel="nofollow" href="http://feature.attributes.name" target="_blank">feature.attributes.name</a> + 
&quot;&lt;/h2&gt;
<br>Stadtteil: &quot; + feature.attributes.stadtteil, //Definition der 
Attribute
<br>             maximizable: false,
<br>             collapsible: true,
<br>             //lonlat: 
feature.geometry.getBounds().getCenterLonLat(),
<br>             //lonlat: feature.geometry.getCenterLonLat(),
<br>             //lonlat: feature.geometry.getBounds(),
<br>             listeners: {
<br>                &quot;close&quot;: function() {
<br>                 selectCtrl.unselect(this.feature);
<br>                 }
<br>                         }
<br>             },
<br>             //map.setCenter(new OpenLayers.LonLat(), 18)
<br>             //map.setCenter(new OpenLayers.Geometry.getCentroid(), 
18)
<br>             //map.zoomToExtent(new OpenLayers.Bounds(lonlat), 18)
<br>             map.setCenter(new OpenLayers.LonLat(), 18)
<br>
<br>             );
<br>         // unselect feature when the popup
<br>         // is closed
<br>         popup.on({
<br>             close: function() {
<br>                 if(OpenLayers.Util.indexOf(layer.selectedFeatures,
<br>                                            this.feature)&gt;  -1) {
<br>                     selectCtrl.unselect(this.feature);
<br>                 }
<br>             }
<br>         });
<br>         popup.show();
<br>     }
<br>
<br>             // create popup on &quot;featureselected&quot;
<br>             layer.events.on({
<br>                 featureselected: function(e) {
<br>                     createPopup(e.feature)
<br>
<br>                 }
<br>             });
<br>
<br>         /* On unselection the GeoExt-Popup closes */
<br>         function onFeatureUnselect(event) {
<br>             popup.destroy();
<br>             }
<br>
<br></div>
</div></div></div></div>
</div><br></div></blockquote></div><br>