Skip to main content

Issue with JXMapViewer

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2011-02-17

Hello All,
I am using the JXMapViewer toolkit in a swing application. The objective is to show several components (say JPanel) on a map based on latitude and longitude. While doing this I fnd the following issue:
The JXMapViewer toolkit is not showing more than a certain number of components. The numbers is depening upon the size (of the map area as well as the commponent) and the zoom level of the map. For example, when I have added 15 components (each of them are associated with a lat and long), the JXMapViewer is showing all the components at max zoom level. But as soon as I added the 16th component, the JXMapViewer is not able to show any of them (all just disappears). At this stage when I reduce the zoom level then only all the 16 components are visible.
To add the components I am using the following code
JXMapKit jXMapKit1=new JXMapKit ();
JXMapViewer map=jXMapKit1.getMainMap();
for(int i=0;i<16;i++){
map.add(component[i]); //Here component[i] is of type JComponent
//For each component I am doing the below
WaypointPainter componentPainter = new WaypointPainter() {
protected void doPaint(Graphics2D g, JXMapViewer map, int width, int height) {
for (Object ob : getWaypoints()) {
JComponent component=(JComponent)ob;
Point2D gp_pt = map.getTileFactory().geoToPixel(new GeoPosition(37.31358788128608, -120.49695253372192), map.getZoom());
Rectangle rect = map.getViewportBounds();
Point pt = new Point((int) gp_pt.getX() - rect.x, (int) gp_pt.getY() - rect.y);
component.setPreferredSize(new Dimension(600, 500));
componentPainter.setWaypoints(wayComponents); //wayComponents is a Set containing the JComponent that needs to put on the map
painterlist.add(componentPainter); //painterList is an arraylist

Now when Step2 is done for each of the 16 components I am doing the below operation:
CompoundPainter cp = new CompoundPainter();
org.jdesktop.swingx.painter.Painter[] painters = new org.jdesktop.swingx.painter.Painter[painterlist.size()];
for (int i = 0; i < painters.length; i++) {
painters[i] = painterlist.get(i);

Is anything wrong I am doing in the above code. Any suggestion is higly appreciated