ThinkGeo.com    |     Documentation    |     Premium Support

How to highlight a line?

Hi,

I want to know if there is a buitlin way in ThinkGeo API to outline a line?
I noticed the DrawArea and DrawText both have option to provide fill brush and halo pen but the DrawLine only allow a single outline color so I can’t achieve the highlight effect. I could draw a bigger line underneath as the highlight but I wonder if there is a better way do it.
Below are examples of 3 different lines with different colors but all highlighted with green outlines.

Thanks,
Duy

Thanks Duy,
We use the highlight overlay to handle the highlight. Basically just put a new bigger feature on the top of the original one. Here is a demo to show you how to highlight a polygon. The line should work the same way. DemoProject.zip (3.2 MB)

Thanks

Frank

Hi Frank,

Thanks a lot for the sample code. I wasn’t able to run the project successfully but as I looked into the code, I think the below line of code is what you mentioned about the highlight layer:
highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyle.CreateSimpleAreaStyle(GeoColor.FromArgb(120, GeoColor.FromArgb(255, 56, 200, 21)), GeoColors.LightGray);

If I understand it correctly, you created a special layer that will apply highlight effect (green with light gray outline) to any feature with area style added to the layer. Am I understanding this correctly?

I also noticed the code specifically use the ZoomLevel01, does this mean the effect would only apply to that specific zoom level? If that’s true then what would be the best way to apply the effect to all zoom levels?

Thanks,
Duy

Yes you are correct. Here is a video show you how the sample looks like.

   highlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

This line will apply the effect from zoomlevel1 to 20.

Thanks

Frank

Thank you Frank!

Also, is it possible to make the highlight layer to not interfere with the mouse events (e.g. mouse click) so that the events still go directly to the features of the underneath layer as if the highlight layer doesn’t exist? My concern is with this new highlight layer added on top, the existing features interaction on the underneath layers with mouse events will be affected.

Thanks Duy,
Yes. the highlight layer is a regular InMemoryFeatureLayer. It does not have to bind to the click or mouse over event. For you scenario you just need add the regular highlightLayer and set the default line style instead of the area style.

  InMemoryFeatureLayer highlightLayer = new InMemoryFeatureLayer();
            highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyle.CreateSimpleAreaStyle(GeoColor.FromArgb(120, GeoColor.FromArgb(255, 56, 200, 21)), GeoColors.LightGray);
            highlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay highlightOverlay = new LayerOverlay();
            highlightOverlay.Layers.Add("HighlightLayer", highlightLayer);
            mapView.Overlays.Add("HighlightOverlay", highlightOverlay);

Thanks

Frank

Thank for your helps Frank.

Duy

No problem Duy. Go ahead let us know if you have any more question.

Thanks

Frank