[OpenLayers-Users] Add Feature and Pan into View
soatley
shawn at niagarafalls.ca
Thu May 21 14:02:42 EDT 2009
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
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
--
View this message in context: http://n2.nabble.com/Add-Feature-and-Pan-into-View-tp2952437p2953370.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list