Using GeoTools I was able to display a simple shape file using JMapPane class. My requirement is to draw a bar much like in any maps that shows the scale of the map on display in meters in relation to the length of the bar as I zoom in/out.
I've been searching for days now and I just couldnt find any concrete hint.
Even a way to convert two given points in a map to distance in pixels would really help me
Please any hint is greatly appreciated.
I don't have an example, but for this use case, if you are on GeoTools 8.x, you should implement your own DirectLayer (http://docs.geotools.org/latest/userguide/library/render/map.html). Code to generate a scale bar can be found in uDig (LGPL, but don't know exactly in which class) or in GeoServer (GPL'd, here: http://svn.codehaus.org/geoserver/trunk/src/wms/src/main/java/org/geoserver/wms/decoration/LegendDecoration.java)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With