Display a label using IlvMakeMeasureInteractor when 2 points are really close to each other

Article ID: 2428
Last updated: 30 May, 2018
Article ID: 2428
Last updated: 30 May, 2018
Revision: 3
Views: 491
Posted: 19 Apr, 2012
by Dean J.
Updated: 30 May, 2018
by Gargani A.

Question

How to display a label using IlvMakeMeasureInteractor when 2 points are really close to each other ?

Answer

The label on the IlvMapOrthodromyPath object is represented by either IlvMapLineLabel or IlvMapAreaLabel depending on the style being set on the path. And the parameter that determines when the label should be displayed is the static ParameterRecord object of the IlvMapXXXLabel.

In order to override this behavior, you need to intercept the IlvMapDefaultLabeler.createLabels to change the ParameterRecord of the label object.

In your View() constructor, add the following before creating your IlvMakeMeasureInteractor():

IlvMapDefaultLabeler labeler = new IlvMapDefaultLabeler() 

public IlvMapLabelingLabel[] createLabels(IlvGraphic graphic, String message) { 
IlvMapLabelingLabel [] labels = super.createLabels(graphic, message); 
for( IlvMapLabelingLabel label : labels) 

if( label instanceof IlvMapAreaLabel ) 

IlvMapAreaLabel mapLabel = (IlvMapAreaLabel) label; 

ilog.views.maps.label.IlvMapAreaLabel.ParameterRecord record = mapLabel.getDefaultParameters(mapLabel.getLabelStyle()); 
record.polylineThreshold = 1; 

else { 
IlvMapLineLabel mapLabel = (IlvMapLineLabel) label; 

ilog.views.maps.label.IlvMapLineLabel.ParameterRecord record = mapLabel.getDefaultParameters(mapLabel.getLabelStyle()); 
record.minPolylineRadius = 1; 
record.followPath = false; // this only works when the label is not displayed along the path 


return labels; 

}; 

IlvMapLabelerProperty prop = new IlvMapLabelerProperty(labeler); 
view.getManager().setNamedProperty(prop); // ensure that your custom IlvMapDefaultLabeler will be used.

Sample code: src.zip

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2428
Last updated: 30 May, 2018
Revision: 3
Views: 491
Posted: 19 Apr, 2012 by Dean J.
Updated: 30 May, 2018 by Gargani A.
Attached files

Also listed in


Others in this category