Add a marker
Use GLMapImage for one image or a small set. Use GLMapImageGroup for many independently moving images, and GLMapMarkerLayer when you need labels or clustering.
Swift
Add an SVG file to the application bundle:
guard let path = Bundle.main.path(forResource: "pin", ofType: "svg"),
let image = GLMapVectorImageFactory.shared.image(
fromSvg: path,
withScale: 1.6,
andTintColor: GLMapColor(red: 230, green: 60, blue: 60, alpha: 255)
)
else {
fatalError("Cannot render pin.svg")
}
let marker = GLMapImage(drawOrder: 3)
marker.setImage(image)
marker.offset = CGPoint(x: image.size.width / 2, y: 0)
marker.position = GLMapPoint(
geoPoint: GLMapGeoPoint(lat: 41.1579, lon: -8.6291)
)
map.add(marker)
Kotlin
Place the SVG under src/main/assets:
val bitmap = SVGRender.render(
assets,
"pin.svg",
SVGRender.transform(renderer.screenScale.toDouble()),
) ?: error("Cannot render pin.svg")
val marker = GLMapImage(3).apply {
setBitmap(bitmap)
setOffset(bitmap.width / 2, 0)
position = MapPoint.CreateFromGeoCoordinates(41.1579, -8.6291)
}
renderer.add(marker)
drawOrder controls which draw objects appear above others. The image offset defines the anchor relative to the geographic point.
For complete group and clustering examples, use the reference implementations instead of creating a parallel marker model: