I am trying to load JMapViewer
from a specified zoom level for my offline use. I have been able to load the tiles from my local machine from zoom levels 1 to 18 and render
it well. The JMapViewer
works well only when minimum zoom level is 0 , 1, 2 or 3
. Suppose I change the minimum zoom level to anything greater than 3
, the JMapViewer
throws a null pointer
exception while trying to get the position while drawing the tiles and the program doesn't start at all. Is there any way to load them from a particular zoom after making a code change.
The following are the links I've referred to:
http://svn.openstreetmap.org/applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/
http://paulusschoutsen.nl/blog/2012/08/java-component-jmapviewer-with-offline-openstreetmap-support/
I guess I figured it out. In JMapViewer.java, we need to specify the minimum zoom level as a parameter to OfflineOsmTileSource. Then we need to specify setDisplayPosition(tileSource.LonToX((lon1 + lon2) / 2, zoom_level),tileSource.LatToY((lat1 + lat2)/2, zoom_level), zoom_level);
Hope it helps somebody.
Cheers!