[OpenLayers-Users] Search for features, show popup when select
Marc Jansen
jansen at terrestris.de
Wed Jan 20 07:20:01 EST 2010
Hi Herman,
I'd try this at the place where you have your comment in the
rowclick-callback-function:
var popup = new OpenLayers.Popup.FramedCloud(
"chicken",
bounds.getCenterLonLat(),
null,
"<div style='font-size:.8em'>Feature: " + feature.id +"<br />Area: " + feature.geometry.getArea()+"</div>",
null,
true
);
feature.popup = popup;
map.addPopup(popup);
untested, original code from
http://www.openlayers.org/dev/examples/select-feature-openpopup.html
Regards,
Marc
Herman Badenhorst wrote:
>
> Hi group.
>
> What i need to do is display a list of search results in the grid
> panel. When user clicks on a record, highlight the feature and display
> a popup with the feature attributes.
> The code below does all except the popup. How would i go about
> displaying the popup?
>
> Regards,
> Herman
>
> *new* Ext.grid.GridPanel({
>
> title: 'Search results',
>
> region: 'center',
>
> ds: store,
>
> sm: sm,
>
> autoSizeColumns: *true*,
>
> viewConfig: {
>
> forceFit: *true*,
>
> autoFill: *true*
>
>
> },
>
> height: 300,
>
> columns: [{
>
> header: 'mapunit',
>
> dataIndex: 'mapunit',
>
> width: 50
>
> }
>
> ],
>
> listeners: {
>
> 'rowclick': {
>
> 'fn': *function*(grid, index, evt) {
>
> *var* r =
> grid.getStore().getAt(index);
>
> *var* feature = r.get('feature');
>
> *var* a = feature.attributes;
>
>
>
> vectorLayer.destroyFeatures();
>
> vectorLayer.addFeatures(feature);
>
> vectorLayer.redraw();
>
>
>
>
>
> *var* bounds =
> feature.geometry.getBounds();
>
>
> map.setCenter(bounds.getCenterLonLat(),map.getZoomForExtent(bounds));
>
>
>
>
> // popup code goes here?
>
> }
>
> }
>
> },
>
> bbar: [{
>
> text: 'Clear highlight',
>
> handler: *function*() {
>
>
> vectorLayer.removeFeatures(vectorLayer.features);
>
> }
>
> }
>
> })
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
--
Dipl.-Geogr. Marc Jansen
- Anwendungsentwickler -
terrestris GmbH & Co. KG
Irmintrudisstraße 17
53111 Bonn
Tel: ++49 (0)228 / 96 28 99 -53
Fax: ++49 (0)228 / 96 28 99 -57
Email: jansen at terrestris.de
Web: http://www.terrestris.de
Amtsgericht Bonn, HRA 6835
Komplementärin: terrestris Verwaltungsgesellschaft mbH
vertreten durch: Hinrich Paulsen, Till Adams
More information about the Users
mailing list