简体   繁体   中英

Custom Marker in RadiusMarkerClusterer

I created a customMarker that in addition to the image contains a label at the bottom with a name. If I create a " FolderOverlay " everything works correctly I see my custom Marker.

This is my customMarker

class MarkerWithLabel(mapView: MapView?, val label: String) : Marker(mapView) {
val textPaint = Paint()

init {

    with(textPaint){
        color = Color.BLACK
        textSize = 35f
        isAntiAlias = true
        typeface = Typeface.DEFAULT_BOLD
        textAlign = Paint.Align.CENTER
    }
}

override fun draw(c: Canvas, osmv: MapView?, shadow: Boolean) {
    draw(c, osmv)
}



fun draw(c: Canvas, osmv: MapView?) {
    super.draw(c, osmv, false)
    val p: Point = mPositionPixels // already provisioned by Marker
    c.drawText(label, p.x.toFloat(), (p.y + 30).toFloat(), textPaint)
}

}

Creating a " RadiusMarkerClusterer " on the other hand does not show the label below the CustomMarker. Actually it seems that osmBonuspack does not use my CustomMarker but the normal Marker.

I say this because it does not override the draw method of my CustomMarker.

How can I solve this?

In MarkerClusterer.java, drawing piece code is as follow:

for (StaticCluster cluster:mClusters){
    cluster.getMarker().draw(canvas, mapView.getProjection());

As you can see, the method called is: public void draw(Canvas canvas, Projection pj)

So you should try to override this method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM