[OpenLayers-Users] Detecting a click in a feature

Eric Lemoine eric.c2c at gmail.com
Fri Feb 22 11:19:20 EST 2008


On Fri, Feb 22, 2008 at 2:07 PM, Carlos Pinto <cmspinto at gmail.com> wrote:
> Hi all,
>
> I was using google maps and last week I decided to use OpenLayers, so I'm
> quite a new user.
>
> So now I'm changing all my code to OpenLayers, but I have this problem that
> I was adding features from a database and then I was showing the balloons
> with the description.
>
> Now I want to show it in a table that it is outside the map. But can anybody
> advise me what is the best way to add features from the database (they can
> be hundreds of polygons),

You can possibly use MapServer as a WFS server and use
OpenLayers.Layer.WFS. For that, your data needs to be in database
MapServer can read from (e.g. Postgresql/Postgis).

> I have try to use GML and the text file, but once
> they are in the map I can not detect when a feature was clicked, I was using
> this code:
>
>
>
>             function init(){
>             var mylayer =   new OpenLayers.Layer.GML("GML",
> "../KML/MyPolygon.xml");
>                map.addLayer(mylayer);
>
>             selectControl = new OpenLayers.Control.SelectFeature(mylayer,
>                  {onSelect: onFeatureSelect, onUnselect:
> onFeatureUnselect});
>             selectControl.activate();
>           }
>
>
> But doens't work, does anybody knows why?

Your code looks perfectly correct to me. What OL version are you using?

--
Eric



More information about the Users mailing list