Eric,<div><br></div><div>If I understand you correctly, every instance of feature.something, should now be evt.feature.something?<br><br><div class="gmail_quote">On Sun, Aug 16, 2009 at 8:00 PM, Eric Lemoine <span dir="ltr"><<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">On Sunday, August 16, 2009, Nicholas Efremov-Kendall<br>
<div class="im"><<a href="mailto:n.e.kendall@gmail.com">n.e.kendall@gmail.com</a>> wrote:<br>
> Hi all,<br>
> I'm having some issues with my code, and I'm not sure where the problem lies. This code worked at one point, and I've been staring at it for too long to see the problem. Two firebug errors fire when I click on one of the POI's "feature.geometry is undefined" and "popup is undefined". Any suggestions?<br>
><br>
><br>
> var map, layer, selectedFeature, selectControl, selectedFeature, sites;function onPopupClose(evt) { selectControl.unselect(selectedFeature); }<br>
><br>
> function onFeatureSelect(feature) { selectedFeature = feature;<br>
<br>
</div>"featureselected" listeners do not receive a feature but an object<br>
with a feature property referencing the selected feature. So your code<br>
should look like this:<br>
<br>
function onFeatureSelect(evt) {<br>
selectedFeature = evt.feature;<br>
...<br>
}<br>
<br>
cheers,<br>
<div><div></div><div class="h5"><br>
<br>
<br>
<br>
> popup = new OpenLayers.Popup.FramedCloud("chicken", feature.geometry.getBounds().getCenterLonLat(),<br>
> null, "<div style='font-size:.8em'>Site_ID: " + feature.attributes.title +"<hr />Locality: " + feature.attributes.title+"<br/>Description: " +feature.attributes+"<br/> Feature ID: "+<a href="http://feature.id" target="_blank">feature.id</a>+"<br/>Feature Type:"+feature.attributes.NEWSITE_ +"</div>",<br>
> null, true, onPopupClose); feature.popup = popup; map.addPopup(popup); }<br>
> function onFeatureUnselect(feature) { map.removePopup(feature.popup); feature.popup.destroy(); feature.popup = null;<br>
> }<br>
> function init() { map = new OpenLayers.Map ("map",<br>
> { controls:[ new OpenLayers.Control.Navigation(),<br>
> new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.LayerSwitcher(),<br>
> new OpenLayers.Control.Attribution()], sphericalMercator: true, maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),<br>
> maxResolution: 156543.0399, numZoomLevels: 19, units: 'm',<br>
> projection: new OpenLayers.Projection("EPSG:900913"), displayProjection: new OpenLayers.Projection("EPSG:4326"),<br>
> } );<br>
> var sites = new OpenLayers.Layer.GML ( "Archaeological Sites", "data/siteswatr.gml",<br>
> { style: {pointRadius: 2.5}, projection: new OpenLayers.Projection("EPSG:4326"),<br>
> format: OpenLayers.Format.GML } );<br>
> map.addLayer(sites);<br>
> sites.events.on({ 'featureselected': onFeatureSelect,<br>
> 'featureunselected': onFeatureUnselect });<br>
><br>
> selectControl = new OpenLayers.Control.SelectFeature(sites, {clickout: true, toggle: false, hover: false,<br>
> } ); map.addControl(selectControl);<br>
> selectControl.activate();<br>
> if( ! map.getCenter() ){ sites.events.register('loadend', sites, function(){map.zoomToExtent(sites.getDataExtent())});<br>
> map.setCenter(null, null); };}<br>
> --<br>
> Nicholas Efremov-Kendall<br>
> Fulbright Student 2009-2010, Ukraine<br>
> <a href="mailto:nefremov@artsci.wustl.edu">nefremov@artsci.wustl.edu</a><br>
> c/o Halyna Yerko<br>
> Balzaka 92a, Kv 27<br>
> 02232<br>
> Kyiv, Ukraine<br>
> (mob) +380963576524<br>
><br>
><br>
<br>
</div></div>--<br>
Eric Lemoine<br>
<br>
Camptocamp France SAS<br>
Savoie Technolac, BP 352<br>
73377 Le Bourget du Lac, Cedex<br>
<br>
Tel : 00 33 4 79 44 44 96<br>
Mail : <a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a><br>
<a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Nicholas Efremov-Kendall<br>Fulbright Student 2009-2010, Ukraine<br><a href="mailto:nefremov@artsci.wustl.edu">nefremov@artsci.wustl.edu</a><br>c/o Halyna Yerko<br>Balzaka 92a, Kv 27<br>
02232<br>Kyiv, Ukraine<br>(mob) +380963576524<br>
</div>