Skip to main content

Markers

|

A marker is a visual representation (such as an icon or a geometry, like a polyline or polygon) placed at a specific geographic location on a map to indicate an important point of interest, event, or location.

Markers can represent temporary or user-specified points on the map, such as user-defined locations, waypoints, or temporary annotations. While they are often represented by icons, they can also take the form of more complex geometries, like lines or shapes, depending on the context or requirements.

Markers typically contain only basic metadata, such as their position, title, or description, without extensive associated details.

By default, the map does not include any visual elements categorized as markers. Users have the ability to create and add markers to the map as needed.

Instantiating Markers

Markers can be instantiated via:

  1. Default Initialization : Marker() creates a basic marker object.
  2. With CoordinatesList : Marker(coordinates: CoordinatesList) initializes a marker at specified geographic coordinates
  3. With Coordinates and radius in meters : Marker(coordinates: Coordinates, radius: Int) creates a circular marker centered at the given coordinates with a defined radius.
  4. With Coordinates, horizontal radius, and vertical radius in meters : Marker(coordinates: Coordinates, horizRadius: Int, vertRadius: Int) creates a rectangle marker centered at the specified coordinates with defined horizontal and vertical radii.
danger

Creating a marker does not automatically display it on the map. Ensure you set its coordinates and attach it to the desired map. Refer to the Display markers guide for detailed instructions.

Types of Markers

There are 3 types of markers:

  • Point markers (each part is a group of points - array of coordinates)
  • Polyline markers (each part is a polyline - array of coordinates)
  • Polygon markers (each part is a polygon - array of coordinates)

The marker has methods for managing and manipulating markers on a map, including operations such as adding, updating, and deleting coordinates or parts.

A marker can be rendered in multiple ways on the map, either through default settings or user-specified rendering options:

  • An image icon
  • A polygon drawn with custom collors for border and shape.
  • A polyline having an associated image at each point
Point marker
Polyline marker with point markers at each point
Polygon marker

Customization options

Markers offer extensive customization options through MarkerRenderSettings class and MarkerCollectionRenderSettings, enabling developers to tailor their appearance and behavior. Customizable features include:

  • Colors: Modify the fill color, contour color, and text color to match the desired style.
  • Sizes: Adjust dimensions such as line width, label size, and margins to fit specific requirements.
  • Labeling and Positioning: Define custom labeling modes, reposition item or group labels, and adjust the alignment of labels and images relative to geographic coordinates.
  • Grouping Behavior: Configure how multiple markers are grouped when located in proximity.
  • Icons: Customize icons for individual markers or groups, including options for image fit and alignment.
  • Polyline and Polygon Textures: Apply unique textures to polylines and polygons for enhanced visualization.

Interaction with Markers

Selecting markers

Markers are selectable by default, meaning user interactions, such as taps or clicks, can identify specific markers programmatically (e.g., through the function mapview.cursorSelectionMarkers()).

Tip

When cursor is hovering over a grouped marker cluster, the mapview.cursorSelectionMarkers() method will return the MarkerMatchList with a group head marker. See more about group head markers at Marker Clustering.

The result is a MarkerMatchList. The MarkerMatch item contains detailed information about the match:

  • the matched marker: Marker
  • the marker's type: EMarkerMatchType
  • the matched marker's index: Int in collection
  • the matched markerCollection: MarkerCollection of the marker
  • the matched marker's segment: Int
  • the matched position coordinates: Coordinates
  • the distance: Int from the matched position to the cursor position in meters

Searching markers

Markers are not searchable.

Calculating route with marker

Markers are not designed for route calculation.

Tip

To enable route calculation and navigation, create a new landmark using the relevant coordinates of the marker and a representative name and use that object for routing.

Marker

NameTypeDescription
idLongUnique identifier for the marker.
nameStringName of the marker.
typeEMarkerTypeType of the marker (Point, Polyline, Polygon).
areaRectangleGeographicAreaThe geographic area covered by the marker.
partCountIntNumber of parts in the marker.
getCoordinates()CoordinatesListReturns the coordinates of the marker.
setCoordinates(coordinates: CoordinatesList)UnitSets the coordinates of the marker.
set(center: Coordinates, radius: Int)UnitSets the marker as a circle with the specified center and radius in meters.
set(center: Coordinates, horizontalRadius: Int, verticalRadius: Int)UnitSets the marker as an ellipse with the specified center and horizontal/vertical radii in meters.
set(corner1: Coordinates, corner2: Coordinates)UnitSets the marker as a rectangle defined by two corner coordinates.
add(coordinates: Coordinates, index: Int, part: Int)UnitAdds coordinates to the marker at the specified index and part.
add(latitude: Double, longitude: Double, index: Int, part: Int)UnitAdds coordinates to the marker using latitude and longitude values at the specified index and part.

MarkerCollection

The MarkerCollection class is the main collection holding markers. All the markers within a collection have the same type and are styled in the same way.

NameTypeDescription
nameStringThe name of the marker collection.
sizeIntReturns the number of markers in the collection.
typeEMarkerTypeRetrieves the type of the marker collection.
areaRectangleGeographicAreaThe geographic area enclosing all markers in the collection.
markersArrayList<Marker>?The list of markers in the collection.
add(marker:Marker,index:Int)UnitAdds a marker to the collection at a specific index (default is the end of the collection).
del(index: Int)UnitDeletes a marker from the collection by index.
clear()UnitDeletes all markers from the collection.
getMarkerAt(index:Int)MarkerReturns the marker at a specific index or an empty marker if the index is invalid.
getMarkerById(markerId:Long)MarkerRetrieves a marker by its unique ID.
getPointsGroupHead(groupId:Long)MarkerRetrieves the head of a points group for a given marker ID.
getPointsGroupComponents(groupId:Long) ArrayList<Marker>?Retrieves the components of a points group by its ID.
save(buffer: DataBuffer)IntSerializes the collection and adds it to a DataBuffer.