Giter Site home page Giter Site logo

jxmapviewer2's Introduction

Overview

sample2 sample2

This project is based on the JXMapViewer component of SwingX-WS.

The project was hosted at SwingLabs.org, but has been discontinued. We extracted the JXMapViewer part from the latest SwingX-WS version available and continue developing it.

The JXMapViewer Tutorial by Joshua Marinacci provided a good overview over the functionality of the component, which is now gone from java.net but available on archive.org. Please have a look at the examples section in addition.

The content of this project are also available at Maven Central and can be referenced in your pom.xml with the following coordinates:

<dependency>
    <groupId>org.jxmapviewer</groupId>
    <artifactId>jxmapviewer2</artifactId>
    <version>2.8</version>
</dependency>

Examples

You can find some examples as part of this source code repository. You can open them as a separate project in your IDE and run them there. Alternatively, they can be run from the command line after creating a Maven package from them.

$ mvn clean package
$ java -cp target/jxmapviewer2-examples-2.5.jar sample1_basics.Sample1

GeoPackage data

An example on how to integrate GeoPackage data has been implemented here: #122

History

This source code used in this project is based on:

  • SwingX-ws-2009_06_14.jar formerly hosted at java.net/projects/swingx
  • SwingX 1.6.3 (released Feb 2012) formerly hosted at java.net/projects/swingx-ws

This is what we have done so far ...

  • Extract the JXMapViewer part from the full package
  • Upgrade to Java 6 (version 2.1)
  • Upgrade to Java 7 (version 2.5)
  • Fixed javadoc
  • Replaced system.out.println() with apache.commons.logging
  • Removed broken TileProviders
  • Remove dependencies to SwingX (and its indirect dependencies)
  • Fixed tile caching so that only tiles are cached, not everything
  • Extract user interaction from the viewer
  • Make CompoundPainter use Lists instead of Arrays
  • Find out what the "Java One" hack is and replace it with proper implementation
  • Improved zooming in - images of coarser resolution are used until new images are loaded
  • Fixed thread leak when setting new TileFactory
  • Supports OSGi bundles (contains MANIFEST.MF)
  • Supports Maven dependency management
  • Fixed use of deprecated code
  • Fix bugs that were posted on java.net/jira/browse/SWINGX_WS

License

This project has been licensed under the GNU Lesser General Public License (LGPL)

jxmapviewer2's People

Contributors

agorshkov23 avatar bargru avatar bjorndarri avatar bradh avatar clansdown avatar cyberpython avatar dansch1 avatar danstahr avatar fastfission avatar filllip avatar gmaslowski avatar heiko-zelt avatar jkoelewijn avatar kkieffer avatar maeichris avatar matthiasblaesing avatar mikey75 avatar msteiger avatar primosk avatar richardeigenmann avatar rusio avatar saper avatar sjaenick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jxmapviewer2's Issues

is user-agent set correctly on tile request?

Hi,

I'm not a web developer, so please excuse me if I'm missing something obvious here. As far as I can tell jxmapviewer2 is not setting a valid user agent in its tile request when this is part of the OSM tile server's terms of usage:

http://wiki.openstreetmap.org/wiki/Tile_usage_policy#Technical_Usage_Requirements

I think the only change needs to be in AbstractTileFactory.TileRunner.cacheInputStream where the line:

InputStream ins = url.openStream();

would be replace by something like the following?

URLConnection connection = url.openConnection();
connection.setRequestProperty("User-Agent", "MyApp/1.0");
InputStream ins = connection.getInputStream();

where the client code needs to pass though a sensible string for the user-agent.

Licensing Issues

Passing the source code through our legal department turned up the following two issues that seem to negate the use of the LGPL.

  1. For file: /jxmapviewer2-jxmapviewer2-1.2/jxmapviewer2/src/org/jdesktop/swingx/
    OSMTileFactoryInfo.java

