public void searchById ( final FeaturesSupported layer , final String [ ] ids , final FeatureArrayCallback callback ) { Layer < ? > gwtLayer = map . getMapWidget ( ) . getMapModel ( ) . getLayer ( layer . getId ( ) ) ; if ( gwtLayer != null && gwtLayer instanceof VectorLayer ) { VectorLayer vLayer = ( VectorLayer ) gwtLayer ; SearchCriterion [ ] criteria = new SearchCriterion [ ids . length ] ; for ( int i = 0 ; i < ids . length ; i ++ ) { criteria [ i ] = new SearchCriterion ( SearchFeatureRequest . ID_ATTRIBUTE , "=" , ids [ i ] ) ; } SearchFeatureRequest request = new SearchFeatureRequest ( ) ; request . setBooleanOperator ( "OR" ) ; request . setCrs ( map . getMapWidget ( ) . getMapModel ( ) . getCrs ( ) ) ; request . setLayerId ( vLayer . getServerLayerId ( ) ) ; request . setMax ( ids . length ) ; request . setFilter ( layer . getFilter ( ) ) ; request . setFeatureIncludes ( GeomajasConstant . FEATURE_INCLUDE_ALL ) ; request . setCriteria ( criteria ) ; GwtCommand command = new GwtCommand ( SearchFeatureRequest . COMMAND ) ; command . setCommandRequest ( request ) ; GwtCommandDispatcher . getInstance ( ) . execute ( command , new AbstractCommandCallback < SearchFeatureResponse > ( ) { public void execute ( SearchFeatureResponse response ) { if ( response . getFeatures ( ) != null && response . getFeatures ( ) . length > 0 ) { Feature [ ] features = new Feature [ response . getFeatures ( ) . length ] ; for ( int i = 0 ; i < response . getFeatures ( ) . length ; i ++ ) { features [ i ] = new FeatureImpl ( response . getFeatures ( ) [ i ] , layer ) ; } callback . execute ( new FeatureArrayHolder ( features ) ) ; } } } ) ; } }
Search features within a certain layer using the feature IDs .