Identify - Identifiable not working

Hi

Are per a previous post, there seems to be no ActiveLayer for vba, but I can do without this. I load a number of layers and only want the identify to work on certain layers. I read that the default for identifiable is false, but it still seems to be identifying on the layer. I have an Operational Entity polygon layer that is always at position 0. It always brings this up when I loop through the ShapesIdentified and I set it myself to shpOpEntity.Identifiable = False. I have a lot of layers loading but have only set ShpRdLineBackground when I test as it seems to ignore this anyway

see code
shpRdLineBackground.Identifiable = True
Set shpOpEntity.Identifiable = False
With Map1.Identifier
.IdentifierMode = tkIdentifierMode.imAllLayers
.OutlineColor = RGB(0, 0, 255)
.HotTracking = False
End With

In the following sub
Private Sub Map1_ShapeIdentified(ByVal LayerHandle As Long, ByVal shapeIndex As Long, ByVal pointX As Double, ByVal pointY As Double)
I loop through the IdentifiedShapes and go different things for each Layer I find

eg sample

Set shapes = Map1.IdentifiedShapes
For i = 0 To shapes.Count - 1
hnd = shapes.LayerHandle(i)
If hnd = 0 Then
GoTo NextLoop
End If
If hnd = hndAccidents Then
fieldIndex = shpAccidents.Table.FieldIndexByName(“LocnCode”)
Me![LocationCode] = shpAccidents.CellValue(fieldIndex, shapes.shapeIndex(i))
DoCmd.OpenForm “DisplayLocnAccsForm”
Exit Sub
End If
Whole lot more tests
Next

I ignore hnd = 0 as this is my Operational Entity Layer that it still seems to be finding. Also when I highlight the shape eg an Accident Location, it also highlights the Operational Entity Layer below this and I can’t remove the highlighting. I tried to remove this by setting HotTracking to false, but it still highlights. I like the highlight of the Accident Location, but not the polygon behind.

Thanks for any help you can give me.

Regards

Colleen Crawford

Hello Colleen.

  1. Looking at the source code, it looks like Identifiable is True by default, AND IdentifierMode = imAllLayers. I will have to review and update the documentation.
  2. The HotTracking property is a special mode in which features are identified and highlighted just by moving the mouse over them, rather than clicking. So you do want this False.
  3. It does seem strange that you get back layers that are not flagged as Identifiable. I’ll have to see if I can duplicate this behavior.

In your case, I think you should try setting IdentifierMode = imSingleLayer

    With Map1.Identifier
        .IdentifierMode = tkIdentifierMode.imSingleLayer
        .OutlineColor = RGB(0, 0, 255)
        .HotTracking = False
    End With

When you do this, you indicate which layer to Identify by handling the ChooseLayer event, as such:

Private Sub Map1_ChooseLayer(sender As Object, e As _DMapEvents_ChooseLayerEvent) Handles Map1.ChooseLayer
    e.layerHandle = hndAccidents
End Sub

See if this solves your problems.

Jerry.

Hi Jerry

This works very well, the only problem is that I sometimes have say 4 layers loaded and I want to identify on the closest shape and then set the LayerHandle to this Layer. I tried using the XProj and yProj from the ChooseLayer event (Private Sub Map1_ChooseLayer(ByVal xProj As Double, ByVal yProj As Double, LayerHandle As Long). I can’t seem to get this to get the closest shapes. I did notice that xProj and yProj are slightly different to the X/Y Coords that are displayed on the Map.

I then thought maybe I need to capture the x/y coords from the Mousedown event, but that needs cursormode = cmNone to work. I am sure there is an easy way to do this. I probably should be looping through all the returned layers when using imAllLayers but it has the issues of highlighting background shapes.

regards

Colleen Crawford

Hello Colleen.

I’m not sure I understand what you mean by the ‘closest’ layer. If you’re not directly above a shape, it will not be identified. But is that what you want, is to be able to Identify a shape that is ‘close’ to the mouse, but not directly below? If so, this would be custom behavior.

One thing that occurred to me (and I just realized that it is not in the current documentation) is that there’s a third option for tkIdentifierMode, specifically tkIdentifierMode.imAllLayersStopOnFirst. This setting is similar to All Layers except that it will stop searching on the first layer it encounters with a shape below the mouse.

Regards,
Jerry.

Thanks, I knew I was overcomplicating this. I was thinking that it was like Map Objects that would find all the shapes. I will try the imAllLayersStopOnFirst as this seems to be what I want. I’m assuming if I am clicking directly on a road, it will get this before the Area polygon underneath and if I want the Area Polygon, I just click somewhere on the Area where there are no other shapes.

Regards

Colleen

Colleen.

Yes, what you say is correct. It should be from the topmost layer on down, stopping at the first one it finds.

Hi

It works brilliantly for points and lines, but if the user has loaded a polygon as well, then when you click on a line or point in the polygon, it gets the polygon first. It does not matter if I load the polygon first or last it still behaves like this, which is strange as when a point is on a road, if I click on the point then it gets the point and not the Road. Not quite sure how I am going to get around this besides telling the User that they need to unload all polygons before identifying or doing it some other way.

Regards

Colleen

Hello Colleen.

I just loaded a test program, and I’m not able to reproduce this behavior. I wonder if something else is going on? (although I don’t know what). I presume that you’re zoomed in close enough so that the tolerance allows for finding the point or line?

If you want to either submit that section of code? or submit the layers? I’ll see if I see anything. But it should work. :wink:

Jerry.

Hi

Thanks, after reading this I went and tried again and have figured out the following, all polygons must be at the back, then lines, then points. I was moving my Road Layer to the back so that points were not covered, so now I work out where the Road Layer should go depending on how many polygons are loaded and I move the polygons to the back, just above my filled in background polygon. It works most of the time. Something to note, the background layer is set to identifiable = false and when I use imAllLayersStopOnFirst or imSingleLayer it correctly does not highlight this polygon for identifying, but when imAllLayers is chosen it ignores the identifiable = false and still highlights the layer.

Thank you for your help

Regards

Colleen