Hi
I have a layer with many points. And when I put on a text style it gets very cluttered.
Is is possible to define a text style so that it only activates when either the user clicks on the point or the cursor hovers over the point?
thanks
Murray
Show text style on hoverover
Hi Murray,
Thanks for your post
one suggestion could be to put all the points inside layer1, and layer1 doesn’t set a textstyle, and when the customer clicks on the map we could use “Feature ClickedFeature=Layer1.FeatureSource.GetFeaturesNearestTo(clickPosition, GeographyUnit.DecimalDegree, 10, new string[] { }, 10, DistanceUnit.Kilometer);” in MapClick Event to find the ClickedFeature.
Then put ClickedFeature into Layer2, and Layer2 has textstyle to show the ClickedFeature text.
This way, only the clicked feature’s text will be shown.
if you have any more question , please feel free to let us know.
Best Regards
Summer
Hi Summer
I implemented the following code as you suggested
var ClickedFeature =
((InMemoryFeatureLayer) layer).FeatureSource.GetFeaturesNearestTo(e.WorldLocation,
MapUnit, 10,
new string[] {}, 10,
DistanceUnit.Kilometer).FirstOrDefault();
_pointsLayer.Open();
_pointsLayer.InternalFeatures.Clear();
_pointsLayer.InternalFeatures.Add(ClickedFeature);
And this does get me a feature returned. However when the feature is found it contains no column values. ( the original feature does) which means the text has nothing to show.
Is this a bug?
Surely it should just pass the orig feature across
regards
Murray
Hi Murray,
Thanks for your query and sorry for the inconvenience, Would you please replace :
((InMemoryFeatureLayer) layer).FeatureSource.GetFeaturesNearestTo(e.WorldLocation,MapUnit, 10,new string[] {}, 10,
DistanceUnit.Kilometer).FirstOrDefault();
With
((InMemoryFeatureLayer)layer).FeatureSource.GetFeaturesNearestTo(e.WorldLocation, MapUnit,1,((InMemoryFeatureLayer)layer).InternalFeatures[0].ColumnValues.Keys,10, DistanceUnit.Kilometer)[0];
Now it should work.
if you have any more question , please feel free to let us know.
Best Regards
Summer
Hi Simon
That did work. But for some reason I can’t make it show the text.
The point is found and it does have the data. It is added to the new layer but for some reason it does not show the text even though the style is set.
I know it must be something I am doing wrong but I can’t work out what.
I did orig have the style code separate but can you see what I am doing wrong below?
var ClickedFeature = ((InMemoryFeatureLayer)layer).FeatureSource.GetFeaturesNearestTo(e.WorldLocation, MapUnit, 1, ((InMemoryFeatureLayer)layer).InternalFeatures[0].ColumnValues.Keys, 10, DistanceUnit.Kilometer)[0];
_pointsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Country1(
“Name”
);
_pointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
_pointsLayer.Open();
_pointsLayer.InternalFeatures.Clear();
_pointsLayer.InternalFeatures.Add(ClickedFeature);
_pointsOverlay.Refresh();
thanks
Murray
Hi Murray,
Thanks for your query, attahced sample could show a basic idea to sort it out, would you please check it?
Hope it helps
Summer
Post11376.txt (2.49 KB)