The software package contains one file with a statement that the file can only be used with an explicit permission from the owner. No indication of any license or such a permission was found. Therefore the file in question creates a clear risk of infringement and should be removed.

  1. For file licensed under GPL v.3: /examples/src/sample5_tilesets/Sample5.java

The software package includes a file under the GPL v.3 license. Since GPL v.3 is considered to be incompatible with LGPL v.3 this creates a clear risk of infringement. This report has been drafted with the intent of not having to apply GPL v.3, therefore section 3 of the report contains instructions for removing the GPL-licensed file. It would also be possible to license the whole package under GPL v.3, as allowed by the LGPL v.3 main license of the package. This would allow retaining the GPL-licensed file.

Personally, I can't see point 2. Point 1, however, seems to be a clear LGPL issue. Am I misunderstanding something?

Missing mechanism for attribution

The use of OSM maps requires some attribution to be shown on or next to the map.

It is possible to use multiple maps by keeping multiple TileFactory / TileFactoryInfo in an array. But these classes have no support for an attribution text. If you want to show proper attribution, you have to implement this redundantly in parallel.

TileFactoryInfo should have a property String attribution and some support to query this property, maybe via the TileFactory. This way you could control all properties of a map in the same place.

Using my own tile server

Hi,

I've just tried jxmapviewer2 and everything works fine with http://tile.openstreetmap.org.
Then, I asked someone to setup my own tile server and example url is as follow:

http://89.187.66.107:8090/styles/klokantech-basic/?vector#9.53/51.5515/-0.0701

I developed a new TileFactoryInfo class to match this url as follow:

@Override
  public String getTileUrl(int x, int y, int zoom) {
    zoom = max - zoom;
    String url = this.baseURL + "" + zoom + "/" + x + "/" + y  + "";
    return url;
  }

But x,y are not GeoPosition, so it's not working.
So, How can I use jxmapviewer2 with my own tile server?

SwingLabsBlueMarble is not available anymore.

The SwingLabsBlueMarble provider is not available anymore. From what I could gather the website is still there but the tile server is gone.

However, one might be able to fall over to the NASA source, which is a WMS service. I tried connecting to it:

mapKit.setTileFactory(new WMSTileFactory(new WMSService("https://svs.gsfc.nasa.gov/cgi-bin/wms?SERVICE=WMS&", "2915_21223")));

But seems like the service does not like the request it is send:

$ curl --dump-header - "https://svs.gsfc.nasa.gov/cgi-bin/wms?SERVICE=WMS&version=1.1.1&request=GetMap&Layers=2915_21223&format=image/jpeg&BBOX=0.0,0.0,0.0054931640625,0.00549316405408165&width=500&height=500&SRS=EPSG:4326&Styles="

HTTP/1.1 200 OK
Date: Tue, 07 Feb 2017 15:15:32 GMT
Server: Apache
Strict-Transport-Security: max-age=31536000; includeSubdomains;
Transfer-Encoding: chunked
Content-Type: application/vnd.ogc.se_xml

<?xml version='1.0' encoding="UTF-8" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM
 "http://svs.gsfc.nasa.gov/exception_1_1_0.dtd">
<ServiceExceptionReport version="1.1.0">
  <ServiceException code="InvalidSize">
    WIDTH is invalid for layer. Should be 1024.
  </ServiceException>
  <ServiceException code="InvalidSize">
    HEIGHT is invalid for layer.  Should be 512.
  </ServiceException>
  <ServiceException code="InvalidFormat">
    FORMAT is invalid for layer.  Should be image/png.
  </ServiceException>
  <ServiceException code="InvalidBBOX">
    BBOX is invalid for layer.  Should be [-180,-90,180,90]
  </ServiceException>
  <ServiceException code="LayerNotDefined">
    Unable to find layer.
  </ServiceException>
</ServiceExceptionReport>

Not sure why the layer is reported as undefined, if one does fix all the other errors it works. I'm not sure what the appropriate fix for that should be.

Problem using JXMapViwer2 1.3 with swingx-all-1.6.5-1.jar

