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 am creating a simple text search application, where the user can enter an address search and the result appear in a listbox, which they can then select it and zoom to the address.

Now the problem I am having is that I have set layer definition, within the layer I am working with to only show Residential addresses ( and this works, as i can only see residential addresses in the attribute table), however when I enter a street (in the app), that contains not only residential address, the records appear in my list box when though I have set the layer definition.

Is this behavior normal ? and what is the best way to get round this?

Thanks

share|improve this question

1 Answer 1

up vote 1 down vote accepted

It is a normal behaviour.

You can use IGeoFeatureLayer. It will search only within your definition query.

Dim pGeoFtrLyr As IGeoFeatureLayer
Set pGeoFtrLyr = pMap.Layer(0)

Dim pQueryFilter As IQueryFilter
Set pQueryFilter = New QueryFilter
pQueryFilter.WhereClause = "STNAME = 'Stack Street'"

Dim pFtrCur As IFeatureCursor
Set pFtrCur = pGeoFtrLyr.Search(pQueryFilter, False)

Or you can simply set set your QueryFilter to include the Layer Definition Query too.

share|improve this answer
    
Perfect, thanks! –  Halil Siddique Jul 5 '12 at 12:42

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.