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.
Optional
options: TAddFlatLabelOptionsAdd 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',
}
});
Optional
options: TFlatLabelAllLocationsOptionsRemove 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.
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 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.