how to remove vector feature?

body onload the map 
after that click drop down menu(onchange) remove it.
but i cant remove feature

any mistake with my code?
thanks~~!!

sample code as below:
 
*javascript*


var map, layer;
        //var url =
"http://data.mapguide.com/mapguide/mapagent/mapagent.fcgi?USERNAME=Anonymous&";;
        //you can use this URL when MapGuide OS is installed locally
        var url = "http://localhost:8008/mapguide/mapagent/mapagent.fcgi";;
        
        //Adjust the scale assumptions for MapGuide layers
        //Tiled layers MUST use a DPI value of 96, untiled layers can use a 
        //different DPI value which will be passed to the server as a parameter.
        //Tiled and untiled layers must adjust the OL INCHES_PER_UNIT values
        //for any degree-based projections.
        var metersPerUnit = 1;  //value returned from mapguide
        var inPerUnit = OpenLayers.INCHES_PER_UNIT.m * metersPerUnit;
        OpenLayers.INCHES_PER_UNIT["dd"] = inPerUnit;
        OpenLayers.INCHES_PER_UNIT["degrees"] = inPerUnit;
        OpenLayers.DOTS_PER_INCH = 96;    
        

        function init() {
        
          var extent = new OpenLayers.Bounds(-180,-80,180,80);
          var mapOptions = {
                        maxExtent: extent,
                        controls: [
                                new OpenLayers.Control.Navigation(),
                                new OpenLayers.Control.PanZoomBar(),
                                new OpenLayers.Control.MousePosition()
                        ]
          };

          
          map = new OpenLayers.Map( 'map', mapOptions );


          var options = {
                 singleTile: true,
                 isBaseLayer: true,
                 visibility: true,
                 /* useAsyncOverlay: true, */ //<- remove
                 //useOverlay:true
          };

  
          var params = {
                  mapdefinition: 'Library://sample/Maps/sample.MapDefinition'
          };


          
          var layer = new OpenLayers.Layer.MapGuide( "sample", url, params, 
options
);
          map.addLayer(layer);


          var vectorLayer = new OpenLayers.Layer.Vector("vector layer1");
                var feature = new OpenLayers.Feature.Vector(
                 new OpenLayers.Geometry.Point(180,80),
                 {some:'data'},
                 {externalGraphic: 'images/car1.png', graphicHeight: 21, 
graphicWidth:
16});
                vectorLayer.addFeatures(feature);
                map.addLayer(vectorLayer); 



          map.addControl(new OpenLayers.Control.LayerSwitcher());
          map.zoomToMaxExtent();
          map.setCenter(new OpenLayers.LonLat(180,80), 4);

}


function remove(sel){
        vectorLayer.removeFeatures(feature);    
}






*html part*
<body onload="init();">

<div>
        
<select id="sel" name="sel"
onchange="remove(this.value)"><option></option><option
value="Y">Remove</option></select>


<div id="map" >   
</div>

</div>  

</body>





--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/remove-feature-problem-tp5001007.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to