[OpenLayers-Users] strange vector/gml behavior

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Tue Jun 23 13:59:05 EDT 2009


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);
            };
            }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090623/859d851f/attachment.html


More information about the Users mailing list