Add a flat label to a single polygon.
// Label the apple store with the label "Apple Store"
const location = mapView.venue.locations.find((l) => l.name === "Apple")!;
mapView.FlatLabels.add(location.polygons[0], "Apple Store");
The MappedinPolygon to label.
The text to display on the label.
Add a flat label to the polygons associated with all locations on the venue. The text is automatically determined based on location data.
// Draw red labels on all polygons with a location
mapView.FlatLabels.labelAllLocations({
appearance: {
color: 'red',
}
});
Remove a flat label from a single polygon.
mapView.FlatLabels.add(polygon, "Label");
...
// Remove the label currently on this polygon
mapView.FlatLabels.remove(polygon);
The MappedinPolygon with a label to remove.
Remove all flat labels from the venue.
mapView.FlatLabels.add(polygon1, "Label 1");
mapView.FlatLabels.add(polygon2, "Label 2");
...
// Remove all labels from all polygons
mapView.FlatLabels.removeAll();
Update the appearance attributes of an already-existing label. If the provided polygon does not have a label already, this is a no-op.
mapView.FlatLabels.setAppearance(polygon, {
color: 'blue',
font: 'times',
});
The MappedinPolygon with a label to update.
The new TFlatLabelAppearance settings to apply to the polygon's label.
Set the hover text color for all Flat Labels. To set hover color for all polygons, see {@link MapView.setHoverColor}.
// Make all flat labels turn red on hover
mapView.FlatLabels.setHoverColorForAll('#ff0000');
A hexidecimal string representing the hover color.
API to add and remove flat labels on the map.