Hi ,
I have Feature and i want to add Popup on that feature.I am able to add popup in case of Latitude and longitude but i am facing problem in case of when getting feature .Please suggest me or if anyone have code please share me.
Regards:
Rupesh
Add Popup on Selecte Feature
Hi Rupesh,
I think you can find a sample named AddSimpleMarkers in our HowDoISamples, which maybe helpful for you.
You can also view the other samples in it which related with "marker".
Regards,
Don
Hi Rupesh, I went though the same difficulty. I found the demo code to be useless and had to find my own solution. Here is how I arrived at our solution. I hope it helps. Sorry I am doing this in VB.NET because our project is VB.
First, I created a Mouse Click event handler for the map in my code.
Private
Sub
mapCtrl_MouseClick(sender
As
Object
, e
As
MouseEventArgs)
Handles
mapCtrl.MouseClick
'Code Goes Here
End
Sub
I then added code to detect the right mouse click.
If
e.Button = Windows.Forms.MouseButtons.Right
Then
'Code Goes Here
End
If
Then I added code to get my mouse position.
Dim
p
As
PointShape = ExtentHelper.ToWorldCoordinate(mapCtrl.CurrentExtent,
New
ScreenPointF(e.X, e.Y), mapCtrl.Width, mapCtrl.Height)
I would then loop through all of my InMemoryFeatureLayers and query for any features within 5 meters of my mouse pointer. You can then place your own code to handle the returned features however you like. In my case I dynamically built a Context Menu and set it’s location to the mouse pointer’s location. If for some reason there are more than one feature within 5 meters I show a popup asking to choose between the features that were found. I then show the menu from there.
For
Each
imfl
As
InMemoryFeatureLayer
In
layers
Dim
features
As
Collection(Of Feature) = imfl.QueryTools.GetFeaturesWithinDistanceOf(p, GeographyUnit.Meter, DistanceUnit.Meter, 5, ReturningColumnsType.AllColumns)
'Code goes here to handle the features collection and show context menu or the like
Next
Here is how you can get set the location of a context menu to the mouse location. This returns a point that can be used to set the location of the control.
mapCtrl.PointToScreen(
New
Point(e.X, e.Y))
I hope this was helpful. This is how it looks in our application.
Hi Dave,
Thanks for your share, that should be very helpful for Rupesh.
Regards,
Don