> For the complete documentation index, see [llms.txt](https://dev.pointr.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.pointr.tech/v9/features/indoor-maps/customizations-and-branding/custom-drawings/custom-drawings-for-mobile.md).

# Custom Drawings for Mobile

Overview, common use cases, and sample code for adding custom elements on top of your maps.

## Markers

Markers are objects of `PTRMapMarker` class. Markers should be used when you want to add any kind of custom view to the map.

More about markers can be found on the iOS and Android reference documentation.

#### Add a marker

{% tabs %}
{% tab title="iOS" %}

```swift
mapWidget.mapViewController.addMarkers([
    PTRMapMarker(
        view: view, 
        coordinate: coordinate, 
        level: level, 
        reuseIdentifier: "marker-reuse-id", 
        maximumZoomLevel: 18.0
    )
])
```

{% endtab %}

{% tab title="Android" %}

```kt
mapWidget.mapFragment?.addMarker(
    PTRMapMarker(
        latitude = latitude, 
        longitude = longitude,
        minZoomLevel = 0.0,
        maxZoomLevel = 19.0,
        level = selectedLevel,
        view = view
    )
)
```

{% endtab %}

{% tab title="Flutter" %}
{% code title="Image as a Marker" %}

```dart
await PTRMapWidgetChannel.addMarker(
  PTRMapMarker(
    id: 'image_marker_${_markerCount++}',
    latitude: latitude,
    longitude: longitude,
    level: 0,
    type: PTRMarkerType.image,
    imageBytes: imageBytes,
    size: 40,
  )
);
```

{% endcode %}

{% code title="Text/Emoji as a Marker" %}

```dart
await PTRMapWidgetChannel.addMarker(
  PTRMapMarker(
    id: 'text_marker_${_markerCount++}',
    latitude: latitude,
    longitude: longitude,
    level: 0,
    type: PTRMarkerType.text,
    text: '📍',
    textColor: Colors.blue,
    size: 32,
  )
);
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Features & Layers

Features are objects of `PTRFeature` class. Features can be subclassed to create new objects. POI’s are an example, since `PTRPoi` class is a subclass of the `PTRFeature` class.

Layer classes are subclasses of `PTRMapLayer` class.

More about features & layers can be found on the iOS and Android References

#### Add feature to a symbol layer <a href="#add-feature-to-a-symbol-layer" id="add-feature-to-a-symbol-layer"></a>

{% tabs %}
{% tab title="iOS" %}

```swift
guard let position = PTRPosition(coordinate: coordinate, level: level) else { return }

let layerId = "symbol-layer"

let geometry = PTRGeoPoint(coordinate: coordinate)
let feature = PTRFeature(typeCode: "custom_annotation", geometry: geometry, position: position, externalId: "your-external-id", attributes: ["myText": "Hello"])

let layer = PTRMapSymbolLayer(identifier: layerId)
layer.textKeyPath = "myText"
layer.iconImageName = "my-image"
layer.iconImage = image
layer.iconScale = 1.0
layer.iconAnchor = .top
layer.textAnchor = .bottom

mapWidget.mapViewController.addLayer(layer)
mapWidget.mapViewController.addFeatures([feature], toLayer: layerId)
```

{% endtab %}

{% tab title="Android" %}

```kotlin
widget.mapFragment?.addLayer(layer = ptrLayer) { isSuccess, message ->
    Plog.d("Layer add ${ptrLayer.identifier} $isSuccess $message")
    if (!isSuccess) {
        return@addLayer
    }
    val position = Position(GeoPoint(lat = latitude, lon = longitude))
    val feature = Feature(geometry = GeoPoint(latitude, longitude), position = position, attributes = mapOf("name" to "feature"))
    widget.mapFragment?.addFeatures(listOf(feature), ptrLayer.identifier)
}
```

{% endtab %}
{% endtabs %}

#### Add feature to a fill extrusion layer (3D) <a href="#add-feature-to-a-fill-extrusion-layer-3d" id="add-feature-to-a-fill-extrusion-layer-3d"></a>

{% tabs %}
{% tab title="iOS" %}

```swift
guard let location = PTRPosition(coordinate: coordinate, level: level) else { return }

let layerId = "fill-extrusion-layer"

let point1 = PTRGeoPoint(coordinate: coordinate1)
let point2 = PTRGeoPoint(coordinate: coordinate2)
let point3 = PTRGeoPoint(coordinate: coordinate3)

// Assign the points on the correct order
// following the polygon perimeter
let geometry = PTRGeoPolygon(points: [point1, point2, point3])
let feature = PTRFeature(typeCode: "custom_annotation", geometry: geometry, position: position, externalId: "your-external-id")

//Create the fill extrusion layer and set properties like color, height, etc.
let layer = PTRMapFillExtrusionLayer(identifier: layerId)
layer.fillExtrusionColor = .blue
layer.fillExtrusionHeight = 5
layer.maximumZoomLevel = 24
layer.minimumZoomLevel = 0

mapWidget.mapViewController.addLayer(layer)
mapWidget.mapViewController.addFeatures([feature], toLayer: layerId)
```

{% endtab %}

{% tab title="Android" %}

```kotlin
val ptrLayer = PTRMapFillExtrusionLayer()
// Changes the opacity of the layer.
// Other properties can also be modified. Please check the list of available apis
ptrLayer.fillExtrusionOpacity = 0.5F

widget.mapFragment?.addLayer(layer = ptrLayer) { isSuccess, message ->
    Plog.d("Layer add ${ptrLayer.identifier} $isSuccess $message")
    if (!isSuccess) {
        return@addLayer
    }
    val position = Position(GeoPoint(lat = latitude1, lon = longitude1))

    // Assign the points on the correct order
    // following the polygon perimeter
    // (bottomLeft, bottomRight, topRight, topLeft)
    val geo = GeoPolygon( outer =
    listOf(GeoPoint(latitude1, longitude1),
        GeoPoint(latitude2, longitude1),
        GeoPoint(latitude1, longitude2)))

    val feature = PTRFeature(geometry = geo, position = position)
    widget.mapFragment?.addFeatures(listOf(feature), ptrLayer.identifier)
}
```

{% endtab %}
{% endtabs %}

<table data-header-hidden><thead><tr><th width="261.3984375"></th><th></th></tr></thead><tbody><tr><td><code>PTRMapLineLayer</code></td><td>to render polylines on map view.</td></tr><tr><td><code>PTRMapCircleLayer</code></td><td>to render circles on map view.</td></tr><tr><td><code>PTRMapFillLayer</code></td><td>to render polygon or multipolygon features on map view.</td></tr><tr><td><code>PTRMapFillExtrusionLayer</code></td><td>to render polygon or multipolygon features on map view in 3D.</td></tr><tr><td><code>PTRMapSymbolLayer</code></td><td>to render icons and/or text labels on map view.</td></tr></tbody></table>

{% hint style="warning" %}

## Performance

We advise the usage of features, because features and layers provide higher performance compared to markers. Markers should only be used in case the existing layers don't cover a specific use case like having a completely custom and interactive view on the map.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://dev.pointr.tech/v9/features/indoor-maps/customizations-and-branding/custom-drawings/custom-drawings-for-mobile.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
