Display markers
Learn how to add and customize markers on your map, including point, polyline, and polygon types.
Overview
The Marker class is the base for all marker types. It encapsulates coordinates assigned to specific parts. You can add multiple coordinates to the same marker and separate them into different parts. If no part is specified, coordinates are added to the default part (indexed as 0). Coordinates are stored in a list-like structure where you can specify their index explicitly. By default, the index is -1, meaning the coordinate appends to the end of the list.
// code used for displaying a marker with coordinates separated into different parts
final marker1 = Marker()
..add(Coordinates(latitude: 52.1459, longitude: 1.0613), part: 0)
..add(Coordinates(latitude: 52.14569, longitude: 1.0615), part: 0)
..add(Coordinates(latitude: 52.14585, longitude: 1.06186), part: 1)
..add(Coordinates(latitude: 52.14611, longitude: 1.06215), part: 1);
// code used for displaying a marker with coordinates added to the same part
final marker1 = Marker()
..add(Coordinates(latitude: 52.1459, longitude: 1.0613), part: 0)
..add(Coordinates(latitude: 52.14569, longitude: 1.0615), part: 0)
..add(Coordinates(latitude: 52.14585, longitude: 1.06186), part: 0)
..add(Coordinates(latitude: 52.14611, longitude: 1.06215), part: 0);
Add markers to the map
To display markers on your map, add them to a MarkerCollection. When creating a collection, provide a name and specify the MarkerType enum (MarkerType.point, MarkerType.polyline, or MarkerType.polygon).
Once populated, add the MarkerCollection to MapViewMarkerCollections through the GemMapController:
mapController.preferences.markers.add(markerCollection);
Marker types
Point markers
Point markers display as icons to highlight specific locations dynamically. The MarkerCollection must use MarkerType.point.
final marker = Marker()
..add(Coordinates(latitude: 52.1459, longitude: 1.0613), part: 0)
..add(Coordinates(latitude: 52.14569, longitude: 1.0615), part: 0)
..add(Coordinates(latitude: 52.14585, longitude: 1.06186), part: 1)
..add(Coordinates(latitude: 52.14611, longitude: 1.06215), part: 1);
final markerCollection = MarkerCollection(markerType: MarkerType.point, name: "myCollection");
markerCollection.add(marker);
mapController.preferences.markers.add(markerCollection);
controller.centerOnArea(markerCollection.area);
By default, point markers appear as blue circles. Beyond specific zoom levels, they automatically cluster into orange circles, then red circles at higher clustering levels. See Marker clustering for details.
Polyline markers
Polyline markers display continuous lines with one or more connected segments. The MarkerCollection specifies markerType as MarkerType.polyline. Markers can include multiple coordinates that may belong to different parts. Coordinates within the same part connect via a polyline (red by default), while coordinates in different parts remain unconnected.
Polygon markers
Polygon markers display closed shapes composed of straight-line segments. The MarkerCollection must use MarkerType.polygon.
At least three coordinates must be added to the same part to create a polygon. Otherwise, the result is an open polyline.
Customize polygons using properties like polygonFillColor and polygonTexture. Since polygon edges are polylines, you can refine their appearance with polylineInnerColor, polylineOuterColor, polylineTexture, and more.



