Hi, following the samples in the downloaded code I wrote some code that lets users add markers.Users can delete the markers by clicking on them. But the code is not working. Click event handler is never entered... The code is shown below...
Actually, the marker_Click event is inherited from Control class of .NET framework, there is a workaround for your requirement, here is the solution for you below:
Hey Yale, I think you missed the point. I am currently using the SimpleMarkerOverlay, but I need to handle the click event of the markers. ... OR have the marker (or simpleMarkerLayer) pass the click event to the shapes underneath. That would work for my needs as well.
I reviewed the attached sample code what the Yale provided, in the sample he added different customize markers to the map control and used the SimpleMarkerOverlay to add them. For your requirements, can you tell us the detail information on how to customize the marker? Currently, I just understand you want to add the click event to each marker, but I don’t know what’s requirements for each marker in the click event, also the marker’s click event is easy to bind as below:
marker1.Click +=new EventHandler(marker1_Click);
So you can add your own code in the click event, if you have any special requirements please let us know we will help you on that,
As Tarkan pointed out in his initial post, the click event is never entered.
When I create the markers I am adding the handler like this: AddHandler tempMarker.Click, AddressOf Marker_Click
and here is my Event Handler: Private Sub Marker_Click(sender As Object, e As EventArgs) Dim tempMarker As Marker Dim apn As String If TypeOf sender Is Marker = True Then tempMarker = CType(sender, Marker) apn = tempMarker.Tag.ToString PerformSearch(apn, "") End If End Sub
PS. The primary reason I need this is certain shapes have markers to indicate certain information, but they need to be able to click on the shape to get at more information. Problem is the marker is in front of the shape and doesn’t seem to respond to anything. I need to be able to handle the marker click event, or the marker needs to pass the click on to the layers below. Either method is fine with me.
I verified that the marker event works as Scott said, it will be fired when we click on the image. I think the issue is that it is somehow difficult to click on the marker to get it fired, as we have to click on the image without exceeding its scope. Following is my test code, you can take a try against it.
One possible solution you can consider is trying to customize the event in the map click event with the query against the markers in the SimpleMarkerOverlay, which is very similar with query against feature layer. In this way, we can customize the way to detect the marker event by finding the nearest marker point.
Your code is absolutely right. And what cause you feel it doesn’t work? It’s because the real point of a marker is very small, you need clicked the point exactly right, then the event will be fire. You can try it by click the marker’s bottom many times.
And because our marker’s event is inherit from Microsoft, so we can’t change it, then we have a workaround to resolve this problem. You can try Scott’s code as below: