Howard,
Thanks for reply.
I checked the code, it works fine on Map1_Click(..) event. I got features count for selected point on a map.
But I need it to display as ToolTip on mouse hover on any feature layer using client side. I don’t want to display toop tip on map click.
Below is code that works on map click event.
//===========================================
// get the click position.
PointShape clickWorldPosition = e.Position;
// convert to screen point.
ScreenPointF clickScreenPoint = Map1.ToScreenCoordinate(clickWorldPosition);
// 5 is the radius to buffer the click point.
ScreenPointF clickNextScreenPoint = new ScreenPointF(clickScreenPoint.X + 5, clickScreenPoint.Y);
// calculate the distance is world coordinate of the radius.
double worldDistance = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(Map1.CurrentExtent, clickScreenPoint, clickNextScreenPoint, (float)Map1.WidthInPixels, (float)Map1.HeightInPixels, GeographyUnit.Meter, DistanceUnit.Meter);
// calculate the buffer which you need.
MultipolygonShape clickArea = clickWorldPosition.Buffer(worldDistance, GeographyUnit.Meter, DistanceUnit.Meter);
ShapeFileFeatureLayer Lyr_Access_Point = (ShapeFileFeatureLayer)((LayerOverlay)Map1.CustomOverlays[0]).Layers["Lyr_Access_Point"];
Lyr_Access_Point.Open();
Collection<Feature> features = Lyr_Access_Point.QueryTools.GetFeaturesIntersecting(clickArea, ReturningColumnsType.AllColumns);
if (features.Count > 0)
{
callbackResult = features[0].ColumnValues["Type_Name"];
}
//===============
I tried following code to show tooltip on clinet side into RaiseCallbackEvent(string eventArgument), but got error.
I converted eventArgument to PointShape.. that did not worked… I got error at following line
double worldDistance = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(Map1.CurrentExtent, clickScreenPoint, clickNextScreenPoint, (float)Map1.WidthInPixels, (float)Map1.HeightInPixels, GeographyUnit.Meter, DistanceUnit.Meter);
Error:
Map1.WidthInPixels & Map1.HeightInPixels value only available after postback.
Here is code..
public void RaiseCallbackEvent(string eventArgument)
{
string[] lonlatStrings = eventArgument.Split(',');
// get the click position.
PointShape clickWorldPosition = new PointShape(double.Parse(lonlatStrings[0]), double.Parse(lonlatStrings[1]));
// convert to screen point.
ScreenPointF clickScreenPoint = Map1.ToScreenCoordinate(clickWorldPosition);
// 5 is the radius to buffer the click point.
ScreenPointF clickNextScreenPoint = new ScreenPointF(clickScreenPoint.X + 5, clickScreenPoint.Y);
// calculate the distance is world coordinate of the radius.
double worldDistance = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(Map1.CurrentExtent, clickScreenPoint, clickNextScreenPoint, (float)Map1.WidthInPixels, (float)Map1.HeightInPixels, GeographyUnit.Meter, DistanceUnit.Meter);
// calculate the buffer which you need.
MultipolygonShape clickArea = clickWorldPosition.Buffer(worldDistance, GeographyUnit.Meter, DistanceUnit.Meter);
ShapeFileFeatureLayer Lyr_Access_Point = (ShapeFileFeatureLayer)((LayerOverlay)Map1.CustomOverlays[0]).Layers["Lyr_Access_Point"];
Lyr_Access_Point.Open();
Collection<Feature> features = Lyr_Access_Point.QueryTools.GetFeaturesIntersecting(clickArea, ReturningColumnsType.AllColumns);
if (features.Count > 0)
{
callbackResult = features[0].ColumnValues["Type_Name"];
}
}
Thanks
Hiren