Search code examples
androidmapsopenstreetmaposmdroid

How does osmdroid's CopyrightOverlay.setCopyrightNotice() work?


I added a copyright notice to my map like this:

/* add copyright overlay */
val copyrightOverlay = CopyrightOverlay(this)
copyrightOverlay.setCopyrightNotice("This doesn't do anything :(")
mapView.overlays.add(copyrightOverlay)

The documentation doesn't mention what setCopyrightNotice(String pCopyrightNotice) is supposed to do.

I expected it to somehow change the text of the copyright overlay. But as shown in the screenshot below, the overlay still says © OpenStreetMap contributors

Does anyone know how this method is supposed to be used? Did I miss anything?

screenshot

(the reason I tried to edit the notice was to find a way to make donations to OSM, similarly to the overlay at openstreetmap.org


Solution

  • You can look into the source code : since it's open source.

    There we can see that setter should set the text:

    public void setCopyrightNotice(final String pCopyrightNotice) {
            mCopyrightNotice = pCopyrightNotice;
    }
    

    But we can also see that the draw method gets the copyright notice from tile source:

    @Override
    public void draw(Canvas canvas, MapView map, boolean shadow) {
        setCopyrightNotice(map.getTileProvider().getTileSource().getCopyrightNotice());  
        draw(canvas, map.getProjection());
    }
    

    This practically overrides the value you set every time the overlay is drawn.

    I kind of think this is a mistake in the API. The setCopyrightNotice method shouldn't be public, that's just confusing.

    I would suggest to implement your own copyright notice overaly - you can fallow the original source and reproduce the code exactly how you want it to be.