User Tools

Site Tools


map_suite_ios_labeling

Map Suite iOS Labeling

Video Overview

Labeling
Labeling(Xamarin Forms)

Introduction

In this sample, we show the flexibility of Map Suite iOS 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 Percentage” 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.

Select the next layer style from the Show Layers menu, “Labeling Points.” 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.

Tap on the “Labeling Lines” sample. 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

Main.cs is the entrance to the app. It opens AppDelegate.cs. Storyboards contain UI and the relationship between UIs, but for this sample they are blank. MainViewController.cs contains the UI and imports the XML file that lists all samples. ViewDidLoad() is the iOS event for page load.

In the Controllers folder, there is a controller for each of the Labeling samples. Each controller should give you an idea of what APIs are used to execute the Labeling style. Under Controllers > Advanced, DetailVewController.cs has common functions that are inherited by the Labeling controllers. SliderViewController.cs handles the menu that slides in from the left side of the map.

map_suite_ios_labeling.txt · Last modified: 2016/01/12 03:26 by tgwikiupdate