Hi All,

I'm getting some strange behavior with the select and highlight feature
select controls. This maybe sloppy, but yesterday this "worked" fine, (i.e.
the sites highlighted when moused-over and popups appeared). Today, the
sites highlight to a light blue, and sometimes stay highlighted, and no
popups appear. Not sure what's going on.

here's my code. I'm using the url to the api rather than a local file.

var map, controls, selectControl, selectedFeature;
function init() {
            map = new OpenLayers.Map ("map",
                    {
                    controls:[
                    new OpenLayers.Control.Navigation(),
                    new OpenLayers.Control.PanZoomBar(),
                    new OpenLayers.Control.LayerSwitcher(),
                    new OpenLayers.Control.Attribution()],
                sphericalMercator: true,
                maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
                maxResolution: 156543.0399,
                numZoomLevels: 19,
                units: 'm',
                projection: new OpenLayers.Projection("EPSG:900913"),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),
                    }
            );
            var myBaseLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
        "http://labs.metacarta.com/wms/vmap0";, {layers: 'basic', projection:
"myproj"} );
         map.addLayer(myBaseLayer);

         var topo = new OpenLayers.Layer.GML("Topography", "data/test4.gml",
{
  projection: new OpenLayers.Projection("EPSG:4326")});
         map.addLayer(topo);


// Selection and hoverstate controls
          var report = function(e) {
                OpenLayers.Console.log(e.type, e.feature.id);
            };

            var highlightCtrl = new OpenLayers.Control.SelectFeature(topo, {
                hover: true,
                highlightOnly: true,
                renderIntent: "temporary",
                eventListeners: {
                    beforefeaturehighlighted: report,
                    featurehighlighted: report,
                    featureunhighlighted: report
                }
            });

   var selectCtrl = new OpenLayers.Control.SelectFeature(topo,
                {clickout: true}
            );

            map.addControl(highlightCtrl);
              map.addControl(selectCtrl);

            highlightCtrl.activate();
            selectCtrl.activate();
//Popups and
        function onPopupClose(evt) {
            selectControl.unselect(selectedFeature);
        }
        function onFeatureSelect(feature) {
            selectedFeature = feature;
            popup = new OpenLayers.Popup.FramedCloud("chicken",

feature.geometry.getBounds().getCenterLonLat(),
                                     null,
                                     "<div style='font-size:.8em'>Feature: "
+ feature.attributes.title +"<br />Area: " +
feature.attributes.newsite_+"<br/>This should do something<br/> This should
do something else</div>",
                                     null, true, onPopupClose);
            feature.popup = popup;
            map.addPopup(popup);
            }
          function onFeatureUnselect(feature) {
            map.removePopup(feature.popup);
            feature.popup.destroy();
            feature.popup = null;
        }

            if( ! map.getCenter() ){
            topo.events.register('loadend', topo,
function(){map.zoomToExtent(topo.getDataExtent())});
            map.setCenter(null, null);
            };
            }
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to