Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a refresh feature layer problem, because i need to delete all the markers and add the new markers so i tried this piece of code , but it doesn't work :(

            //refresh
            markers.clear()
            markers.reset();
            markers.removeFeatures(markers.features);
            markers.redraw(true);
            //refresh

            trace(markers.features,"features before");
            trace(Snaps ,"Snaps" );
            for each(var Car in Snaps)
                {
                    var mat = Car[0];
                    var Loc = Car[2];
                    var snap_id = Car[1];
                    var direction = Car[3];
                    //Alert.show(Loc[0]);
                    var marker:CustomMarker = CustomMarker.createUrlBasedMarker("images/markers/iconFlag1up_.png", new Location(Number(Loc[1]),Number(Loc[0])));
                    marker.addEventListener(MouseEvent.CLICK,handlesClickMarker); 
                    marker.name=snap_id;

                    markers.addFeature(marker);//add marker to markers
                }

                trace(markers.features,"features after add");

thanks in advance

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I have solved this problem :)

this is the code that i used :)

            trace(Snaps ,"Snaps" );
            var i = 0 ;
            trace(map.featureLayers.length ,"layers count " );
            trace(map.featureLayers ,"layers  " );

             if(markers == null){
             markers= new FeatureLayer("markers");
             markers.projection = new ProjProjection("EPSG:4326");

             markers.style = Style.getDefaultPointStyle();
             map.addLayer(markers);
             trace("markers layer just has been created " );
             }else
                 markers.removeFeatures(markers.features);

            for each(var Car in Snaps)
                {
                    var mat = Car[0];
                    var Loc = Car[2];
                    var snap_id = Car[1];
                    var direction = Car[3];
                                            var marker:CustomMarker = CustomMarker.createUrlBasedMarker("images/markers/iconFlag1up_.png", new Location(Number(Loc[1]),Number(Loc[0])));
                    marker.addEventListener(MouseEvent.CLICK,handlesClickMarker); /
                    marker.name=snap_id;

                    markers.addFeature(marker);

                }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.