Hi, See the example (1). Use firebug to see the new requests sent (I'm getting an error 404 on the example, but only looking at the requests should be enough for you to understand what the BBOX does). When you zoom in, since the new extent is within the previous one, no request needs to be sent, but if you zoom out or pan, an new request is sent.
So it would not be enough for you. You could register your "beforefeatureselected" event, keep the feature in a variable, move the map to the extent of the feature. If the BBOX strategy invalidated the bounds, that means that a new request will be sent resulting to new feature drawn. So, the feature you have in your variable don't exists anymore on your layer, but you still have access to its attributes (feature.attributes, see in firebug). If they have a key attribute, you could use it to get your feature on your layer and force your selection. If the BBOX didn't change the bounds, the original feature should still exist so there's nothing needed to be done. I may have missed some important details but you should have enough stuff to start somewhere. Take a look at the examples to learn more and don't forget to use firebug. It's a great teacher. Regards, Alexandre (1) http://openlayers.org/dev/examples/strategy-bbox.html oatley wrote: > Alexandre, > Thanks for your reply. > > Can you explain the BBOX strategy a little more? It sounds like it will do > the trick, but I am still new to OpenLayers. It sounds like the zoom level > would change if I set the extent. (Or am I wrong?) I would just like it to > pan, similar to how the Popup pans, in order to get it into view. > > Shawn > > > Alexandre Dube wrote: > >> Hi, >> >> You could register a "beforefeatureselected" event on your vector layer >> and set the map extent according to the feature's extent. I think that >> if you use the BBOX strategy, since the feature was already drawn it >> should remain the same when the map automatically pan/zoom to the >> feature's extent. >> >> What do you think ? >> >> Alexandre >> >> soatley wrote: >> >>> Hello, >>> >>> Does anyone know how to have the map pan when adding a feature to a >>> vector >>> layer so that the entire feature is in view? >>> >>> Here's my code so far that works: >>> //define the popup >>> infoPopup = new OpenLayers.Popup.FramedCloud("info", >>> mouseLoc, >>> null, >>> "<div >>> style=\"padding:5px;font-size:0.8em;\">Loading...</div>", >>> null, true, onPopupClose); >>> map.addPopup(infoPopup); >>> >>> //load the url for the popup data >>> OpenLayers.loadURL(infoUrl, '', this, showTip); >>> >>> >>> In the showTip function, I parse the data that is returned, update the >>> content popup and create a feature. The feature coordinates (WKT) are >>> passed with the response. >>> >>> var f = new OpenLayers.Format.WKT(); >>> infoFeature = f.read(marker.find("points").text()); >>> infoLayer.addFeatures([infoFeature], { style: "default" }); >>> infoPopup.contentHTML = marker.find("result").text(); >>> infoPopup.setContentHTML(); >>> infoFeature.popup = infoPopup; >>> >>> This code works great. If the popup is off the screen it pans into view. >>> Great! But, how can I do the same if the feature (a parcel) is partially >>> off the screen? >>> >>> >>> >>> >> -- >> Alexandre Dubé >> Mapgears >> www.mapgears.com >> >> _______________________________________________ >> Users mailing list >> [email protected] >> http://openlayers.org/mailman/listinfo/users >> >> >> > > -- Alexandre Dubé Mapgears www.mapgears.com _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
