User Tools

Site Tools


map_suite_android_labeling

Map Suite Android Labeling

Video Overview

Labeling
Labeling(Xamarin Forms)

Introduction

In this sample, we show the flexibility of Map Suite Android Edition in labeling parcels, streets, and points of interest. Everything from the number of labels displayed on the screen to the size and color of the labels is customizable. We even show you how to implement your own custom style with our extensible API so you can draw labels exactly how you need them.

Labeling

Label Styling

The Label Styling example has parcels, streets, and POIs to show how all the labeling features work together to create a comprehensive map. The Map Suite Core class “TextStyle” applies to all feature types – points, lines, and polygons.

From the Settings screen, we can customize the style. “Apply Outline Color” creates an outline around the label text so it is more visible. “Apply Background Mask” displays a background behind the POI labels so that they stand out. When “Labels Overlapping Each Other” is selected, labels that would be hidden because they intersect with other labels are displayed. “Grid Size” chops up the display area into cells behind the scenes and only displays one label per cell. If the grid size is small, many labels are displayed; if “Grid Size” is “Large,” few labels will be shown. Change “Duplicate Rule” to “Unlimited Duplicate Labels” and roads can then be labeled multiple times. For example, the road “Mall Ring” will have multiple labels. “Drawing Margin” changes the maximum length of some labels. For example, change it to “15” and see that “Nordstrom’s In-House Café and Coffee Bar” is truncated. Set this parameter to a value greater than “100” to reduce the chance that the label is truncated. A value of “200” or “300” is usually best.

Labeling Points

This example shows how you can control the placement of POI labels to create a clearly labeled map.

From the Style Setting menu, it is possible to modify the location of the label to any one of 9 Placements with customizable X and Y Offsets.

Labeling Lines

This sample demonstrates the importance of splining. Streets and rivers don’t always follow a straight path. Use splining so that the label follows the curves and zig-zags of the feature.

Under the setting “Spline Type,” it’s possible to choose “None,” “StandardSplining,” and “ForceSplining.” When “None” is selected, labels are only displayed in a straight line. This mode has the best performance. “StandardSplining” shows labels that curve with the road and those that can also be displayed without splining. Standard Splining generally looks the best. “ForceSplining” forces the label to be displayed using splining. Usually this is used for Asian languages like Chinese or Japanese. The setting, “Line Segment Ratio” is the maximum ratio of the label to the length of the street required for the label to display. At the default setting of “0.9,” labels that are 90% of the road length or less will be displayed.

Labeling Polygons

This sample shows some of the polygon-based labeling features, like only showing labels that can fit inside their polygon.

If “Fitting Factors Only Within” is selected, only labels that fit inside their polygon are displayed by using the FittingPolygon property. Not all labels that fit inside their polygon are displayed because there are other reasons why labels are hidden. It is also possible to use the FittingPolygonFactor property to set which labels will be displayed based upon their size in relation to the size of the polygon. The setting “Label All Polygon Parts” will label all the parts making up a polygon-based feature.

Custom Labeling

If you don’t like our built-in labeling styles, that’s not a problem. Map Suite is extensible, so you can create your own custom labeling class! In this example, we created a custom class in order to have a minimum and maximum label text size.

A Look at the Code

SplashActivity is the MainLauncher, meaning that it will run when the program is opened and display the splash screen. After checking for the sample data, MainActivity is called. MainActivity.cs includes SliderView, which sets up the sliding menu, and ListView, which is a Xamarin class used to show the Style List in the menu. In the SampleListView_ItemClick function, the currentSample is set to the style that was tapped.

BaseSample is the base class of all the samples. Title sets the header at the top of the screen. MapView is the Map Suite map controller. Each of the style samples have an InitializeMap function that sets up the map for display and an ApplySettings function which runs when “OK” is tapped in the settings dialog. BaseSettingsDialog sets up the setting dialog box and there is a class for each Labeling sample that overrides it to provide the appropriate options. StyleSettings returns the selected settings.

map_suite_android_labeling.txt · Last modified: 2016/01/12 05:49 by tgwikiupdate