[OpenLayers-Users] Understanding layers and popups

Alexandre Dube adube at mapgears.com
Fri Jan 16 10:49:31 EST 2009


Hi Gene,

Did you look this example : 
http://openlayers.org/dev/examples/select-feature-openpopup.html

What you're trying to do seems to be displayed there.

You should also look at the draw features example :
http://openlayers.org/dev/examples/draw-feature.html

Also, your vector layer must be on top of all others for this to work. 
Or, layers on top must not be visible or not inRange.

Best of luck,

Alexandre

Gene Sally wrote:
> Hi,
>
> I've been slogging through getting this to work (my map renders on the page now) and I'm having trouble getting my head around how layers and the click/hover callbacks work.  The goal is to get a popup working on arbitrary points added to the map.
>
> I have a map with an Image baselayer and a Vector layer where the features have been added, like so
>
> var newPoint = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point());
> var lonlat = map.getLonLatFromPixel(new OpenLayers.Pixel(x,y));
> newPoint.geometry.x = lonlat.lon;
> newPoint.geometry.y = lonlat.lat;
> targetLayer.drawFeature(newPoint, OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {}));
>
> So far so good!  The points appear in the targetLayer as expected.  (But, when I use the zoom control, they don't zoom with the map, but that's another day's problem...)
>
> I added a OpenLayers.Control.SelectFeature
>
> selectControl = new OpenLayers.Control.SelectFeature(
>                       targetLayer,
>                       {onSelect: onTargetSelect, onUnselect: onTargetUnselect});
> selectControl.activate();
> map.addControl(selectControl);
>
> When click on a newPoint on the map, the reaction is like I'm selecting the baselayer. What I can't figure out is how to make the targetLayer the active layer, as from reading the mail logs, it appears like the SelectFeature works for the active layer.  I've read/reread the sundials.html code (as that's close to the affect I want) and can't figure out what I'm doing wrong.
>
> With Regards,
> gene
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list