there is a problem if you use the
CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>(routePainter);

That isn't compiling, just give the message:

The constructor CompoundPainter<JXMapViewer>(List<Painter<JXMapViewer>>) is undefined

Workaround:
I have made a custom build with the actual version on swingx...

LocalResponseCache not working when PrintServiceLookup is called

In case the java class PrintServiceLookup.lookupPrintServices from javax.print.PrintServiceLookup is called, the LocalResponseCache doesn´t create the tilecache.
The folder is created, but tiles (.png) are not stored.

This issue occurs only on Linux (Debian).
On Windows the cache work as expected.

Do you have any ideas?

how to draw on all maps

When I draw something on the map and zoom out really far, it's only drawn on the middle map (many maps are placed side by side so as to create a "wrapping" effect). Is there an example that shows how to draw on all of the maps? I'm expecting a waypoint to show up on each wrapped map.

Also, great work! I work with a lot of people who use maps, and none of us knows about this continued work. I'm going to push for using it in our organization.

Rebuilding 2.0 for JDK6?

Hi, I just noticed that the distributed jxmapviewer2-2.0.jar on the Maven Central corresponds to 159950c, and to to tag 2.0 (which is 503b5e4). Most importantly, the images have been moved.

I managed to compile 503b5e4 using maven and got the jar (unfortunately with strange paths like main/... that made it into the release.

However I am stuck at the newer gradle process:

Using gradle, I get:

* Where:
Build file '/home/saper/sw/jxmapviewer2/jxmapviewer2/build.gradle' line: 27

* What went wrong:
A problem occurred evaluating root project 'jxmapviewer2'.
> No such property: sonatypeRepoURI for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 13.241 secs

When I used Maven on 503b5e4 I managed to compile the code for a JDK6 successfully.

Maybe jxmapviewer could be re-relased with class files version 50 and not 51?

What's the best way to rebuild current source?

Maintain tile caching after program terminated

Congratulation ,great job .
I would like to ask how we can maintain tile cache for a standard duration of time ?
For example three months.
For the time being using the code from the samples after program termination the cache is gone.

Thanks in advanced

Setting tile factories

Does JXMapViewer2 save zoom info when switching TileFactories as of now?
See http://osdir.com/ml/java.jdnc.general/2008-01/msg00088.html

Furthermore, in swingx-ws-1.0 there was a big memory leak:

Whenever you change the tile factory via

myJXMapKit.setTileFactory(new DefaultTileFactory(new TileFactoryInfo( ... ){ ... });

5 new threads are instantiated (1 ImageFetcher thread, 4 tile-pool threads), and the pre-existing 5 threads (1 ImageFetcher and 4 tile-pool) are not terminated but keep lingering there forever.
So each time setTileFactory is called (e.g. a UI control that allows users to change the tile server) there's a memory leak consisting of 5 threads and the memory they occupy.

Wrong totalMapZoom in OSMTileFactoryInfo

The OSM map has 19 zoom levels (19 being the most detailed)

In OSMTileFactoryInfo totalMapZoom is set to 19.
But in method getTileUrl() zoom is converted: "zoom = 19 - zoom"
With 1 being the most detailed zoom in jxmapviewer2 this means that the highest zoom level is 18.

So totalMapZoom should be 19 to actually use all zoom levels.

Load custom image not tiled

Hello Martin, thank's for this work.
I have worked with this library two years ago, to displayed maps. But now I think, it could be utilized to display a single image with an arbitrary coordinate system and make zoom, move image, etc...
Is it posible to load a custom image not tiled from local file with this library?.
Greetings

Sample to drag Waypoint

Thanks for the great samples! They are super clear and easy to follow and I had my map up in no time!

Has someone got a sample how to drag Waypoints and receive a callback with the coordinates of the new location?

Being able to tell when all tiles are loaded up.

Greetings,

First of all, thank you for your development of JXMapViewer. I am currently using it on our network planification tool (https://github.com/girtel/Net2Plan) and so far, it has been of much utility. However, I have found myself with a problem I have not found a solution to.

In this project, I am using the map viewer as a way of showing a non-interactive map centered on a specific point. The thing is that I need the map to finish loading before the program continues its execution. Nevertheless, I have not found a proper way to make the program wait until the visible tiles have finished loading. Is there some way this could be achieved?.

Thank you for your time, Jorge.

Integrating this into a project troubles.

As I'm fairly new at the more advanced Java stuff. (for example adding other libraries into projects), I'm having some problems importing this into my NetBeans. Are there any dependencies missing, or is there a fairly specific way on how to make this work?

PS: Wonderful project!

geoposition serializable

Hello,

can you implement the Serializable interface to the GeoPosition class, so the position can be stored / read from a file?

Thx

Mouse- and keyevents not functioning

Well. forgetting my last issue, which wasn't much of an issue at all, this one seems a bit more serious. I can't see any accessable documentation as to how to enable mouse and key-events. I've tried to adding objects from the swingx-input classes, but that doesn't seem to do it. Any tips?

PS: I'll be out of your hair in notime!

Hovering: setLocation does not work (wrong position)

Hi,
I'm performing this tutorial: https://today.java.net/pub/a/today/2007/11/13/mapping-mashups-with-jxmapviewer.html#waypoint-rollovers
The rollover JLabel is not added at the correct position, it is always displayed at the top, horizontal center.
screenshot from 2014-05-26 14 18 25

My code, however, should place it at the mouse pointer position:

  if (converted_gp_pt.distance(e.getPoint()) < 20) {
                            //System.out.println("IMPORTANT " + converted_gp_pt);
                            mapViewer.add(tooltip);

                            tooltip.setText(twitterDataManager.getContent(dataItem));
                            tooltip.setVisible(true);
                            System.out.println("set location " + e.getPoint());
                            tooltip.setLocation(e.getPoint());
                            break;
                        } else {
                            tooltip.setVisible(false);
                            mapViewer.remove(tooltip);
                        }

include best fit zoom method in source?

Apologies if this isn't the best place to post this - I couldn't see anywhere to post feature requests so I've posted this as an issue instead. I wrote a method which is a variant of JXMapViewer.calculateZoomFrom that zooms both in and out to find a best fit position around a set of geopositions. calculateZoomFrom only zooms out until everything fits in, but doesn't zoom in to do a best fit, and I couldn't find anywhere else in the JXMapViewer2 project which did this. I was wondering if you'd like to put it into the JXMapViewer class?

/**
 * Zoom and centre the map to a best fit around the input GeoPositions.
 * Best fit is defined as the most zoomed-in possible view where both
 * the width and height of a bounding box around the positions take up
 * no more than maxFraction of the viewport width or height respectively.
 * @param jxMap
 * @param positions
 * @param maxFraction
 */
public static void zoomToBestFit(JXMapViewer jxMap, HashSet<GeoPosition> positions, double maxFraction) {
    // TO DO ... replace this class with call to private method JXMapViewer.generateBoundingRect
    // if code is integrated into JXMapViewer.
    class BoundingRect{
        Rectangle2D generateBoundingRect(JXMapViewer jxMap, Set<GeoPosition> positions, int zoom){
            Rectangle2D rect=null;
            for (GeoPosition pos : positions){
                Point2D pnt = jxMap.getTileFactory().geoToPixel(pos, zoom);
                if(rect==null){
                    rect = new Rectangle2D.Double(pnt.getX(), pnt.getY(), 0,0);
                }else{
                    rect.add(pnt);
                }
            }   
            return rect;
        }
    }
    BoundingRect calcBounds = new BoundingRect();

    if(positions.size()>0){

        TileFactory tileFactory = jxMap.getTileFactory();
        TileFactoryInfo info = tileFactory.getInfo();
        if(info!=null){

            // set map to maximum zoomed out
            jxMap.setZoom(info.getMaximumZoomLevel());

            // set to central position initially
            Rectangle2D bounds=calcBounds.generateBoundingRect(jxMap, positions,jxMap.getZoom());   
            GeoPosition centre = tileFactory.pixelToGeo(new Point2D.Double(bounds.getCenterX(),bounds.getCenterY()), jxMap.getZoom());
            jxMap.setCenterPosition(centre);

            // repeatedly zoom in until we find the first zoom level where either the width or height
            // of the points takes up more than the max fraction of the viewport
            int bestZoom = jxMap.getZoom();
            while(jxMap.getZoom() >= info.getMinimumZoomLevel() && positions.size()>1){

                // is this zoom still OK?
                bounds = calcBounds.generateBoundingRect(jxMap, positions, jxMap.getZoom());
                Rectangle2D viewport = jxMap.getViewportBounds();
                if(bounds.getWidth() < viewport.getWidth() * maxFraction && bounds.getHeight() < viewport.getHeight()* maxFraction){
                    bestZoom = jxMap.getZoom();
                }else{
                    break;
                }
                jxMap.setZoom(jxMap.getZoom()-1);
            }

            jxMap.setZoom(bestZoom);
        }
    }
}

set bounds of map by given coordinates

can you please provide a method, which enables me to set the bounds of the map with 2 coordinates or something like that for the given frame bounds?
I want to display a track on the map and would need something to display it completly on the map inside the "fixed" frame. Means: i don't want to resize the frame for settings the right bounds of the map.
Thank you very much

Incorrect tiles being loaded

Hi,

I'm trying to run JXMapViewer using a local tile repository. The tile pyramid structure works perfectly for JMapViewer but when I load the same url by passing it to TileFactoryInfo class, it just doesn't work. I get a peculiar file_no.png file for a specified area. I have generated the tiles using Mapnik. Let me know if you need any other information.

Infinite loop in zoomToBestFit()

in JXMapViewer.java, line 709: (within zoomToBestFit())

    while (getZoom() >= info.getMinimumZoomLevel())

this condition can never evaluate false, because the call to setZoom() on 722 will have no effect if it tries to set the zoom below the info.getMinimumZoomLevel(). (i.e. getZoom() can never return a value less than minimumZoomLevel, because setZoom() prohibits setting an illegal value) So, if your data is such that you never exit due to the conditional break on line 720, then you never exit at all, and your swing thread locks up. (e.g. two points at the same location, or close enough that they are still on the screen together at zoom level 1.)

(This is not hypothetical - I had a program lock up due to this)

Suggested fix: at the end of the loop, break out if we are already at the minimum zoom level. Note that it is NOT equivalent to change the while loop condition from >= to > , because that would have the effect of preventing this function from ever zoom to exactly the minimumZoomLevel* (i.e. it would be limited to minimumZoomLevel+1, which is silly)

while (getZoom() >= info.getMinimumZoomLevel())
{
   // is this zoom still OK?
   bounds = generateBoundingRect(positions, getZoom()); 
   if (bounds.getWidth() < viewport.getWidth() * maxFraction && 
                bounds.getHeight() < viewport.getHeight()* maxFraction)
   {
                bestZoom = getZoom();
   }
   else
   {
       break;
   }

   if (getZoom == info.getMinimumZoomLevel()){ // new
       break;                                  // new
   }                                           // new
   else {                                      // new
       setZoom(getZoom()-1);
   }                                           // new
}

Cannot add event on waypoint

Hello, I want to add a focus event to my waypoints in the route (thanks to a JToolTip), to show the city name associated to tehe waypoint but I don't find anything about that in the project. Is it possible to do that?

Thank you

tile size other than 256 using url with center lat/long

Thank you for this amazing lib !

I try to use it with goole maps static api and others provider.
With these tiles providers, we have to use a center latitude,longitude

(version 2.3 from maven)

It works well with tile of 256px with the following code, but with other tile size the map displayed is not ok.
Have you ever done some test with other tile size ??? 512 or 640, does it works ???
Is there any other change to do if the tile size change ????

MyTileFactoryInfo myTileFactoryInfo = new MyTileFactoryInfo("Google", 1, 20, 20, 256,
true,true,"https://maps.googleapis.com/maps/api/staticmap", ....

in TileFactoryInfo Class I use this code to convert x/y to lat/long

public String getTileUrl(int x, int y, int zoom)
{
	zoom = getTotalMapZoom() - zoom;
	
	double xtile = x + 0.5;
	double ytile = y + 0.5;

	double n = Math.pow(2.0,zoom);
	double lon_deg = ((xtile / n) * 360.0) - 180.0;
	double lat_rad = Math.atan(Math.sinh(Math.PI * (1 - 2 * ytile / n)));
	double lat_deg = (lat_rad * 180.0) / Math.PI;
	...

}

OSM tile not load

Below is my code (map part)

image

the tile not coming out... can anyone help me fix the code part.

image

image

offline map

Thank you for the good samples, i have a question, whether such maps can be created offline ?

geo position on mouse position returns wrong values

Hello,

I try to get the geo position of a mouse click position within the map, I add a MouseInputAdapter with addMouseListenerand the listener runs the code

public void mouseClicked(MouseEvent l_event)
{
   JXMapViewer l_src  = (JXMapViewer)l_event.getSource();
  System.out.println( l_src.getTileFactory().pixelToGeo(l_event.getPoint(),l_src.getZoom()));
   System.out.println( l_src.getCenterPosition() );
   System.out.println();
}

The output of the geo position is

[85.04939956663897, -179.94206428527832]
[50.35222445008026, 7.575244903564453]

another example

[85.05038273711463, -179.96354341506958]
[38.956989381812555, -95.26070237159729]

zoom level is 4 (both), so the result of pixelToGeo is wrong.
Thanks

Need help - Thanks

Hi Martin,

Sorry to report this incident under jxmapviewer2 but I can't find the solution to run the command "gradlew run" for 2D colormap explorer application. I get this error:

Could not resolve de.fhg.igd:pcolor:1.4.1.
Required by:
de.fhg.igd.iva:metrics:2018-07-17-08-07-32
Could not GET 'http://artifactory.esdi-humboldt.eu/artifactory/libs-release/de/fhg/igd/pcolor/1.4.1/pcolor-1.4.1.pom'.
> Connection to http://artifactory.esdi-humboldt.eu refused

It seems that the web address "http://artifactory.esdi-humboldt.eu" is no longer available.

Do you have other suggestions?

Many thanks,

Ivan

zoomToBestFit centers to wrong position

As mentioned in the last comment to issue #18
zoomToBestFit() still centers to a wrong position.

In my opinion there is something wrong with public void setCenter(Point2D center) in relation finding the right zoom level top down from the maximum zoom level. If the map has the same width and lenght it works fine. But if they are different you get a wrong center position of the map.

My workaround is not to set the max. ZoomLevel in zoomToBestFit() . But this does not solve the original problem.

        // set map to maximum zoomed out
        setZoom(info.getMaximumZoomLevel()-1);

Tile cache doesn't work if the URLs vary

Currently, the Tile Cache is based on the URL of the image inside. This doesn't work well for cases where the URL can vary, for example if there are multiple instances of the server and the URLs are distributed randomly between them (like s1.maps.example.com and s2.maps.example.com).

This can be handled in the Factory Info (so that it always returns something like (x + y) % number_of_servers), but I think the cache shouldn't rely on uniqueness of the URLs and instead should be based on the X, Y, zoom and mapId fields.

JavaFX version planned?

Hello,

thanks for continuation of the JXMapViewer project! I use it in my JavaFX based SportsTracker project ( https://github.com/ssaring/sportstracker ) and so I have to handle with many JavaFX<->Swing integration pitfalls.
Are there any plans to create a JavaFX based version of JXMapViewer?

Bye, Stefan

A whole lot of caching

Hi - thank you sooooo much for this simple-to-understand/simple-to-use library. I must have spent a solid week looking at alternatives until I found this.

I do have a question, though. I'm not trying to pick nits, but as I was reviewing the code to look for a place to handle offline maps I saw just how much caching is going on at various levels. There's the local response cache. There is the tile cache (which really seems to me to be an image cache). There is the tile map (which does seem to be a tile cache). I have put numerous trace messages in the methods and it appears to me that the tile map does almost all of the heavy lifting .. so much so that I question the value of the added complexity of all the other caches.

Are there usage scenarios I'm not thinking of where these other caches come into play, or are they there for historical reasons?

Inaccurate

Is it possible that the screen coordinates you get using convertGeoPositionToPoint() does not follow the wayPoint at the same GeoPosition.

I am drawing the waypoint and another thing overlaying it using convertGeoPositionToPoint() position and as I zoom in both of them don't follow each other.

Memeory Leak when used as component

I used JXMapViewer as a component in a Java Swing program in order to display objects on a map. You can turn the component on and of, even have multiples of them open. Whenever you close the parent frame, the component gets destroyed. Whenever you click to show the map in menu, the component gets recreated.

Eventually I ran into out of memory exceptions. I tracked the problem down to the ExecutorService, excerpt:

protected synchronized ExecutorService getService()
{
if (service == null)
{
// System.out.println("creating an executor service with a threadpool of size " + threadPoolSize);
service = Executors.newFixedThreadPool(threadPoolSize, new ThreadFactory()
...
}

The threads were being recreated over and over again.

The quick solution for me was to add a method to AbstractTileFactory

public void shutdownService() {
getService().shutdown();
}

and in that matter a wrapper method to JXMapViewer in order to access it:

public void shutdownService() {
if( getTileFactory() instanceof AbstractTileFactory) {
((AbstractTileFactory) getTileFactory).shutdownService();
}
}

It's called when my main panel with your component gets destroyed.

I'd prefer a proper way. Do you know of any?

By the way, a thing worth mentioning: I display only an excerpt of a world map from our server. If a tile doesn't exist on the server, it shows the usual replacement tile. I hope the issue isn't in combination of ExecutionService and the images not being found.

Thanks!

Control max extent

I suggest to add a new feature: control max extent.

On map init specify max extent (for zoom and pan of the map) and then check it on pan and move.

I've tried to add it and for Zoom is simple, just check maximum zoom on MouseWheelListener.
For pan I'm asking for support.

Thanks in advance

WMS problem with passed command

Using UMN Mapserver WMS service, there is an error present, which is resolved with this change in
WMSTileFactoryInfo

the question mark prior to the version parameter causes the issue.

Not sure if this is a UMN or jxmapviewer2 issue, so I have posted it to bring it to your attention.

//String url = getBaseURL() + "?version=1.1.1&request=GetMap&layers=" + this.getLayers() + "&format=" + this.getTileFormat()
// + "&bbox=" + bbox + "&width=" + tileSize + "&height=" + tileSize + "&srs=" + this.getSrs() + "&styles=" + this.getStyles() + (this.getTileBgColor()==null?"":"&bgcolor="+this.getTileBgColor());
String url = getBaseURL() + "version=1.1.1&request=GetMap&layers=" + this.getLayers() + "&format=" + this.getTileFormat()
+ "&bbox=" + bbox + "&width=" + tileSize + "&height=" + tileSize + "&srs=" + this.getSrs() + "&styles=" + this.getStyles() + (this.getTileBgColor()==null?"":"&bgcolor="+this.getTileBgColor());

onZoomListener ?

Hi!
I was wondering whether there is an event for a change of the zoom of the mapviewer? I basically want to have another component getting a notification if the zoom changes. My current solution would be to have separate listeners for double click, mouse wheel etc in order to get any situation that actually causes a zoom. But this seems a bit too complex to me.
Any idea is appreciated! :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.